|
|
|
|
@ -50,7 +50,7 @@ nxos_argument_spec = {
|
|
|
|
|
'validate_certs': dict(type='bool'),
|
|
|
|
|
'timeout': dict(type='int'),
|
|
|
|
|
|
|
|
|
|
'provider': dict(type='dict', no_log=True),
|
|
|
|
|
'provider': dict(type='dict'),
|
|
|
|
|
'transport': dict(choices=['cli', 'nxapi'])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -212,7 +212,7 @@ class Nxapi:
|
|
|
|
|
# only 10 show commands can be encoded in each request
|
|
|
|
|
# messages sent to the remote device
|
|
|
|
|
if output != 'config':
|
|
|
|
|
commands = collections.deque(commands)
|
|
|
|
|
commands = collections.deque(to_list(commands))
|
|
|
|
|
stack = list()
|
|
|
|
|
requests = list()
|
|
|
|
|
|
|
|
|
|
@ -230,7 +230,8 @@ class Nxapi:
|
|
|
|
|
requests.append(data)
|
|
|
|
|
|
|
|
|
|
else:
|
|
|
|
|
requests = commands
|
|
|
|
|
body = self._request_builder(commands, 'config')
|
|
|
|
|
requests = [self._module.jsonify(body)]
|
|
|
|
|
|
|
|
|
|
headers = {'Content-Type': 'application/json'}
|
|
|
|
|
result = list()
|
|
|
|
|
@ -241,7 +242,7 @@ class Nxapi:
|
|
|
|
|
headers['Cookie'] = self._nxapi_auth
|
|
|
|
|
|
|
|
|
|
response, headers = fetch_url(
|
|
|
|
|
self._module, self._url, data=data, headers=headers,
|
|
|
|
|
self._module, self._url, data=req, headers=headers,
|
|
|
|
|
timeout=timeout, method='POST'
|
|
|
|
|
)
|
|
|
|
|
self._nxapi_auth = headers.get('set-cookie')
|
|
|
|
|
@ -275,7 +276,7 @@ class Nxapi:
|
|
|
|
|
return self._device_configs[cmd]
|
|
|
|
|
except KeyError:
|
|
|
|
|
out = self.send_request(cmd)
|
|
|
|
|
cfg = str(out['result'][0]['output']).strip()
|
|
|
|
|
cfg = str(out[0]).strip()
|
|
|
|
|
self._device_configs[cmd] = cfg
|
|
|
|
|
return cfg
|
|
|
|
|
|
|
|
|
|
@ -309,8 +310,7 @@ class Nxapi:
|
|
|
|
|
def load_config(self, commands):
|
|
|
|
|
"""Sends the ordered set of commands to the device
|
|
|
|
|
"""
|
|
|
|
|
cmds = ['configure terminal']
|
|
|
|
|
cmds.extend(commands)
|
|
|
|
|
commands = to_list(commands)
|
|
|
|
|
self.send_request(commands, output='config')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|