cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Announcements
397
Views
0
Helpful
4
Replies
khgrant
Cisco Employee

'load merge' with API

Hello team,

I would like to automate the following flow:

  1. A config xml file for a device is stored on a repository;

  2. Some changes are performed on the xml file to change the configuration of the device;

  3. An application is triggered on the NSO server that loads the xml file and perform a ‘load merge <filename>’ and ‘commit’ on that device.

What is the best way to accomplish this using any of the NSO APIs? I would prefer to use python, but eventually also java will do.

1 ACCEPTED SOLUTION

Accepted Solutions
khgrant
Cisco Employee

This is very easy, there is Java API and Python API to load an XML (or cli) file. Maapi.loadConfig()

Also commandline tool ncs_load does this

See man page for ncs_load

The file must adhere to NSO data models though, so if we have dev.xml - which is th device config for device "d1", we must enclose the contents of dev.xml with

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

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

    <device>

     <name>d1</name>

      ... content of dev.xml

    </device>

   </devices>

</config>

And just load this data into NSO, it'll then be pushed to the device d1

View solution in original post

4 REPLIES 4
khgrant
Cisco Employee

This is very easy, there is Java API and Python API to load an XML (or cli) file. Maapi.loadConfig()

Also commandline tool ncs_load does this

See man page for ncs_load

The file must adhere to NSO data models though, so if we have dev.xml - which is th device config for device "d1", we must enclose the contents of dev.xml with

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

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

    <device>

     <name>d1</name>

      ... content of dev.xml

    </device>

   </devices>

</config>

And just load this data into NSO, it'll then be pushed to the device d1

View solution in original post

khgrant
Cisco Employee

Thanks a lot! I will give it a try today.

One more question. Is there another API that I can use to export a device configuration at the moment in which I do a commit, with a post-commit script?

I would like to do the following:

  1. Some changes are done on one or more devices, due to a manual configuration on the device on the nso cli

  2. After the commit is executed I want to execute a post-commit script that saves the configuration of the changed devices in the file systems, in xml format (like when we execute the command ‘show full-configuration devices device <device_name> | display xml | save <file_name>.xml

So the post-commit script must have an API to get the list of devices whose configuration has changed by the commit and another API to export the configuration of those devices into an xml file. Is this possible?

khgrant
Cisco Employee

Would someone please unicast me a link to download version 3.3. I have 3.4, but I want 3.3.

khgrant
Cisco Employee

Yes - there is such an API.

You'd have to do a bit of programming though.

1. A CDB subscriber that subscribes to /devices/device

2. Whenever it triggers, it can diffIterate() through the

    change a figure out which devices are affected.

3. Grab the running config from those devices and save it.

See e.g examples.ncs/getting-started/developing-with-ncs/1-cdb/

I prefer the "low-level" CDB subscriber API to the Navu ones.

Create
Recognize Your Peers
Content for Community-Ad