cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1382
Views
1
Helpful
9
Replies

[NSO-4.6.2] cli perform deactivate over junos using MAAPI

romain.guilloux
Level 1
Level 1

Hello,

 

    I would like to perform over JUNIPER devices :

 

rguilloux@ncs(config)# deactivate devices device ysty....

 

I wants to use ncs maapi/maagic python API to perform it but I don't find any command in root object for it :

 

with ncs.maapi.Maapi() as m:
    with ncs.maapi.Session(m, "nso", "pyNORTHNSO"):
        with m.start_write_trans() as t:
            root = ncs.maagic.get_root(t)
            out = root.devices.device["RNET-M6"]
            for i in out.config:
                print i

Any idea of how to launch deactivate using NSO python API ?

 

Thanks,

 

Romain

9 Replies 9

Jan Lindblad
Cisco Employee
Cisco Employee

You would have to use the low-level MAAPI (not MAAGIC) API to set attributes ("inactive" is an attribute). Setting attributes from a service does not work the way you'd expect, however, so I can't recommend this approach.

sayeali
Cisco Employee
Cisco Employee

Hello Jan ,

Could you pls suggest How to perform the same using restconf .

 this /restconf/data/tailf-ncs:devices/device=junos1/config/junos:configuration/groups=BASE-SYSTEM/system/commit/synchronize

to 

inactive: /restconf/data/tailf-ncs:devices/device=junos1/config/junos:configuration/groups=BASE-SYSTEM/system/commit/synchronize

to this 



Jan Lindblad
Cisco Employee
Cisco Employee

As far as I am aware, there is no ready made YANG rpc/action to set (and remove) the inactive flag on some data tree path. The good news is that you can (easily?) write such an action with the YANG interface of your choice. That action would then use the low level MAAPI interface to set (or remove) the inactive attribute. The action could be specific to the path you mention, or you could make it more generic, accepting a data tree path to the element to be inactivated.

Hi,

Thanks for the prompt reply Jan .

I have got a one way of doing that is using inactive and using content-type as +xml instead +json 

url = "http://X.X.X.X:Port/restconf/data/"

content-type = "application/yang-data+xml"
<devices xmlns="http://tail-f.com/ns/ncs">
<device >
<name>junos1</name>
<config>
<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm">
<groups>
<name >BASE-SYSTEM</name>
<system >
<commit active="active">
<synchronize />
</commit>
</system>
</groups>
</configuration>
</config>
</device>
</devices>

However its working fine on till commit level of tree when I m trying to perform on synchronize its not working .

Any suggestion

Jan Lindblad
Cisco Employee
Cisco Employee

The request message to reactivate <commit> looks right to me (assuming that was the element deactivated earlier). If the device doesn't behave as expected when you send this message, maybe posing a question to the device vendor's support organization might give some clue as to what is wrong? Or you could resort to classical management operations like create/delete.

As mentioned above your assumption is correct I have sent you a sample of reactivation.


<devices xmlns="http://tail-f.com/ns/ncs">
<device >
<name>junos1</name>
<config>
<configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm">
<groups>
<name >BASE-SYSTEM</name>
<system >
<commit inactive="inactive">
<synchronize />
</commit>
</system>
</groups>
</configuration>
</config>
</device>
</devices>

 However when I m performing the same with .
......above similar code 

<system >
<commit>
<synchronize inactive="inactive"/>
</commit>
</system>
....... code

apparently this is not performing the expected operation similar to how we get output from CLI on triggering below command .

admin@ncs(config)# deactivate devices device junos1 config configuration groups BASE-SYSTEM system commit synchronize

admin@ncs(config)# show full-configuration devices device junos1 config configuration groups BASE-SYSTEM system commit synchronize | display xml

admin@ncs(config)# show full-configuration devices device junos1 config configuration groups BASE-SYSTEM system commit synchronize | display xml

```

<config xmlns="http://tail-f.com/ns/config/1.0">

  <devices xmlns="http://tail-f.com/ns/ncs">

    <device>

      <name>junos1</name>

      <config>

        <configuration xmlns="http://xml.juniper.net/xnm/1.1/xnm">

          <groups>

            <name>BASE-SYSTEM</name>

            <system>

              <commit>

                <synchronize inactive="inactive"/>

              </commit>

            </system>

          </groups>

        </configuration>

      </config>

    </device>

  </devices>

</config>

```






Jan Lindblad
Cisco Employee
Cisco Employee

I would suggest connecting with the device vendor to find out how the inactive mechanism works in this part of the data tree. Once we know that, we can try to make NSO send the right thing.  Or, as there doesn't seem to be tons of config below <synchronize> that you are trying to preserve temporarily by marking it as inactive, maybe delete and create may be a more suitable choice of operations.

THanks Jan Probably will try for TAC or device vendor as there are couple of more commands need to be executed .

 

sayeali
Cisco Employee
Cisco Employee

Works fine on real devices where as problem or limitation on netsim devices