Skip to content

Commit

Permalink
Merge pull request #5783 from alexbrett/IH-621
Browse files Browse the repository at this point in the history
IH-621: Add IPMI host power on support and remove DRAC
  • Loading branch information
robhoes authored Jul 8, 2024
2 parents caff014 + 331c564 commit eee3f80
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 67 deletions.
3 changes: 2 additions & 1 deletion ocaml/idl/datamodel_host.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1367,6 +1367,7 @@ let set_power_on_mode =
[
(Published, rel_cowley, "")
; (Changed, rel_stockholm, "Removed iLO script")
; (Changed, "24.19.0", "Replaced DRAC mode with IPMI")
]
~in_product_since:rel_midnight_ride
~doc:"Set the power-on-mode, host, user and password"
Expand All @@ -1375,7 +1376,7 @@ let set_power_on_mode =
(Ref _host, "self", "The host")
; ( String
, "power_on_mode"
, "power-on-mode can be empty, wake-on-lan, DRAC or other"
, "power-on-mode can be empty, wake-on-lan, IPMI or other"
)
; (Map (String, String), "power_on_config", "Power on config")
]
Expand Down
2 changes: 1 addition & 1 deletion scripts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ endif
# poweron
$(IPROG) poweron/wlan.py $(DESTDIR)$(PLUGINDIR)/wlan.py
$(IPROG) poweron/wlan.py $(DESTDIR)$(PLUGINDIR)/wake-on-lan
$(IPROG) poweron/DRAC.py $(DESTDIR)$(PLUGINDIR)/DRAC.py
$(IPROG) poweron/IPMI.py $(DESTDIR)$(PLUGINDIR)/IPMI.py
$(IPROG) poweron/power-on.py $(DESTDIR)$(PLUGINDIR)/power-on-host
# YUM plugins
$(IPROG) yum-plugins/accesstoken.py $(DESTDIR)$(YUMPLUGINDIR)
Expand Down
60 changes: 0 additions & 60 deletions scripts/poweron/DRAC.py

This file was deleted.

43 changes: 43 additions & 0 deletions scripts/poweron/IPMI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env python3

import sys
from xcp import cmd

class IPMI_POWERON_FAILED(Exception):
"""IPMI Poweron exception"""
pass

ipmi_path = "/usr/bin/ipmitool"

def IPMI(power_on_ip, user, password):
(rc, stdout, stderr) = cmd.runCmd(
[
ipmi_path,
"-H",
power_on_ip,
"-I", "lanplus",
"-U",
user,
"-P",
password,
"chassis", "power", "on"
],
with_stdout=True,
with_stderr=True,
)
if rc != 0:
raise IPMI_POWERON_FAILED(stderr)
return stdout


def main():
if len(sys.argv) < 3:
sys.exit(1)
ip = sys.argv[1]
user = sys.argv[2]
password = sys.argv[3]
print(IPMI(ip, user, password))


if __name__ == "__main__":
main()
10 changes: 5 additions & 5 deletions scripts/poweron/power-on.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ def main(session, args):

power_on_config = session.xenapi.host.get_power_on_config(remote_host)

if mode == "DRAC":
if mode == "IPMI":
ip = power_on_config["power_on_ip"]
user = power_on_config["power_on_user"]
secret = power_on_config["power_on_password_secret"]
secretref = session.xenapi.secret.get_by_uuid(secret)
password = session.xenapi.secret.get_value(secretref)
modu = __import__("DRAC")
modu.DRAC(ip, user, password)
modu = __import__("IPMI")
modu.IPMI(ip, user, password)
return waitForXapi(session, remote_host)
elif mode == "wake-on-lan":
modu = __import__("wlan")
Expand All @@ -60,8 +60,8 @@ def main(session, args):
modu = __import__(mode)
except ModuleNotFoundError as e:
# iLO.py was removed as part of REQ-811, so tell user why they are receiving this error
if mode == "iLO":
syslog.syslog(syslog.LOG_ERR, "iLO script was removed")
if mode in ["iLO", "DRAC"]:
syslog.syslog(syslog.LOG_ERR, f"{mode} script has been removed")
raise e

modu.custom(session, remote_host, power_on_config)
Expand Down

0 comments on commit eee3f80

Please sign in to comment.