Module Name: juniper.device.rpc
When using juniper.device.rpc with connection: juniper.device.pyez, if the RPC raises a RpcTimeoutError, the module crashes with UnboundLocalError: cannot access local variable 'resp' where it is not associated with a value instead of a meaningful error message.
Environment
- juniper.device version: 2.0.0
- Ansible core: 2.18.x
- Connection: juniper.device.pyez
- PyEZ version: 2.7.6
- Python: 3.11
Steps to reproduce
Run get-checksum-information on a large file (e.g. a 1.5GB vmhost .tgz) from an environment where persistent_command_timeout is lower than the time required to compute the MD5 checksum on the device:
- name: Generate checksum for file on device
juniper.device.rpc:
rpcs:
- "get-checksum-information"
format: xml
kwargs:
- path: "/var/tmp/junos-vmhost-install-mx-x86-64-23.4R2-S4.11.tgz"
timeout: 120
connection: juniper.device.pyez
UnboundLocalError: cannot access local variable 'resp' where
Expected behavior
The task should fail with a clear RpcTimeoutError message, not crash with UnboundLocalError.
Maybe the fault is around this code lines?
except Exception as ex:
if "RpcError" in (str(ex)):
raise junos_module.pyez_exception.RpcError
if "ConnectError" in (str(ex)):
raise junos_module.pyez_exception.ConnectError
# any other exception is silently swallowed here
Module Name: juniper.device.rpc
When using juniper.device.rpc with connection: juniper.device.pyez, if the RPC raises a RpcTimeoutError, the module crashes with UnboundLocalError: cannot access local variable 'resp' where it is not associated with a value instead of a meaningful error message.
Environment
Steps to reproduce
Run get-checksum-information on a large file (e.g. a 1.5GB vmhost .tgz) from an environment where persistent_command_timeout is lower than the time required to compute the MD5 checksum on the device:
Expected behavior
The task should fail with a clear RpcTimeoutError message, not crash with UnboundLocalError.
Maybe the fault is around this code lines?