nxos_install_os: Fix nxapi local failures (#55993)

* Fix nxapi failures

* Remove logit debug calls

* Remove msg_timestamps

* Fix code alignment issue
This commit is contained in:
Mike Wiebe 2019-06-06 00:05:08 -04:00 committed by Trishna Guha
parent 1dc3fe5317
commit 7c73dd3e78
10 changed files with 115 additions and 24 deletions

View file

@ -429,6 +429,12 @@ class LocalNxapi:
def load_config(self, commands, return_error=False, opts=None, replace=None):
"""Sends the ordered set of commands to the device
"""
if opts is None:
opts = {}
responses = []
if replace:
device_info = self.get_device_info()
if '9K' not in device_info.get('network_os_platform', ''):
@ -436,12 +442,30 @@ class LocalNxapi:
commands = 'config replace {0}'.format(replace)
commands = to_list(commands)
msg = self.send_request(commands, output='config', check_status=True,
return_error=return_error, opts=opts)
try:
resp = self.send_request(commands, output='config', check_status=True,
return_error=return_error, opts=opts)
except ValueError as exc:
code = getattr(exc, 'code', 1)
message = getattr(exc, 'err', exc)
err = to_text(message, errors='surrogate_then_replace')
if opts.get('ignore_timeout') and code:
responses.append(code)
return responses
elif code and 'no graceful-restart' in err:
if 'ISSU/HA will be affected if Graceful Restart is disabled' in err:
msg = ['']
responses.extend(msg)
return responses
else:
self._module.fail_json(msg=err)
elif code:
self._module.fail_json(msg=err)
if return_error:
return msg
return resp
else:
return []
return responses.extend(resp)
def get_diff(self, candidate=None, running=None, diff_match='line', diff_ignore_lines=None, path=None, diff_replace='line'):
diff = {}