From 060ed665f60959722522183008ccf4db689652e3 Mon Sep 17 00:00:00 2001 From: Nathaniel Case Date: Mon, 12 Sep 2016 14:20:50 -0400 Subject: [PATCH] Cleanup nxos closes #17414 --- lib/ansible/module_utils/nxos.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/ansible/module_utils/nxos.py b/lib/ansible/module_utils/nxos.py index 1680a825dfd..7ba30183174 100644 --- a/lib/ansible/module_utils/nxos.py +++ b/lib/ansible/module_utils/nxos.py @@ -21,7 +21,7 @@ import re import time import collections -from ansible.module_utils.basic import json +from ansible.module_utils.basic import json, json_dict_bytes_to_unicode from ansible.module_utils.network import ModuleStub, NetworkError, NetworkModule from ansible.module_utils.network import add_argument, register_transport, to_list from ansible.module_utils.shell import CliBase @@ -145,14 +145,14 @@ class Nxapi(NxapiConfigMixin): while commands: stack.append(commands.popleft()) if len(stack) == 10: - data = self._get_body(stack, output) - data = self._jsonify(data) + body = self._get_body(stack, output) + data = self._jsonify(body) requests.append(data) stack = list() if stack: - data = self._get_body(stack, output) - data = self._jsonify(data) + body = self._get_body(stack, output) + data = self._jsonify(body) requests.append(data) headers = {'Content-Type': 'application/json'} @@ -279,12 +279,14 @@ class Cli(NxapiConfigMixin, CliBase): Cli = register_transport('cli', default=True)(Cli) + def prepare_config(commands): prepared = ['config'] prepared.extend(to_list(commands)) prepared.append('end') return prepared + def prepare_commands(commands): jsonify = lambda x: '%s | json' % x for cmd in to_list(commands):