Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement action:shutdown for vmhost devices issue 587 #1287

Closed
wants to merge 3 commits into from
Closed
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
18 changes: 13 additions & 5 deletions lib/jnpr/junos/utils/sw.py
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,8 @@ def _system_operation(
) and member_id is not None:
cmd.append(E("member", str(member_id)))
if in_min >= 0 and at is None:
cmd.append(E("in", str(in_min)))
if vmhost is not True:
cmd.append(E("in", str(in_min)))
elif at is not None:
cmd.append(E("at", str(at)))
try:
Expand Down Expand Up @@ -1230,7 +1231,9 @@ def reboot(
# -------------------------------------------------------------------------
# poweroff - system shutdown
# -------------------------------------------------------------------------
def poweroff(self, in_min=0, at=None, on_node=None, all_re=True, other_re=False):
def poweroff(
self, in_min=0, at=None, on_node=None, all_re=True, other_re=False, vmhost=False
):
"""
Perform a system shutdown, with optional delay (in minutes) .

Expand All @@ -1252,6 +1255,8 @@ def poweroff(self, in_min=0, at=None, on_node=None, all_re=True, other_re=False)
:param str other_re: If the system has dual Routing Engines and this option is C(true),
then the action is performed on the other REs in the system.

:param str vmhost: If the device is vmhost device then the shutdown will be performed on the device

:returns:
* power-off message (string) if command successful

Expand All @@ -1265,12 +1270,15 @@ def poweroff(self, in_min=0, at=None, on_node=None, all_re=True, other_re=False)
else:
cmd = E("request-node-power-off")
cmd.append(E("node", on_node))
elif vmhost is True:
cmd = E("request-vmhost-poweroff")
all_re = False
else:
cmd = E("request-power-off")
try:
return self._system_operation(
cmd, in_min, at, all_re, other_re, vmhost=False
)
return self._system_operation(cmd, in_min, at, all_re, other_re, vmhost)
except RpcTimeoutError as err:
raise err
except Exception as err:
if err.rsp.findtext(".//error-severity") != "warning":
raise err
Expand Down
Loading