cisco-ie / cisco-gnmi-python

CLI and library wrapping gNMI functionality to ease usage with Cisco implementations in Python programs.
https://pypi.org/project/cisco-gnmi/
Apache License 2.0
40 stars 18 forks source link

Need mechanism to update/replace based on xpath #81

Open mahen-g opened 4 years ago

mahen-g commented 4 years ago

Current way of doing the update/replace operation requires user to provide the payload in the json format. While this seems ok for update operation, for replace operation user would have to provide the entire payload, though that is not being replaced.

For example, if user needs to replace an ip address on an interface on NX-OS, and if if the box had 48 interfaces, the user would have to create the payload which would include all the interfaces on the device with their corresponding info, even though the intent is to replace ip address for only interface.

Providing a mechanism to replace based on xpath would help resolve this. something of the below format --xpath_update /interfaces/interface[name=eth1/47]/@ip.json

On NX-OS, if we do not provide the entire payload, we would hit the below error. I believe, it could be the same for other platforms too.

File "/ws/mgangaia-sjc/pyats-latest/lib/python3.6/site-packages/cisco_gnmi/nx.py", line 194, in set_json return self.set(prefix=prefix, updates=updates, replaces=replaces) File "/ws/mgangaia-sjc/pyats-latest/lib/python3.6/site-packages/cisco_gnmi/client.py", line 223, in set response = self.service.Set(request, metadata=self.default_call_metadata) File "/ws/mgangaia-sjc/pyats-latest/lib/python3.6/site-packages/grpc/_channel.py", line 549, in call return _end_unary_response_blocking(state, call, False, None) File "/ws/mgangaia-sjc/pyats-latest/lib/python3.6/site-packages/grpc/_channel.py", line 466, in _end_unary_response_blocking raise _Rendezvous(state, None, None, deadline) grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with: status = StatusCode.INTERNAL details = "descr:internal processing error [error:operation-failed msg:Cannot delete object of class:l1PhysIf path:/config/interfaces][error:operation-failed msg:Cannot delete object of class:l1PhysIf Commit Failed path:/config/interfaces]" debug_error_string = "{"created":"@1595898351.637576743","description":"Error received from peer","file":"src/core/lib/surface/call.cc","file_line":1039,"grpc_message":"descr:internal processing error [error:operation-failed msg:Cannot delete object of class:l1PhysIf path:/config/interfaces][error:operation-failed msg:Cannot delete object of class:l1PhysIf Commit Failed path:/config/interfaces]","grpc_status":13}"

Thanks, Mahendra

remingtonc commented 4 years ago

Related to #27