cisco-ie / ios-xr-grpc-python Goto Github PK
View Code? Open in Web Editor NEWIOS-XR gRPC Python connectivity library.
License: Other
IOS-XR gRPC Python connectivity library.
License: Other
Hi @skkumaravel,
Thanks a lot for providing these examples!
I've got just a quick question: is it possible to specify in the proto file to return XML instead of JSON?
Regards,
Mircea
suggestion, to upgrade requirements.txt packages of grpcio
and protobuf
grpcio==1.36.1
protobuf==3.15.6
why?
add support for python 3.9+
tested locally
git clone https://github.com/cisco-ie/ios-xr-grpc-python.git
(modify requirements.txt)
pip3 install -e .
Defaulting to user installation because normal site-packages is not writeable
Obtaining file:///workspaces/cisco-devnet-quiz/classroom/solved/model-driven_programmability_stack/grpc/ios-xr-grpc-python
Collecting grpcio==1.36.1
Using cached grpcio-1.36.1-cp39-cp39-manylinux2014_x86_64.whl (4.1 MB)
Requirement already satisfied: six>=1.5.2 in /home/vscode/.local/lib/python3.9/site-packages (from grpcio==1.36.1->iosxr-grpc==1.3) (1.15.0)
Collecting protobuf==3.15.6
Using cached protobuf-3.15.6-cp39-cp39-manylinux1_x86_64.whl (1.0 MB)
Installing collected packages: protobuf, grpcio, iosxr-grpc
Running setup.py develop for iosxr-grpc
Successfully installed grpcio-1.36.1 iosxr-grpc protobuf-3.15.6
setup.py
also needs to be updated for pypi
from setuptools import setup
setup(name='iosxr_grpc',
version='1.3',
description='gRPC library for IOS-XR > 6.1.1',
url='https://github.com/cisco-grpc-connection-libs/ios-xr-grpc-python',
author='Karthik Kumaravel',
authoer_email='[email protected]',
licencse='Apache 2.0',
packages=['iosxr_grpc'],
install_requires=[
'grpcio==1.36.1',
'protobuf==3.15.6',
],
zip_safe=False)
hello, i tried to execute example on 6.1.1 IOS-XRv. output below:
vagrant@vagrant-ubuntu-trusty-64:~/cisco_grpc_python$ python grpc_example.py
Traceback (most recent call last):
File "grpc_example.py", line 15, in
main()
File "grpc_example.py", line 10, in main
result = client.getconfig(path)
File "/home/vagrant/cisco_grpc_python/client/cisco_grpc_client.py", line 58, in getconfig
for response in responses:
File "/usr/local/lib/python2.7/dist-packages/grpc/beta/_client_adaptations.py", line 153, in next
return self._next()
File "/usr/local/lib/python2.7/dist-packages/grpc/beta/_client_adaptations.py", line 147, in _next
raise _abortion_error(rpc_error_call)
grpc.framework.interfaces.face.face.ExpirationError: ExpirationError(code=StatusCode.DEADLINE_EXCEEDED, details="Deadline Exceeded")
When i try to get interface config with the following path it raises an error:
path_intf = '{"Cisco-IOS-XR-ifmgr-cfg:interface-configurations": [null]}'
getconfig(path_intf)
The following paths for example work ok:
path_isis = '{"Cisco-IOS-XR-clns-isis-cfg:isis": [null]}'
path_route_Static = '{"Cisco-IOS-XR-ip-static-cfg:router-static": [null]}'
path_telemetry = '{"Cisco-IOS-XR-telemetry-model-driven-cfg:telemetry-model-driven": [null]}'
For path_intf the following error is raised:
[libprotobuf ERROR C:\projects\protobuf\protobuf\src\google\protobuf\wire_format_lite.cc:626] String field 'IOSXRExtensibleManagabilityService.ConfigGetReply.yangjson' contains invalid UTF-8 data when parsing a protocol buffer. Use the 'bytes' type if you intend to send raw bytes.
Traceback (most recent call last):
File "C:\Users\jpgoncalves\AppData\Local\Programs\Python\Python36\lib\site-packages\grpc\beta_client_adaptations.py", line 131, in _next
return next(self._iterator)
File "C:\Users\jpgoncalves\AppData\Local\Programs\Python\Python36\lib\site-packages\grpc_channel.py", line 364, in next
return self._next()
File "C:\Users\jpgoncalves\AppData\Local\Programs\Python\Python36\lib\site-packages\grpc_channel.py", line 358, in _next
raise self
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.INTERNAL
details = "Exception deserializing response!"
debug_error_string = "None"
hi,
i'm trying to use your telemetry_collector.py and was wondering if you can help me understand how i would put the path inside the script to collect sensor data?
the current sensors that are enabled on my NCS are:
sensor-path Cisco-IOS-XR-shellutil-oper:system-time
sensor-path Cisco-IOS-XR-wdsysmon-fd-oper:system-monitoring/cpu-utilization
sensor-path Cisco-IOS-XR-nto-misc-oper:memory-summary/nodes/node/summary
sensor-path Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/data-rate
sensor-path Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface/latest/generic-counters
sensor-path Cisco-IOS-XR-ipv4-bgp-oper:bgp/instances/instance/instance-active/default-vrf/neighbors/neighbor
Line 13 in 3e99c81
The required version for grpcio
is listed as 1.18.0, can this be updated to either be >= this version or the current version of grpcio
1.33.1? There appears to be an issue with the wheel of 1.18.0, leading to install issues when using pip.
Hi,
I'm trying to use the cliconfig
to load some configuration, e.g.,
>>> driver.cliconfig('ntp server 1.2.3.4')
>>>
To my surprise, this operation did commit the changes on the device. I would have expected to have to explicitly invoke the CommitConfig
directive (by issuing another RPC request) to commit.
That's probably the expected / designed behaviour. So my question is: how can you load some configuration (without committing directly), preview the diff, then issue a separate RPC in order to commit (i.e., commit only if the config diff looks good)?
Cheers,
-Mircea
Hi,
First of all, understand I am learning gRPC to use with our CiscoXR. Therefore if anything I ask seems amateurish, that is why.
I read though the wiki and Readme.
It looks like this repo has two .json files which you use as the structure for sending GRPC commands to adjust BGP.
How does one use other yang modules?
Looking at the yang/cisco repo, there are a variety of modules to use. Would like to use one based on my version (7.2.1).
I tried converting the same .yang module you used to xml then from xml to json, but the structure looks completely different.
How did you create / convert your .json files?
I am trying to connect to an xr device and unfortunately having issues.
options = 'ems.cisco.com'
client = CiscoGRPCClient('x.x.x.x', 57400, 10, 'username', 'password', pem, options)
client.getconfig('{"openconfig-interfaces:interfaces": [null]}')
This is throwing alerts as below, Any idea what might be the issue here. Appreciate your help.
/home/xxxx/ios-xr-grpc-python/iosxr_grpc/cisco_grpc_client.py in getconfig(self, path)
84 responses = self._stub.GetConfig(message, self._timeout, metadata=self._metadata)
85 objects, err = '', ''
---> 86 for response in responses:
87 objects += response.yangjson
88 err += response.errors
/home/xxx/gnmmi/lib/python3.6/site-packages/grpc/beta/_client_adaptations.py in next(self)
134
135 def next(self):
--> 136 return self._next()
137
138 def next(self):
/home/supanick/gnmmi/lib/python3.6/site-packages/grpc/beta/_client_adaptations.py in _next(self)
131 return next(self._iterator)
132 except grpc.RpcError as rpc_error_call:
--> 133 raise _abortion_error(rpc_error_call)
134
135 def next(self):
AbortionError: AbortionError(code=StatusCode.UNAVAILABLE, details="failed to connect to all addresses")
The addresses used in the example is different from the tutorials in xrdocs
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.