Skip to content

Commit

Permalink
issue587 (#636)
Browse files Browse the repository at this point in the history
* implement action:shutdown in vmhost devices

* implem
  • Loading branch information
apurvaraghu authored Jan 24, 2024
1 parent 290e339 commit cf07c23
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions ansible_collections/juniper/device/plugins/connection/pyez.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -202,7 +202,7 @@
vars:
- name: ansible_pyez_ssh_config
- name: ssh_config
"""
import pickle

Expand Down Expand Up @@ -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.
Expand All @@ -469,16 +469,16 @@ 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)
resp = self.dev.rpc(rpc_etree, normalize=bool(format == 'xml'), ignore_warning=ignore_warning)
if(format == 'json'):
return resp
return etree.tostring(resp)

def get_facts(self):
"""Get device facts.
"""
Expand Down Expand Up @@ -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':
Expand Down
6 changes: 3 additions & 3 deletions ansible_collections/juniper/device/plugins/modules/system.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

DOCUMENTATION = '''
---
extends_documentation_fragment:
extends_documentation_fragment:
- juniper_junos_common.connection_documentation
- juniper_junos_common.logging_documentation
module: system
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit cf07c23

Please sign in to comment.