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

Suggest examples in the README (or Wiki). #40

Closed
mike-albano opened this issue Feb 20, 2020 · 8 comments · Fixed by #46
Closed

Suggest examples in the README (or Wiki). #40

mike-albano opened this issue Feb 20, 2020 · 8 comments · Fixed by #46
Assignees
Labels
documentation enhancement New feature or request

Comments

@mike-albano
Copy link

I could use an example of how to formulate a Subscription.

Suggestion for documentation:
For the README or WiKi, I'd suggest something like the following:

Working example of OpenConfig Streaming Telemetry on Aceess Point.

from cisco_gnmi import ClientBuilder

builder = ClientBuilder('192.168.0.5:8080')
builder.set_secure_from_target()
builder.set_ssl_target_override('openconfig.mojonetworks.com')
builder.set_call_authentication('admin', 'admin')
client = builder.construct()

paths = [client.parse_xpath_to_gnmi_path('/access-points/access-point[hostname="test-ap.example.net"]/radios/radio[id="0"]/state/rx-noise-channel-utilization/')]
print(client.get(paths))

You may also want to provide a pointer in your documentation that list-key values must be quoted due to your xpath parsing. Even if the list-key is an int (like the radio id in the above example).

@remingtonc remingtonc self-assigned this Feb 20, 2020
@remingtonc remingtonc added documentation enhancement New feature or request labels Feb 20, 2020
@remingtonc
Copy link
Contributor

Good idea - certainly something to do. The XPath predicates needing to be strings seems more like a bug to be investigated, filing.

@mike-albano
Copy link
Author

Sg, thanks. If you could share a sample of valid syntax for a subscribe (which passes the 'validate_request') I'd be happy to do some testing with net elements we have which support ST as of now.

@remingtonc
Copy link
Contributor

@mike-albano I'll be away from a laptop until Monday but in the meantime check out the subscribe_xpaths method in the respective OS clients. Will help debug, but not as effectively for several days!

@remingtonc
Copy link
Contributor

Addressing in doc-examples.

@remingtonc
Copy link
Contributor

@mike-albano Apologies for the delay here. In the meantime, added some level of a CLI which lightly demonstrates usage of the library. https://github.com/cisco-ie/cisco-gnmi-python/blob/doc-examples/src/cisco_gnmi/cli.py#L148

Reading your issue more, I see this doesn't totally address what you are asking. Will address this tonight with some more direct examples.

@mike-albano
Copy link
Author

Sounds good.
I've been messing with it a bit; still a little unclear on your args.os, so I've been manually over-riding, but I'll wait for some examples then take a closer look. Thanks.

@remingtonc
Copy link
Contributor

@mike-albano The args.os corresponds to the OS-specific wrapper to utilize. https://github.com/cisco-ie/cisco-gnmi-python/blob/master/src/cisco_gnmi/builder.py#L77-L82

So specifying IOS XR will give IOS XR convenience functions, IOS XE for IOS XE, etc. None simply returns the base Client implementation.

@remingtonc
Copy link
Contributor

@mike-albano It's not pretty but I'm lagging on this too hard to not give some examples - here is a "custom" usage of the base Client class. Several other scripts in branch directory. https://github.com/cisco-ie/cisco-gnmi-python/blob/actual-doc-examples/examples/custom.py

Please ask any questions, happy to collaborate directly on code if desired. Can set something up meeting-wise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants