Skip to content

Commit

Permalink
Merge pull request #1294 from apurvaraghu/master
Browse files Browse the repository at this point in the history
implement shutdown for vmhost devices
  • Loading branch information
dineshbaburam91 authored Jan 25, 2024
2 parents 422ca38 + 78322e7 commit 76561fd
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 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,13 @@ 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 Exception as err:
if err.rsp.findtext(".//error-severity") != "warning":
raise err
Expand Down

0 comments on commit 76561fd

Please sign in to comment.