cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
316
Views
5
Helpful
1
Replies
Highlighted

how to set a node type in python

Hi all,

I'm going template-less as changing the config directly in python

 

here is my issue, i don't know how to set type node eg

 

svi = root.devices.device[host].config.ios__interface.Vlan[vlan_id]
svi.standby.standby_list[vlan_id].authentication.auth = 'md5'
svi.standby.standby_list[vlan_id].authentication.md5.key_string.type = '0'
svi.standby.standby_list[vlan_id].authentication.md5.key_string.secret = 'bob1234'

 


<ERROR> 29-Jan-2020::22:08:57.929 svi_fractus ncs-dp-39743-svi_fractus:main-1-th-18412: - Node type does not support assignment
<ERROR> 29-Jan-2020::22:08:57.929 svi_fractus ncs-dp-39743-svi_fractus:main-1-th-18412: - Traceback (most recent call last):
File "/opt/ncs/ncs-4.7.2.1/src/ncs/pyapi/ncs/application.py", line 368, in wrapper
pl = fn(self, tctx, root, service, proplist)
File "/var/opt/ncs/state/packages-in-use/1/svi_fractus/python/svi_fractus/main.py", line 306, in cb_create
svi.standby.standby_list[vlan_id].authentication.auth = 'md5'
File "/opt/ncs/ncs-4.7.2.1/src/ncs/pyapi/ncs/maagic.py", line 473, in __setattr__
raise MaagicError("Node type does not support assignment")
ncs.maagic.MaagicError: Node type does not support assignment

 

any one have an example on how to achieve this ??

 

Thanks

Regards

Yale
 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Cisco Employee

Re: how to set a node type in python

So, what happens here is that different types of leafs have to be handled differently. In this case auth is not a leaf, it is a choice. (and mostly invisible in the data tree) If we look in tailf-ned-cisco-ios.yang in the ned it looks like this: 

        // interface * / standby * authentication
        container authentication {
          tailf:info "Authentication";
          choice auth {
            leaf word {
              tailf:cli-drop-node-name;
              tailf:cli-disallow-value "md5|text";
              type string {
                tailf:info "WORD;;Plain text authentication string (8 chars max)";
              }
            }
            container md5 {
              tailf:info "Use MD5 authentication";

              ...

You probably want to write md5 to authentication.word instead.

 

 

View solution in original post

1 REPLY 1
Highlighted
Cisco Employee

Re: how to set a node type in python

So, what happens here is that different types of leafs have to be handled differently. In this case auth is not a leaf, it is a choice. (and mostly invisible in the data tree) If we look in tailf-ned-cisco-ios.yang in the ned it looks like this: 

        // interface * / standby * authentication
        container authentication {
          tailf:info "Authentication";
          choice auth {
            leaf word {
              tailf:cli-drop-node-name;
              tailf:cli-disallow-value "md5|text";
              type string {
                tailf:info "WORD;;Plain text authentication string (8 chars max)";
              }
            }
            container md5 {
              tailf:info "Use MD5 authentication";

              ...

You probably want to write md5 to authentication.word instead.

 

 

View solution in original post