Fixes #23890 Remove idle ShellError exception and get_exception() method from nxos modules (#23947)

Remove idle ShellError exception and get_exception() method from nxos modules
This commit is contained in:
Trishna Guha 2017-04-28 10:42:15 +05:30 committed by GitHub
parent a13d89da68
commit bc22223d63
15 changed files with 29 additions and 91 deletions

View file

@ -946,13 +946,9 @@ def main():
if state == 'present' or (state == 'absent' and existing): if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, existing, proposed, candidate) invoke('state_%s' % state, module, existing, proposed, candidate)
response = load_config(module, candidate)
result.update(response)
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
else: else:
result['updates'] = [] result['updates'] = []

View file

@ -605,13 +605,9 @@ def main():
if state == 'present' or (state == 'absent' and existing): if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, existing, proposed, candidate) invoke('state_%s' % state, module, existing, proposed, candidate)
response = load_config(module, candidate)
result.update(response)
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
else: else:
result['updates'] = [] result['updates'] = []

View file

@ -958,13 +958,9 @@ def main():
if state == 'present' or (state == 'absent' and existing): if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, existing, proposed, candidate) invoke('state_%s' % state, module, existing, proposed, candidate)
response = load_config(module, candidate)
result.update(response)
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
else: else:
result['updates'] = [] result['updates'] = []

View file

@ -268,12 +268,8 @@ def state_absent(module, existing, proposed):
def execute_config(module, candidate): def execute_config(module, candidate):
result = {} result = {}
try: response = load_config(module, candidate)
response = load_config(module, candidate) result.update(response)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
return result return result

View file

@ -232,12 +232,8 @@ def main():
file_exists = True file_exists = True
if not module.check_mode and not file_exists: if not module.check_mode and not file_exists:
try: transfer_file(module, dest)
transfer_file(module, dest) transfer_status = 'Sent'
transfer_status = 'Sent'
except ShellError:
clie = get_exception()
module.fail_json(msg=str(clie))
if remote_file is None: if remote_file is None:
remote_file = os.path.basename(local_file) remote_file = os.path.basename(local_file)

View file

@ -233,13 +233,9 @@ def main():
True in existing.values()) or restart): True in existing.values()) or restart):
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('get_commands', module, existing, proposed_args, candidate) invoke('get_commands', module, existing, proposed_args, candidate)
response = load_config(module, candidate)
result.update(response)
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
else: else:
result['updates'] = [] result['updates'] = []

View file

@ -519,13 +519,9 @@ def main():
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, existing, proposed, candidate) invoke('state_%s' % state, module, existing, proposed, candidate)
response = load_config(module, candidate)
result.update(response)
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
else: else:
result['updates'] = [] result['updates'] = []

View file

@ -335,11 +335,7 @@ def main():
if module.check_mode: if module.check_mode:
module.exit_json(changed=True, commands=cmds) module.exit_json(changed=True, commands=cmds)
else: else:
try: load_config(module, cmds)
load_config(module, cmds)
except ShellError:
clie = get_exception()
module.fail_json(msg=str(clie) + ": " + cmds)
end_state = get_ntp_auth_info(key_id, module) end_state = get_ntp_auth_info(key_id, module)
delta = dict(set(end_state.items()).difference(existing.items())) delta = dict(set(end_state.items()).difference(existing.items()))
if delta or (len(existing) != len(end_state)): if delta or (len(existing) != len(end_state)):

View file

@ -188,13 +188,9 @@ def main():
if (state == 'present' or (state == 'absent' and ospf in existing_list)): if (state == 'present' or (state == 'absent' and ospf in existing_list)):
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, proposed, candidate) invoke('state_%s' % state, module, proposed, candidate)
response = load_config(module, candidate)
result.update(response)
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
else: else:
result['updates'] = [] result['updates'] = []

View file

@ -434,13 +434,9 @@ def main():
if state == 'present' or (state == 'absent' and existing): if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, existing, proposed, candidate) invoke('state_%s' % state, module, existing, proposed, candidate)
response = load_config(module, candidate)
result.update(response)
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
else: else:
result['updates'] = [] result['updates'] = []

View file

@ -173,13 +173,8 @@ def main():
result = {} result = {}
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('get_commands', module, existing, proposed, candidate) invoke('get_commands', module, existing, proposed, candidate)
response = load_config(module, candidate)
try: result.update(response)
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
if module._verbosity > 0: if module._verbosity > 0:
end_state = invoke('get_existing', module, args) end_state = invoke('get_existing', module, args)

View file

@ -253,13 +253,8 @@ def main():
result = {} result = {}
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, existing, proposed, candidate) invoke('state_%s' % state, module, existing, proposed, candidate)
response = load_config(module, candidate)
try: result.update(response)
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
if module._verbosity > 0: if module._verbosity > 0:
end_state = invoke('get_existing', module, args) end_state = invoke('get_existing', module, args)

View file

@ -174,12 +174,8 @@ def main():
commands = get_commands(module, pkg, file_system) commands = get_commands(module, pkg, file_system)
if not module.check_mode and commands: if not module.check_mode and commands:
try: apply_patch(module, commands)
apply_patch(module, commands) changed = True
changed = True
except ShellError:
e = get_exception()
module.fail_json(msg=str(e))
if 'configure' in commands: if 'configure' in commands:
commands.pop(0) commands.pop(0)

View file

@ -270,13 +270,9 @@ def main():
if state == 'present' or (state == 'absent' and existing): if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, existing, proposed, candidate) invoke('state_%s' % state, module, existing, proposed, candidate)
response = load_config(module, candidate)
result.update(response)
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
else: else:
result['updates'] = [] result['updates'] = []

View file

@ -363,13 +363,9 @@ def main():
"all logical interfaces.") "all logical interfaces.")
candidate = CustomNetworkConfig(indent=3) candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, existing, proposed, candidate) invoke('state_%s' % state, module, existing, proposed, candidate)
response = load_config(module, candidate)
result.update(response)
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
else: else:
result['updates'] = [] result['updates'] = []