CiscoTestAutomation / ncdiff

NETCONF Diff Engine
Apache License 2.0
23 stars 5 forks source link

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

Open muffi-dn opened 1 year ago

muffi-dn commented 1 year ago

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.

sumitsehgal123 commented 1 year ago

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

sumitsehgal123 commented 1 year ago

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 commented 1 year ago

Hi Please let know the update on the above ,

yuekyang commented 1 year ago

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

sumitsehgal123 commented 1 year ago

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 .

muffi-dn commented 1 year ago

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.

yuekyang commented 1 year ago

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>
muffi-dn commented 1 year ago

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

sumitsehgal123 commented 1 year ago

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

muffi-dn commented 1 year ago

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

sumitsehgal123 commented 1 year ago

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

sumitsehgal123 commented 12 months ago

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 commented 11 months ago

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 .