Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ansible_collections/juniper/device/plugins/connection/pyez.py
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ def commit_configuration(self, ignore_warning=None, comment=None,
raise AnsibleError('Failure committing the configuraton: %s' %
(str(ex)))

def system_api(self, action, in_min, at, all_re, vmhost, other_re, media, member_id):
def system_api(self, action, in_min, at, all_re, vmhost, other_re, media, member_id=None):
"""Triggers the system calls like reboot, shutdown, halt and zeroize to device.
"""
msg = None
Expand Down Expand Up @@ -845,7 +845,7 @@ def software_api(self, install_params):
self.pyez_exception.RpcError) as ex:
raise AnsibleError('Installation failed. Error: %s' % str(ex))

def reboot_api(self, all_re, vmhost, member_id):
def reboot_api(self, all_re, vmhost, member_id=None):
"""reboots the device.
"""
msg = None
Expand Down
30 changes: 23 additions & 7 deletions ansible_collections/juniper/device/plugins/modules/software.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,11 +726,23 @@ def main():
if reboot is True:
junos_module.logger.debug('Initiating reboot.')
if junos_module.conn_type != "local":
if member_id is not None:
for m_id in member_id:
results['msg'] += junos_module._pyez_conn.reboot_api(all_re, install_params.get('vmhost'), member_id=m_id)
else:
results['msg'] += junos_module._pyez_conn.reboot_api(all_re, install_params.get('vmhost'))
try:
#Handling reboot of specific VC members
if member_id is not None:
results['msg'] += junos_module._pyez_conn.reboot_api(all_re, install_params.get('vmhost'), member_id=member_id)
else:
results['msg'] += junos_module._pyez_conn.reboot_api(all_re, install_params.get('vmhost'))
except Exception as err: # pylint: disable=broad-except
if "ConnectionError" in str(type(err)):
# If Exception is ConnectionError, it is excpected
# Device reboot inititated succesfully
junos_module.logger.debug("Reboot RPC executed.")
results['msg'] += ' Reboot succeeded.'
else:
# If exception is not ConnectionError
# we will raise the exception
raise
junos_module.logger.debug("Reboot RPC successfully initiated.")
else:
try:
# Try to deal with the fact that we might not get the closing
Expand All @@ -744,8 +756,12 @@ def main():
junos_module.dev.timeout = 5
try:
if member_id is not None:
for m_id in member_id:
got = junos_module.sw.reboot(0, None, all_re, None, install_params.get('vmhost'), member_id=m_id)
got = junos_module.sw.reboot(0,
None,
all_re,
None,
install_params.get('vmhost'),
member_id=member_id)
else:
got = junos_module.sw.reboot(0, None, all_re, None, install_params.get('vmhost'))
junos_module.dev.timeout = restore_timeout
Expand Down