cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

How to POST a sample configuration file/command to NSO server using REST API

khgrant
Cisco Employee
Cisco Employee

 

Hey all,

 

             I started working with NSO. I am trying to POST a configuration to NSO client, say ‘a0’ which I created using netsim. I am able to GET most of the things. But I am not able to POST some very basic commands also.

 

 

              My target is to send some configuration to ‘a0’ , apply it there, and then get back the configuration using GET.

 

For example, consider the case below: In this I want to configure a new neighbor id: 10.10.10.20. But I don’t know how to send the corresponding REST API to POST. I can access elements till bgp and I am unable to access any element inside this  “"tailf-ned-cisco-ios:bgp": [ ].”.

 

 

 

http://localhost:8080/api/running/devices/device/a0/config/ios:router/bgp/

 

The output of this is In json:

 

 

{

 

  "collection": {

 

    "tailf-ned-cisco-ios:bgp": [

 

      {

 

        "as-no": 64512,

 

        "aggregate-address": {

 

          "address": "10.10.10.1",

 

          "mask": "255.255.255.251"

 

        },

 

        "bgp": {

 

          "bestpath": {},

 

          "nexthop": {}

 

        },

 

        "distance": {},

 

        "neighbor": [

 

          {

 

            "id": "1.2.3.4"

 

          },

 

          {

 

            "id": "2.3.4.5"

 

          },

 

          {

 

            "id": "10.10.10.0"

 

          }

 

        ],

 

        "redistribute": {

 

          "isis": {},

 

          "iso-igrp": {}

 

        },

 

        "address-family": {}

 

      }

 

    ]

 

  }

 

}

 

 

Corresponding xml configuration is as follows:

 

 

<collection xmlns:y="http://tail-f.com/ns/rest">

 

    <bgp xmlns="urn:ios">

 

        <as-no>64512</as-no>

 

        <aggregate-address xmlns="urn:ios">

 

            <address>10.10.10.1</address>

 

            <mask>255.255.255.251</mask>

 

        </aggregate-address>

 

        <bgp xmlns="urn:ios">

 

            <bestpath xmlns="urn:ios">

 

      </bestpath>

 

            <nexthop xmlns="urn:ios">

 

      </nexthop>

 

        </bgp>

 

        <distance xmlns="urn:ios">

 

    </distance>

 

        <neighbor xmlns="urn:ios">

 

            <id>1.2.3.4</id>

 

        </neighbor>

 

        <neighbor xmlns="urn:ios">

 

            <id>2.3.4.5</id>

 

        </neighbor>

 

        <neighbor xmlns="urn:ios">

 

            <id>10.10.10.0</id>

 

        </neighbor>

 

        <redistribute xmlns="urn:ios">

 

            <isis xmlns="urn:ios">

 

      </isis>

 

            <iso-igrp xmlns="urn:ios">

 

      </iso-igrp>

 

        </redistribute>

 

        <address-family xmlns="urn:ios">

 

    </address-family>

 

    </bgp>

 

</collection>

 

 

Any help will be appreciated.

 

 

Thanks and regards

 

Pradeep

 

3 REPLIES 3

khgrant
Cisco Employee
Cisco Employee

 

Hi Pradeep,

 

 

You may need to use “patch”. As this looks like you are sending in configuration to an existing devices vs. instantiating a new service.

 

 

I do not use json, but XML – here I patch the configuration tree within NSO for an element called “nfvo”

 

 

 

khgrant
Cisco Employee
Cisco Employee

 

Hi Pradeep,

 

 

A short intro that might help. It is using XML, but that should make much of a difference…

 

 

BR,

 

Bostjan

 

khgrant
Cisco Employee
Cisco Employee

 

Hi,

 

 

POST creates a new resource, and the URI for POST is always the parent of the resource you want to create.

 

The parent in your case looks like the bgp list instance with key as-no '64512', so the URI should be (I am shooting from the hip here):

 

http://localhost:8080/api/running/devices/device/a0/config/ios:router/bgp/64512

 

 

You want to create a new 'neighbor', which is list. So, the payload should be the list-instance config. Something like:

 

 

<neighbor>

 

   <id>10.10.10.20</id>

 

</neighbor>

 

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: