cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3323
Views
0
Helpful
5
Replies

Yang model to change device configuration

Chitra
Cisco Employee
Cisco Employee

Hi!

I have a basic doubt in flow. can anyone please help?

1)How do we find correct namespace ?

2) how to find complete yang model definition( i.e xml format ) for the device and its corresponding namespace?

3) who and where is yang model defined for a device? Does it vary for every device or will it remain as 1 yang model for ios , 1 yang model for ios_xr and 1 yang model for nx device?

Doing GET request wont give all possible tags which can be configured. All i need to achieve is  to generalize this xml request body so any configuration can be pushed in one shot.

i used http://localhost:port/api/running/ncs:devices/ncs:device/ios_xr with below PATCH request body

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

   <port>23</port>

   <state>

        <admin-state>unlocked</admin-state>

    </state>

    <config>

                   <logging xmlns="http://tail-f.com/ned/cisco-ios-xr">

                    <host>

                <address>9.9.9.9</address>

            </host>

            </logging>

            <interface xmlns="http://tail-f.com/ned/cisco-ios-xr">

            <Loopback>

                <id>1007</id>

            </Loopback>

            </interface>

      </config>

      </device>

1 Accepted Solution

Accepted Solutions

Jan Lindblad
Cisco Employee
Cisco Employee

1)How do we find correct namespace ?

Not sure what task you are trying to perform, but if you have some config in NSO that you'd like to understand the structure and namespaces of, you can issue an NSO show command and use pipe-flags:

show ... | display xml

show ... | display xpath | display prefixes

If instead you are looking at YANG files, the namespace prefix is specified at the top of the file.

2) how to find complete yang model definition( i.e xml format ) for the device and its corresponding namespace?

Hmm, YANG schema files are not in XML. If you're looking for the *configuration* in XML format, try the

show ... | display xml

command above.

3) who and where is yang model defined for a device? Does it vary for every device or will it remain as 1 yang model for ios , 1 yang model for ios_xr and 1 yang model for nx device?

Each device publishes a set of YANG modules of a particular version. Exactly which ones may vary from one version of one device to another, and definitely between device families and vendors. Some YANGs modules, especially IETF standard modules, may be the same across many devices.

In the NSO world, many NEDs have a single YANG file (or two-three) that covers all the functionality for an entire device family like IOS-XE, NX or IOS-XR. In NETCONF NEDs, there are often many hundred YANG modules. So the answer depends on both what device type and what connection method you are using.

Doing GET request wont give all possible tags which can be configured. All i need to achieve is  to generalize this xml request body so any configuration can be pushed in one shot.

That's right. A lot of people that are not so used to YANG schemas would configure whatever feature they want to use on the device, then issue a NETCONF get-config (sync-from in NSO) to see how this is represented using the show ... | display xml command described above. Experienced YANG readers can just look at the YANG and infer this directly.

View solution in original post

5 Replies 5

Jan Lindblad
Cisco Employee
Cisco Employee

1)How do we find correct namespace ?

Not sure what task you are trying to perform, but if you have some config in NSO that you'd like to understand the structure and namespaces of, you can issue an NSO show command and use pipe-flags:

show ... | display xml

show ... | display xpath | display prefixes

If instead you are looking at YANG files, the namespace prefix is specified at the top of the file.

2) how to find complete yang model definition( i.e xml format ) for the device and its corresponding namespace?

Hmm, YANG schema files are not in XML. If you're looking for the *configuration* in XML format, try the

show ... | display xml

command above.

3) who and where is yang model defined for a device? Does it vary for every device or will it remain as 1 yang model for ios , 1 yang model for ios_xr and 1 yang model for nx device?

Each device publishes a set of YANG modules of a particular version. Exactly which ones may vary from one version of one device to another, and definitely between device families and vendors. Some YANGs modules, especially IETF standard modules, may be the same across many devices.

In the NSO world, many NEDs have a single YANG file (or two-three) that covers all the functionality for an entire device family like IOS-XE, NX or IOS-XR. In NETCONF NEDs, there are often many hundred YANG modules. So the answer depends on both what device type and what connection method you are using.

Doing GET request wont give all possible tags which can be configured. All i need to achieve is  to generalize this xml request body so any configuration can be pushed in one shot.

That's right. A lot of people that are not so used to YANG schemas would configure whatever feature they want to use on the device, then issue a NETCONF get-config (sync-from in NSO) to see how this is represented using the show ... | display xml command described above. Experienced YANG readers can just look at the YANG and infer this directly.

Hi ,

Thanks much! I used below  to convert yang to xml,


pyang -f sample-xml-skeleton tailf-ned-cisco-ios.yang


But it throws error as few modules not in search path eg.tailf-common, ietf-inet-types etc.

How can i resolve this ?

Are there any tool to convert yang to xml,?

You can use the --path= flag to tell Pyang where you keep your YANGs.

There are several popular ways to generate NETCONF/XML payload configuration data

a) Use the device: log in on a relevant device and configure it as you like. Then run a <get-config> towards it. You'll get your configuration expressed in NETCONF/XML.

b) Use NSO: log in to NSO and configure a real or simulated device as you like. Then run a <get-config> towards either the (simulated) device or NSO. You'll get your configuration expressed in NETCONF/XML. Or you can simply run a show running-config .. | display xml in NSO.

As far as I know those two are the most popular approaches. You could certainly also use the methods below, but AFAIK they are less popular:

c) Set up a (free) confd instance and configure it as you like, then show .. | display xml in the CLI or run a <get-config>.

d) Use the pyang -f sample-xml-skeleton

/jan

Hi !

can anyone please help answering below ?

1) where can  i find device specific yang files in NSO managed devices?

a)Is it same as ned yang files(eg: ncs-4.4.2\packages\neds\cisco-ios\src\yang)?

b)Does this mean for all ios device <ncs-4.4.2\packages\neds\cisco-ios\src\yang> is the yang model used ?

note : I am trying to push configuration patch request using pyang -f sample-xml-skeleton output of this file on to device

2)I can see four

tailf-ned-cisco-ios,tailf-ned-cisco-ios-id,tailf-ned-cisco-ios-meta,tailf-ned-cisco-ios-oper,tailf-ned-cisco-ios-stats files in package yang folder.

a)What does each mean ?

b)Which file should i complie using pyang -f sample-xml-skeleton in order to use its output as request body for

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

to change configuration of ios device.

Please re-ask this question in a new thread.