Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove idle ShellError exception and get_exception() method from nxos modules #24091

Merged
merged 1 commit into from
Apr 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_bgp_af.py
Original file line number Diff line number Diff line change
Expand Up @@ -946,13 +946,9 @@ def main():
if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3)
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:
result['updates'] = []

Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_bgp_neighbor.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,13 +605,9 @@ def main():
if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3)
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:
result['updates'] = []

Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_bgp_neighbor_af.py
Original file line number Diff line number Diff line change
Expand Up @@ -958,13 +958,9 @@ def main():
if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3)
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:
result['updates'] = []

Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_evpn_vni.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,12 +268,8 @@ def state_absent(module, existing, proposed):

def execute_config(module, candidate):
result = {}
try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
response = load_config(module, candidate)
result.update(response)
return result


Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_file_copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,12 +232,8 @@ def main():
file_exists = True

if not module.check_mode and not file_exists:
try:
transfer_file(module, dest)
transfer_status = 'Sent'
except ShellError:
clie = get_exception()
module.fail_json(msg=str(clie))
transfer_file(module, dest)
transfer_status = 'Sent'

if remote_file is None:
remote_file = os.path.basename(local_file)
Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_igmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,13 +233,9 @@ def main():
True in existing.values()) or restart):
candidate = CustomNetworkConfig(indent=3)
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:
result['updates'] = []

Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_interface_ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,13 +519,9 @@ def main():

candidate = CustomNetworkConfig(indent=3)
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:
result['updates'] = []

Expand Down
6 changes: 1 addition & 5 deletions lib/ansible/modules/network/nxos/nxos_ntp_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,11 +335,7 @@ def main():
if module.check_mode:
module.exit_json(changed=True, commands=cmds)
else:
try:
load_config(module, cmds)
except ShellError:
clie = get_exception()
module.fail_json(msg=str(clie) + ": " + cmds)
load_config(module, cmds)
end_state = get_ntp_auth_info(key_id, module)
delta = dict(set(end_state.items()).difference(existing.items()))
if delta or (len(existing) != len(end_state)):
Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_ospf.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,9 @@ def main():
if (state == 'present' or (state == 'absent' and ospf in existing_list)):
candidate = CustomNetworkConfig(indent=3)
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:
result['updates'] = []

Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_ospf_vrf.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,13 +434,9 @@ def main():
if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3)
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:
result['updates'] = []

Expand Down
9 changes: 2 additions & 7 deletions lib/ansible/modules/network/nxos/nxos_pim.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,8 @@ def main():
result = {}
candidate = CustomNetworkConfig(indent=3)
invoke('get_commands', module, existing, proposed, candidate)

try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
response = load_config(module, candidate)
result.update(response)

if module._verbosity > 0:
end_state = invoke('get_existing', module, args)
Expand Down
9 changes: 2 additions & 7 deletions lib/ansible/modules/network/nxos/nxos_pim_rp_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,13 +253,8 @@ def main():
result = {}
candidate = CustomNetworkConfig(indent=3)
invoke('state_%s' % state, module, existing, proposed, candidate)

try:
response = load_config(module, candidate)
result.update(response)
except ShellError:
exc = get_exception()
module.fail_json(msg=str(exc))
response = load_config(module, candidate)
result.update(response)

if module._verbosity > 0:
end_state = invoke('get_existing', module, args)
Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_smu.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,8 @@ def main():

commands = get_commands(module, pkg, file_system)
if not module.check_mode and commands:
try:
apply_patch(module, commands)
changed = True
except ShellError:
e = get_exception()
module.fail_json(msg=str(e))
apply_patch(module, commands)
changed = True

if 'configure' in commands:
commands.pop(0)
Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_vrf_af.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,9 @@ def main():
if state == 'present' or (state == 'absent' and existing):
candidate = CustomNetworkConfig(indent=3)
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:
result['updates'] = []

Expand Down
8 changes: 2 additions & 6 deletions lib/ansible/modules/network/nxos/nxos_vxlan_vtep.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,9 @@ def main():
"all logical interfaces.")
candidate = CustomNetworkConfig(indent=3)
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:
result['updates'] = []

Expand Down