02-06-2020 09:56 AM - edited 02-06-2020 09:58 AM
Hi team, this is my first post so apologies if this is not posted in the correct forum. Please help me move it to the correct one if it shouldnt be here.
We are using NSO service package with Python and template...
We take in 3 variables from yang, device name, interface number and true or false for shutdown.
in xml output, for no shut interface it looks like this...
root@ncs> request devices device mario_nexus sync-from dry-run { outformat xml } result-xml <interface xmlns="http://tail-f.com/ned/cisco-nx"> <Ethernet> <name>101/1/1</name> <shutdown xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="delete"/> </Ethernet> </interface> [ok][2020-02-06 09:12:16] root@ncs>
for shutting down the interface the XML generated looks like this...
root@ncs> request devices device mario_nexus sync-from dry-run { outformat xml } result-xml <interface xmlns="http://tail-f.com/ned/cisco-nx"> <Ethernet> <name>101/1/1</name> <shutdown/> </Ethernet> </interface> [ok][2020-02-06 09:11:03]
i'm trying to use if statements in the python logic and a variable in the XML template so that if shutdown is true, then just send a blank string leaving the xml untouched. However if shutdown is false (i.e. no shutdown) then append the <shutdown/> element with a variable so the template looks like the below...
<device> <name>{$DEVICE}</name> <config> <interface xmlns="http://tail-f.com/ned/cisco-nx"> <Ethernet> <name>{$INTERFACE}</name> <shutdown {$ACTION}/> </Ethernet> </interface> </config> </device>
so for a shutdown action the ACTION variable would be blank string resulting in <shutdown /> whereas for no shutdown it would append like this... <shutdown xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="delete"/>
However when reloading the packages in NSO i get errors about the XML syntax... does anyone know how this can be corrected or a different way to achieve shut/no shut of Nexus Ethernet interfaces?
reload-result { package shutdown-switchport-nexus result false info [shutdown-switchport-nexus-template.xml:10: Invalid attribute syntax in tag 'shutdown'.] }
thanks and much appreciated for the help!
Mario
02-06-2020 10:55 AM
02-06-2020 12:44 PM
Hi,
where can i find this Developer guide and also your manual?
i dont see any links and i have google searched but i cant seem to find what you are referring to.
thanks
Mario
02-06-2020 01:09 PM
02-06-2020 11:22 PM
02-11-2020 02:19 AM
Hi, so if we use the delete tag to delete shutdown i.e. doing a no shutdown... how would we be able to initiate a shutdown....? do we do this via a variable?
02-11-2020 05:02 AM
02-19-2020 09:33 AM
Hi thanks for your help on this so far... ok im getting close... i can now shutdown the interface using the delete tag as per the developer guide. Now i have 2 problems..
1) if i change the state of the interface back to shutdown and then try and re-run the "no shutdown" service, NSO keeps advising that there are no changes to commit so never pushes any config to no shut the interface again. If i create a brand new interface the no shutdown service always works the first time but never again... what would cause that?
2) i need to adapt the service to be able to do a shutdown, when you say create two branches with the tag delete in one and create in the other... does that mean that the service would just do the opposite of what the current state is? so if shutdown tag is already deleted it would run the create tag... and if create tag is already created, it would run the delete tag? Or do i have to build some logic of my own using Python and template variables?
thanks so much for this!
Mario
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide