3030from .client import Client , proto , util
3131
3232
33+ logger = logging .getLogger (__name__ )
34+
35+
3336class XEClient (Client ):
3437 """IOS XE-specific wrapper for gNMI functionality.
3538 Assumes IOS XE 16.12+
@@ -108,7 +111,7 @@ def delete_xpaths(self, xpaths, prefix=None):
108111 paths .append (self .parse_xpath_to_gnmi_path (xpath ))
109112 return self .set (deletes = paths )
110113
111- def set_json (self , update_json_configs = None , replace_json_configs = None , ietf = True ):
114+ def set_json (self , update_json_configs = None , replace_json_configs = None , ietf = True , prefix = None ):
112115 """A convenience wrapper for set() which assumes JSON payloads and constructs desired messages.
113116 All parameters are optional, but at least one must be present.
114117
@@ -132,15 +135,15 @@ def set_json(self, update_json_configs=None, replace_json_configs=None, ietf=Tru
132135 raise Exception ("Must supply at least one set of configurations to method!" )
133136
134137 def check_configs (name , configs ):
135- if isinstance (name , string_types ):
136- logging .debug ("Handling %s as JSON string." , name )
138+ if isinstance (configs , string_types ):
139+ logger .debug ("Handling %s as JSON string." , name )
137140 try :
138141 configs = json .loads (configs )
139142 except :
140143 raise Exception ("{name} is invalid JSON!" .format (name = name ))
141144 configs = [configs ]
142- elif isinstance (name , dict ):
143- logging .debug ("Handling %s as already serialized JSON object." , name )
145+ elif isinstance (configs , dict ):
146+ logger .debug ("Handling %s as already serialized JSON object." , name )
144147 configs = [configs ]
145148 elif not isinstance (configs , (list , set )):
146149 raise Exception (
@@ -171,7 +174,7 @@ def create_updates(name, configs):
171174
172175 updates = create_updates ("update_json_configs" , update_json_configs )
173176 replaces = create_updates ("replace_json_configs" , replace_json_configs )
174- return self .set (updates = updates , replaces = replaces )
177+ return self .set (prefix = prefix , updates = updates , replaces = replaces )
175178
176179 def get_xpaths (self , xpaths , data_type = "ALL" , encoding = "JSON_IETF" ):
177180 """A convenience wrapper for get() which forms proto.gnmi_pb2.Path from supplied xpaths.
0 commit comments