-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Labels
Description
When trying to filter in some xpath for a "get" in IOS-XR... for instance:
'Cisco-IOS-XR-infra-statsd-oper:infra-statistics/interfaces/interface[interface-name="MgmtEth0/RP0/CPU0/0"]/generic-counters'
This will create a grpc path:
elem {
name: "infra-statistics"
}
elem {
name: "interfaces"
}
elem {
name: "interface"
key {
key: "interface-name"
value: "MgmtEth0/RP0/CPU0/0"
}
}
elem {
name: "generic-counters"
}
But this will fail due to CSCvk26949 as IOS-XR expects key values to be inserted in double quotes like this:
elem {
name: "infra-statistics"
}
elem {
name: "interfaces"
}
elem {
name: "interface"
key {
key: "interface-name"
value: "\"MgmtEth0/RP0/CPU0/0\""
}
}
elem {
name: "generic-counters"
}
The returned error message will mention something like 'lexical error: invalid char in json text.'.
These diffs seem to make it work for me:
diff --git a/src/cisco_gnmi/xr.py b/src/cisco_gnmi/xr.py
index c55d6e4..50f4240 100644
--- a/src/cisco_gnmi/xr.py
+++ b/src/cisco_gnmi/xr.py
@@ -352,7 +352,13 @@ class XRClient(Client):
# module name
origin, xpath = xpath.split(":", 1)
origin = origin.strip("/")
- return super(XRClient, cls).parse_xpath_to_gnmi_path(xpath, origin)
+ path = super(XRClient, cls).parse_xpath_to_gnmi_path(xpath, origin)
+ # Need to have double quotes around key value in IOS-XR (CSCvk26949)
+ for elem in path.elem:
+ if elem.key:
+ for key in list(elem.key.keys()):
+ elem.key[key] = '"{}"'.format(elem.key[key])
+ return path
@classmethod
def parse_cli_to_gnmi_path(cls, command):