3030from .client import Client , proto , util
3131
3232
33+ LOGGER = logging .getLogger (__name__ )
34+ logger = LOGGER
35+
36+
3337class XEClient (Client ):
3438 """IOS XE-specific wrapper for gNMI functionality.
3539 Assumes IOS XE 16.12+
@@ -108,7 +112,13 @@ def delete_xpaths(self, xpaths, prefix=None):
108112 paths .append (self .parse_xpath_to_gnmi_path (xpath ))
109113 return self .set (deletes = paths )
110114
111- def set_json (self , update_json_configs = None , replace_json_configs = None , ietf = True ):
115+ def set_json (
116+ self ,
117+ update_json_configs = None ,
118+ replace_json_configs = None ,
119+ ietf = True ,
120+ prefix = None ,
121+ ):
112122 """A convenience wrapper for set() which assumes JSON payloads and constructs desired messages.
113123 All parameters are optional, but at least one must be present.
114124
@@ -132,15 +142,15 @@ def set_json(self, update_json_configs=None, replace_json_configs=None, ietf=Tru
132142 raise Exception ("Must supply at least one set of configurations to method!" )
133143
134144 def check_configs (name , configs ):
135- if isinstance (name , string_types ):
136- logging .debug ("Handling %s as JSON string." , name )
145+ if isinstance (configs , string_types ):
146+ LOGGER .debug ("Handling %s as JSON string." , name )
137147 try :
138148 configs = json .loads (configs )
139149 except :
140150 raise Exception ("{name} is invalid JSON!" .format (name = name ))
141151 configs = [configs ]
142- elif isinstance (name , dict ):
143- logging .debug ("Handling %s as already serialized JSON object." , name )
152+ elif isinstance (configs , dict ):
153+ LOGGER .debug ("Handling %s as already serialized JSON object." , name )
144154 configs = [configs ]
145155 elif not isinstance (configs , (list , set )):
146156 raise Exception (
@@ -171,7 +181,7 @@ def create_updates(name, configs):
171181
172182 updates = create_updates ("update_json_configs" , update_json_configs )
173183 replaces = create_updates ("replace_json_configs" , replace_json_configs )
174- return self .set (updates = updates , replaces = replaces )
184+ return self .set (prefix = prefix , updates = updates , replaces = replaces )
175185
176186 def get_xpaths (self , xpaths , data_type = "ALL" , encoding = "JSON_IETF" ):
177187 """A convenience wrapper for get() which forms proto.gnmi_pb2.Path from supplied xpaths.
0 commit comments