Skip to content

Commit

Permalink
handling ansible.module_utils.connection.ConnectionError (#662)
Browse files Browse the repository at this point in the history
  • Loading branch information
chidanandpujar committed May 14, 2024
1 parent 6073106 commit 0b6195e
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion ansible_collections/juniper/device/plugins/modules/software.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,19 @@ def main():
junos_module.logger.debug("Install parameters are: %s",
str(install_params))
if junos_module.conn_type != "local":
results['msg'] = junos_module._pyez_conn.software_api(install_params)
try:
results['msg'] = junos_module._pyez_conn.software_api(install_params)
except Exception as err: # pylint: disable=broad-except
if "ConnectionError" in str(type(err)):
# If Exception is ConnectionError, it is excpected
# Device installation inititated succesfully
junos_module.logger.debug("Package successfully installed.")
results['msg'] += 'Package successfully installed.'
else:
# If exception is not ConnectionError
# we will raise the exception
raise
junos_module.logger.debug("Package successfully installed")
else:
try:
junos_module.add_sw()
Expand Down

0 comments on commit 0b6195e

Please sign in to comment.