Skip to content

Commit 5aa1aab

Browse files
authored
Merge pull request #77 from cisco-ie/revert-76-revert-75-rel-v1.0.12
Release v1.0.13 (Fixed v1.0.12)
2 parents 1b4c0ea + a8f59bf commit 5aa1aab

File tree

6 files changed

+42
-18
lines changed

6 files changed

+42
-18
lines changed

src/cisco_gnmi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@
3030
from .xe import XEClient
3131
from .builder import ClientBuilder
3232

33-
__version__ = "1.0.11"
33+
__version__ = "1.0.13"

src/cisco_gnmi/cli.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,12 @@ def gnmi_subscribe():
113113
default="SAMPLE",
114114
choices=proto.gnmi_pb2.SubscriptionMode.keys(),
115115
)
116+
parser.add_argument(
117+
"-req_mode",
118+
help="SubscriptionList.Mode mode for Subscriptions. Defaults to STREAM.",
119+
default="STREAM",
120+
choices=proto.gnmi_pb2.SubscriptionList.Mode.keys(),
121+
)
116122
parser.add_argument(
117123
"-suppress_redundant",
118124
help="Suppress redundant information in Subscription.",
@@ -159,6 +165,8 @@ def gnmi_subscribe():
159165
kwargs["sample_interval"] = args.interval * int(1e9)
160166
if args.mode:
161167
kwargs["sub_mode"] = args.mode
168+
if args.req_mode:
169+
kwargs["request_mode"] = args.req_mode
162170
if args.suppress_redundant:
163171
kwargs["suppress_redundant"] = args.suppress_redundant
164172
if args.heartbeat_interval:

src/cisco_gnmi/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ def subscribe_xpaths(
277277
sample_interval=_NS_IN_S * 10,
278278
suppress_redundant=False,
279279
heartbeat_interval=None,
280-
prefix=None
280+
prefix=None,
281281
):
282282
"""A convenience wrapper of subscribe() which aids in building of SubscriptionRequest
283283
with request as subscribe SubscriptionList. This method accepts an iterable of simply xpath strings,
@@ -408,7 +408,8 @@ def subscribe_xpaths(
408408
subscription_list.subscription.extend(subscriptions)
409409
return self.subscribe([subscription_list])
410410

411-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
411+
@classmethod
412+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
412413
"""Parses an XPath to proto.gnmi_pb2.Path.
413414
This function should be overridden by any child classes for origin logic.
414415

src/cisco_gnmi/nx.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class NXClient(Client):
5656
>>> capabilities = client.capabilities()
5757
>>> print(capabilities)
5858
"""
59+
5960
def delete_xpaths(self, xpaths, prefix=None):
6061
"""A convenience wrapper for set() which constructs Paths from supplied xpaths
6162
to be passed to set() as the delete parameter.
@@ -90,7 +91,13 @@ def delete_xpaths(self, xpaths, prefix=None):
9091
paths.append(self.parse_xpath_to_gnmi_path(xpath))
9192
return self.set(deletes=paths)
9293

93-
def set_json(self, update_json_configs=None, replace_json_configs=None, ietf=False, prefix=None):
94+
def set_json(
95+
self,
96+
update_json_configs=None,
97+
replace_json_configs=None,
98+
ietf=False,
99+
prefix=None,
100+
):
94101
"""A convenience wrapper for set() which assumes JSON payloads and constructs desired messages.
95102
All parameters are optional, but at least one must be present.
96103
@@ -289,20 +296,25 @@ def subscribe_xpaths(
289296
heartbeat_interval,
290297
)
291298

292-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
299+
@classmethod
300+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
293301
"""Attempts to determine whether origin should be YANG (device) or DME.
294302
"""
295303
if origin is None:
296304
if any(
297-
map(xpath.startswith, [
298-
"Cisco-NX-OS-device",
299-
"/Cisco-NX-OS-device",
300-
"cisco-nx-os-device",
301-
"/cisco-nx-os-device"])
305+
map(
306+
xpath.startswith,
307+
[
308+
"Cisco-NX-OS-device",
309+
"/Cisco-NX-OS-device",
310+
"cisco-nx-os-device",
311+
"/cisco-nx-os-device",
312+
],
313+
)
302314
):
303315
origin = "device"
304316
# Remove the module
305317
xpath = xpath.split(":", 1)[1]
306318
else:
307319
origin = "openconfig"
308-
return super(NXClient, self).parse_xpath_to_gnmi_path(xpath, origin)
320+
return super(NXClient, cls).parse_xpath_to_gnmi_path(xpath, origin)

src/cisco_gnmi/xe.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def subscribe_xpaths(
230230
sample_interval=Client._NS_IN_S * 10,
231231
suppress_redundant=False,
232232
heartbeat_interval=None,
233-
prefix=None
233+
prefix=None,
234234
):
235235
"""A convenience wrapper of subscribe() which aids in building of SubscriptionRequest
236236
with request as subscribe SubscriptionList. This method accepts an iterable of simply xpath strings,
@@ -309,10 +309,11 @@ def subscribe_xpaths(
309309
sample_interval,
310310
suppress_redundant,
311311
heartbeat_interval,
312-
prefix
312+
prefix,
313313
)
314314

315-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
315+
@classmethod
316+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
316317
"""Naively tries to intelligently (non-sequitur!) origin
317318
Otherwise assume rfc7951
318319
legacy is not considered
@@ -323,4 +324,4 @@ def parse_xpath_to_gnmi_path(self, xpath, origin=None):
323324
origin = "openconfig"
324325
else:
325326
origin = "rfc7951"
326-
return super(XEClient, self).parse_xpath_to_gnmi_path(xpath, origin)
327+
return super(XEClient, cls).parse_xpath_to_gnmi_path(xpath, origin)

src/cisco_gnmi/xr.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,8 @@ def subscribe_xpaths(
338338
heartbeat_interval,
339339
)
340340

341-
def parse_xpath_to_gnmi_path(self, xpath, origin=None):
341+
@classmethod
342+
def parse_xpath_to_gnmi_path(cls, xpath, origin=None):
342343
"""No origin specified implies openconfig
343344
Otherwise origin is expected to be the module name
344345
"""
@@ -351,9 +352,10 @@ def parse_xpath_to_gnmi_path(self, xpath, origin=None):
351352
# module name
352353
origin, xpath = xpath.split(":", 1)
353354
origin = origin.strip("/")
354-
return super(XRClient, self).parse_xpath_to_gnmi_path(xpath, origin)
355+
return super(XRClient, cls).parse_xpath_to_gnmi_path(xpath, origin)
355356

356-
def parse_cli_to_gnmi_path(self, command):
357+
@classmethod
358+
def parse_cli_to_gnmi_path(cls, command):
357359
"""Parses a CLI command to proto.gnmi_pb2.Path.
358360
IOS XR appears to be the only OS with this functionality.
359361

0 commit comments

Comments
 (0)