ncdiff icon indicating copy to clipboard operation
ncdiff copied to clipboard

How do you load roots for cases where the feature module uses augments ?

Open muffi-dn opened this issue 2 years ago • 13 comments

I was trying to understand the flow for a case where there is a top level yang module and then the other yang modules (features) use augments for updating the top level module. In such cases, the only way to retreive any configurational data is to use the top module which returns the entire configuration while using the other feature modules results in a tree without a root which does not work directly.

muffi-dn avatar Jun 20 '23 17:06 muffi-dn

Hi . Thanks for reaching out piestack support team, I will be looking at your ticket and get back to you .

sumitsehgal123 avatar Aug 04 '23 04:08 sumitsehgal123

HI , a YANG data model composed of multiple modules, and some of these modules use the "augment" statement to add data to the structure defined in another module. However, when retrieving configurational data, you're facing challenges because the augmented data in feature modules doesn't seem to have a clear root.

In YANG, the "augment" statement is used to extend the schema of an existing data structure defined in another module. This can be quite useful for adding optional features or additional data to a base module without modifying the original module's structure.

When you retrieve data from these YANG modules using NETCONF or RESTCONF protocols (commonly used for configuration management), you should be able to navigate the structure regardless of the module in which it was defined.

sumitsehgal123 avatar Aug 21 '23 15:08 sumitsehgal123

Hi Please let know the update on the above ,

sumitsehgal123 avatar Aug 24 '23 23:08 sumitsehgal123

Even augment is preferred for some reason, the common way to retreive any configurational data is to use the top module with a proper filter that can define which part of configuration should be returned. Examples of subtree filter can be found in https://www.rfc-editor.org/rfc/rfc6241#section-6

yuekyang avatar Aug 25 '23 20:08 yuekyang

Hi Mufaddal, Please let us know the update on above . I hope you will able to resolved your quires .if not ,Please let us know .

sumitsehgal123 avatar Aug 29 '23 05:08 sumitsehgal123

yea i tried with the top level module but it does not seem to work. Do you have a working example which i can refer to ? I know ios-xe uses a top level module but i don't have access to it right now.

muffi-dn avatar Aug 29 '23 09:08 muffi-dn

The root of Cisco IOS-XE native models, /ios:native, is defined in Cisco-IOS-XE-native.yang. Say we want to retrieve config under /ios:native/ios:aaa/ios-aaa:group and nc is the Netconf session object:

from ncclient import xml_

filter = """
<filter xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
    <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
        <aaa>
            <group xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-aaa"/>
        </aaa>
    </native>
</filter>
"""
reply = nc.get_config(source='running', filter=xml_.to_ele(filter))

reply only contains config inside the subtree, which is defined in Cisco-IOS-XE-aaa.yang by an augment statement:

>>> print(reply)
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:cfadd6ab-587c-4e89-aa35-dd42e2fa9d43">
  <data>
    <native xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-native">
      <aaa>
        <group xmlns="http://cisco.com/ns/yang/Cisco-IOS-XE-aaa">
          <server>
            <radius>
              <name>abc</name>
            </radius>
          </server>
        </group>
      </aaa>
    </native>
  </data>
</rpc-reply>

yuekyang avatar Sep 01 '23 20:09 yuekyang

Thanks @yuekyang for the response but I think I understand yang models and how augments are used in general but I wanted to see if it can work fine with ncdiff. I currently can't seem to get ncdiff working when there are augments defined in a yang model.

Thanks

muffi-dn avatar Sep 04 '23 12:09 muffi-dn

Hi, Thanks for confirmation , I hope you are satisfied with our answer , and your issue related quires has been solved .

sumitsehgal123 avatar Sep 06 '23 15:09 sumitsehgal123

@sumitsehgal123 The query is still unresolved, I wanted to check how ncdiff handles augments and see an example with IOS-XE if possible.

muffi-dn avatar Sep 06 '23 15:09 muffi-dn

Sure , Please give us sometime to find the best answers with example for your quires after that we get back to you .

sumitsehgal123 avatar Sep 06 '23 16:09 sumitsehgal123

Hi @muffi-dn Please can share piece of code and the error spinet .We are not able understand what exactly issue you are facing. Please can you explain it here .

@yuekyang has posted the example for ncdiff not ncclient. Sohttps://github.com/CiscoTestAutomation/ncdiff/issues/22#issuecomment-1703291735

sumitsehgal123 avatar Sep 15 '23 09:09 sumitsehgal123

Please could you share piece of code and the error spinet .We are not able understand what exactly issue you are facing. Please can you explain it here .

sumitsehgal123 avatar Sep 20 '23 09:09 sumitsehgal123