cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1930
Views
0
Helpful
12
Replies

Execute config-template XML using API

uwankhed
Cisco Employee
Cisco Employee

Hi

I have generated <config-template> XML for certain CLI commands using ntool. Then I tried searching for northbound API docs and some examples in NSO dir, but couldn't locate any API to execute this XML on NSO. Does anyone have the API handy and can share?

The sample <config-template> is:

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

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

  <device>

    <name>{$DEVICE}</name>

      <config>

        <radius xmlns="urn:ios">

          <server>

            <id>one</id>

            <address>

              <ipv4>

                <host>10.8.8.8</host>

                <auth-port>1812</auth-port>

                <acct-port>1813</acct-port>

              </ipv4>

            </address>

          </server>

        </radius>

      </config>

  </device>

</devices>

</config-template>

12 Replies 12

Dan.Sullivan
Cisco Employee
Cisco Employee

Hi Umesh,

The ntool is largely implemented by CLI plug-and-play scripting and can't be invoked northbound. You could certainly add an action that performs the same functions but it doesn't exist today.

-Dan

Hi Dan

Thanks for the reply. I was looking for northbound API to execute on NSO the generated config template xml from ntool.

e.g. How can I execute/apply on NSO this xml generated from ntool?

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

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

  <device>

    <name>{$DEVICE}</name>

      <config>

        <radius xmlns="urn:ios">

          <server>

            <id>one</id>

            <address>

              <ipv4>

                <host>10.8.8.8</host>

                <auth-port>1812</auth-port>

                <acct-port>1813</acct-port>

              </ipv4>

            </address>

          </server>

        </radius>

      </config>

  </device>

</devices>

</config-template>

-Umesh

Right, understood an action would have to added to solve this problem.

-Dan

Sorry, the xml was missing, added to my previous reply.

Do you mean, natively we can't execute this xml on NSO, it doesn't expose any northbound API?

-Umesh

Well the purpose of ntool is to help generate service and/or device templates, not necessarily to execute them as well. If you created a device template and then added it to NSO you can execute it using REST or whatever your choice is. Service templates are generated to be combined with a service package which is later loaded into NSO.

-Dan

Sorry to come back to this topic again. Dan, can you help me with more details on action part? If you can guide here, I can try adding this to the application. My goal is to add an ability to the tool so that I can invoke ntool using northbound API to generate xml template.

Hi Umesh,

There are two issues that I can see.

1. Ntool dynamically generates a config template however the template isn’t actually loaded into NSO and is unusable. In fact, a package reload operation would be needed to actually utilize the template(s). Package reload operations are typically executed during maintenance windows.

2. Config templates cannot be executed directly through the RESTCONF API. One alternative to this limitation is that you would define a YANG action that could in turn apply a template.

Of course, you can apply any set of configuration changes through the RESTCONF API without a template. So if you create the configuration changes you require you could apply them on the fly to NSO which would remove the need for a package reload operation or an action.

Thanks,

-Dan

Thanks for the comments. Can you let me know if it would be possible to invoke the ntool through APIs so that I can make the call from my application to generate config XML from CLI commands? From the previous discussion, I believe this would require some changes. Can you provide little guidance on this part, so that I can try on my own?

Also, the REST API which I could figure out so far to execute config XML on NSO is below. Is there a better way?

-Umesh

PATCH action on URL:

http://10.126.78.83:8080/api/running/devices/device/ios_192.168.99.194/config/?deep

Payload like this:

<config xmlns="http://tail-f.com/ns/ncs" xmlns:y="http://tail-f.com/ns/rest"  xmlns:ncs="http://tail-f.com/ns/ncs">
       <interface xmlns="urn:ios">
         <Loopback>
           <name>1175</name>
           <ip>
             <address>
               <primary>
                 <address>1.9.9.3</address>
                 <mask>255.255.255.255</mask>
               </primary>
             </address>
           </ip>
         </Loopback>
</interface>
</config>

jjgrinwis
Level 1
Level 1

I guess you want this, applying a template to a device:

Screen Shot 2018-04-12 at 21.54.13.png

Thanks John. The approach you have suggested would require the device template to be present on NSO (If I understand correctly). I was looking for API which would take xml template payload and apply to the device, or even better API to execute service template xml which would be applied across devices. Though, I am not sure if NSO even exposes any such northbound APIs.

@uwankhed did you manage to supply the .xml config to a nso via an api call, so that it can apply it on a router? if yes, would you mind sharing more details about it?

Just tried NSO ver4.4, this API creates a template:

 

curl -X POST --header 'Content-Type: application/vnd.yang.data+json' --header 'Accept: text/html' --header 'Authorization: Basic YWRtaW46YWRtaW4=' -d '{
  "tailf-ncs:template": [
    {
      "tailf-ncs:name": "TMPL1",
      "tailf-ncs:config": {
        "tailf-ned-cisco-asa:hostname": "string1"
      }
    }
  ]
}' 'http://localhost:8080/api/running/devices'

 

This tool https://gitlab.com/nso-developer/rest-api-explorer  can be used to build the config part by clicking the parameters you want to be included in the template, as well as the curl command (tool also builds XML payload). This user guide  has all the details, which includes an example to create new device template.

 

Looking at briefly NSO ver 5.5.2 in rest-api-explorer tool, click this:

/restconf/data/tailf-ncs:devices/tailf-ncs:template={name}/tailf-ncs:config

it says:  Just to support releases prior to 4.5. Will be deprecated. Not sure when this will happen in future.

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 NSO Developer community: