Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
muffi-dn opened this issue Jun 20, 2023 · 13 comments
Open
Assignees

Comments

@muffi-dn
Copy link

muffi-dn commented Jun 20, 2023

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
Copy link

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

@sumitsehgal123
Copy link

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
Copy link

Hi
Please let know the update on the above ,

@yuekyang
Copy link
Collaborator

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
Copy link

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
Copy link
Author

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
Copy link
Collaborator

yuekyang commented Sep 1, 2023

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
Copy link
Author

muffi-dn commented Sep 4, 2023

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
Copy link

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

@muffi-dn
Copy link
Author

muffi-dn commented Sep 6, 2023

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

@sumitsehgal123
Copy link

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

@sumitsehgal123
Copy link

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//issues/22#issuecomment-1703291735

@sumitsehgal123
Copy link

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 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants