30
30
from .client import Client , proto , util
31
31
32
32
33
+ logger = logging .getLogger (__name__ )
34
+
35
+
33
36
class XEClient (Client ):
34
37
"""IOS XE-specific wrapper for gNMI functionality.
35
38
Assumes IOS XE 16.12+
@@ -108,7 +111,7 @@ def delete_xpaths(self, xpaths, prefix=None):
108
111
paths .append (self .parse_xpath_to_gnmi_path (xpath ))
109
112
return self .set (deletes = paths )
110
113
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 ):
112
115
"""A convenience wrapper for set() which assumes JSON payloads and constructs desired messages.
113
116
All parameters are optional, but at least one must be present.
114
117
@@ -132,15 +135,15 @@ def set_json(self, update_json_configs=None, replace_json_configs=None, ietf=Tru
132
135
raise Exception ("Must supply at least one set of configurations to method!" )
133
136
134
137
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 )
137
140
try :
138
141
configs = json .loads (configs )
139
142
except :
140
143
raise Exception ("{name} is invalid JSON!" .format (name = name ))
141
144
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 )
144
147
configs = [configs ]
145
148
elif not isinstance (configs , (list , set )):
146
149
raise Exception (
@@ -171,7 +174,7 @@ def create_updates(name, configs):
171
174
172
175
updates = create_updates ("update_json_configs" , update_json_configs )
173
176
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 )
175
178
176
179
def get_xpaths (self , xpaths , data_type = "ALL" , encoding = "JSON_IETF" ):
177
180
"""A convenience wrapper for get() which forms proto.gnmi_pb2.Path from supplied xpaths.
0 commit comments