|
31 | 31 | from six import string_types
|
32 | 32 | from .client import Client, proto, util
|
33 | 33 |
|
| 34 | +logger = logging.getLogger(__name__) |
| 35 | + |
34 | 36 |
|
35 | 37 | class NXClient(Client):
|
36 | 38 | """NX-OS-specific wrapper for gNMI functionality.
|
@@ -167,14 +169,14 @@ def delete_xpaths(self, xpaths, prefix=None):
|
167 | 169 |
|
168 | 170 | def check_configs(self, configs):
|
169 | 171 | if isinstance(configs, string_types):
|
170 |
| - logging.debug("Handling as JSON string.") |
| 172 | + logger.debug("Handling as JSON string.") |
171 | 173 | try:
|
172 | 174 | configs = json.loads(configs)
|
173 | 175 | except:
|
174 | 176 | raise Exception("{0}\n is invalid JSON!".format(configs))
|
175 | 177 | configs = [configs]
|
176 | 178 | elif isinstance(configs, dict):
|
177 |
| - logging.debug("Handling already serialized JSON object.") |
| 179 | + logger.debug("Handling already serialized JSON object.") |
178 | 180 | configs = [configs]
|
179 | 181 | elif not isinstance(configs, (list, set)):
|
180 | 182 | raise Exception(
|
@@ -206,7 +208,6 @@ def create_updates(self, configs, origin):
|
206 | 208 | )
|
207 | 209 | update.val.json_val = payload
|
208 | 210 | updates.append(update)
|
209 |
| - logging.info('GNMI set:\n\n{0}'.format(str(update))) |
210 | 211 | return updates
|
211 | 212 | else:
|
212 | 213 | for config in configs:
|
@@ -245,6 +246,8 @@ def set_json(self, update_json_configs=None, replace_json_configs=None,
|
245 | 246 | raise Exception("Must supply at least one set of configurations to method!")
|
246 | 247 |
|
247 | 248 | updates = self.create_updates(update_json_configs, origin=origin)
|
| 249 | + for update in updates: |
| 250 | + logger.info('\nGNMI set:\n{0}\n{1}'.format(9 * '=', str(update))) |
248 | 251 | replaces = self.create_updates(replace_json_configs, origin=origin)
|
249 | 252 | return self.set(updates=updates, replaces=replaces)
|
250 | 253 |
|
@@ -287,6 +290,7 @@ def get_xpaths(self, xpaths, data_type="ALL",
|
287 | 290 | raise Exception(
|
288 | 291 | "xpaths must be a single xpath string or iterable of xpath strings!"
|
289 | 292 | )
|
| 293 | + logger.info('GNMI get:\n{0}\n{1}'.format(9 * '=', str(gnmi_path))) |
290 | 294 | return self.get(gnmi_path, data_type=data_type, encoding=encoding)
|
291 | 295 |
|
292 | 296 | def subscribe_xpaths(
|
@@ -399,6 +403,9 @@ def subscribe_xpaths(
|
399 | 403 | raise Exception("xpath in list must be xpath or dict/Path!")
|
400 | 404 | subscriptions.append(subscription)
|
401 | 405 | subscription_list.subscription.extend(subscriptions)
|
| 406 | + logger.info('GNMI subscribe:\n{0}\n{1}'.format( |
| 407 | + 15 * '=', str(subscription_list)) |
| 408 | + ) |
402 | 409 | return self.subscribe([subscription_list])
|
403 | 410 |
|
404 | 411 | def parse_xpath_to_gnmi_path(self, xpath, origin):
|
|
0 commit comments