@@ -342,3 +342,42 @@ def parse_xpath_to_gnmi_path(self, xpath, origin=None):
342
342
# module name
343
343
origin , xpath = xpath .split (":" , 1 )
344
344
return super (XRClient , self ).parse_xpath_to_gnmi_path (xpath , origin )
345
+
346
+ def get_cli_commands (self , cli_commands ):
347
+ """A convenience wrapper for get() which forms proto.gnmi_pb2.Path from supplied CLI commands.
348
+
349
+ Parameters
350
+ ----------
351
+ cli_commands : iterable of str or str
352
+ An iterable of CLI commands as strings to request data of
353
+ If simply a str, wraps as a list for convenience
354
+
355
+ Returns
356
+ -------
357
+ get()
358
+ """
359
+ gnmi_path = None
360
+ if isinstance (cli_commands , (list , set )):
361
+ gnmi_path = map (self .parse_cli_command_to_gnmi_path , set (cli_commands ))
362
+ elif isinstance (cli_commands , string_types ):
363
+ gnmi_path = [self .parse_cli_command_to_gnmi_path (cli_commands )]
364
+ else :
365
+ raise Exception (
366
+ "cli_commands must be a single CLI command string or iterable of CLI commands as strings!"
367
+ )
368
+ return self .get (gnmi_path , encoding = 'ASCII' )
369
+
370
+ def parse_cli_command_to_gnmi_path (self , cli_command ):
371
+ """A convenience wrapper for parse_cli_command_to_gnmi_path() that creates the proto.gnmi_pb2.Path for the
372
+ supplied CLI command.
373
+
374
+ Parameters
375
+ ----------
376
+ cli_command : str
377
+ A CLI command as str
378
+
379
+ Returns
380
+ -------
381
+ parse_cli_command_to_gnmi_path()
382
+ """
383
+ return super (XRClient , self ).parse_cli_command_to_gnmi_path (cli_command )
0 commit comments