From cf07c23c16f0397c8efdcae278b131112acf8116 Mon Sep 17 00:00:00 2001 From: apurvaraghu <100869315+apurvaraghu@users.noreply.github.com> Date: Wed, 24 Jan 2024 01:32:16 -0800 Subject: [PATCH] issue587 (#636) * implement action:shutdown in vmhost devices * implem --- .../juniper/device/plugins/connection/pyez.py | 14 +++++++------- .../juniper/device/plugins/modules/system.py | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/ansible_collections/juniper/device/plugins/connection/pyez.py b/ansible_collections/juniper/device/plugins/connection/pyez.py index b262fc23..dbc50281 100644 --- a/ansible_collections/juniper/device/plugins/connection/pyez.py +++ b/ansible_collections/juniper/device/plugins/connection/pyez.py @@ -113,7 +113,7 @@ env: - name: ANSIBLE_PYEZ_CONSOLE vars: - - name: ansible_pyez_console + - name: ansible_pyez_console private_key_file: description: - The private SSH key or certificate file used to authenticate to the remote device @@ -202,7 +202,7 @@ vars: - name: ansible_pyez_ssh_config - name: ssh_config - + """ import pickle @@ -453,7 +453,7 @@ def get_config(self, filter_xml=None, options=None, model=None, """ resp = self.dev.rpc.get_config(filter_xml, options, model, namespace, remove_ns, **kwarg) return etree.tostring(resp) - + def get_rpc_resp(self,rpc, ignore_warning, format): """Execute rpc on the device and get response. @@ -469,8 +469,8 @@ def get_rpc_resp(self,rpc, ignore_warning, format): Fails: - If the RPC produces an exception. """ - # data comes in JSON format, needs to be converted - rpc_val = xmltodict.unparse(rpc) + # data comes in JSON format, needs to be converted + rpc_val = xmltodict.unparse(rpc) rpc_val = rpc_val.encode('utf-8') parser = etree.XMLParser(ns_clean=True, recover=True, encoding='utf-8') rpc_etree = etree.fromstring(rpc_val, parser=parser) @@ -478,7 +478,7 @@ def get_rpc_resp(self,rpc, ignore_warning, format): if(format == 'json'): return resp return etree.tostring(resp) - + def get_facts(self): """Get device facts. """ @@ -773,7 +773,7 @@ def system_api(self, action, in_min, at, all_re, vmhost, other_re, media, member else: got = self.sw.reboot(in_min, at, all_re, None, vmhost, other_re) elif action == 'shutdown': - got = self.sw.poweroff(in_min, at, None, all_re, other_re) + got = self.sw.poweroff(in_min, at, None, all_re, other_re, vmhost) elif action == 'halt': got = self.sw.halt(in_min, at, all_re, other_re) elif action == 'zeroize': diff --git a/ansible_collections/juniper/device/plugins/modules/system.py b/ansible_collections/juniper/device/plugins/modules/system.py index 6dd40178..6834cf42 100644 --- a/ansible_collections/juniper/device/plugins/modules/system.py +++ b/ansible_collections/juniper/device/plugins/modules/system.py @@ -39,7 +39,7 @@ DOCUMENTATION = ''' --- -extends_documentation_fragment: +extends_documentation_fragment: - juniper_junos_common.connection_documentation - juniper_junos_common.logging_documentation module: system @@ -81,7 +81,7 @@ - power_off at: description: - - The time at which to shutdown, halt, or reboot the system. + - The time at which to shutdown, halt, or reboot the system. - > The value may be specified in one of the following ways: - B(now) - The action takes effect immediately. @@ -365,7 +365,7 @@ def main(): else: got = junos_module.sw.reboot(in_min, at, all_re, None, vmhost, other_re) elif action == 'shutdown': - got = junos_module.sw.poweroff(in_min, at, None, all_re, other_re) + got = junos_module.sw.poweroff(in_min, at, None, all_re, other_re, vmhost) elif action == 'halt': got = junos_module.sw.halt(in_min, at, all_re, other_re) elif action == 'zeroize':