Skip to content

Commit eee3f80

Browse files
authored
Merge pull request #5783 from alexbrett/IH-621
IH-621: Add IPMI host power on support and remove DRAC
2 parents caff014 + 331c564 commit eee3f80

File tree

5 files changed

+51
-67
lines changed

5 files changed

+51
-67
lines changed

ocaml/idl/datamodel_host.ml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1367,6 +1367,7 @@ let set_power_on_mode =
13671367
[
13681368
(Published, rel_cowley, "")
13691369
; (Changed, rel_stockholm, "Removed iLO script")
1370+
; (Changed, "24.19.0", "Replaced DRAC mode with IPMI")
13701371
]
13711372
~in_product_since:rel_midnight_ride
13721373
~doc:"Set the power-on-mode, host, user and password"
@@ -1375,7 +1376,7 @@ let set_power_on_mode =
13751376
(Ref _host, "self", "The host")
13761377
; ( String
13771378
, "power_on_mode"
1378-
, "power-on-mode can be empty, wake-on-lan, DRAC or other"
1379+
, "power-on-mode can be empty, wake-on-lan, IPMI or other"
13791380
)
13801381
; (Map (String, String), "power_on_config", "Power on config")
13811382
]

scripts/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ endif
178178
# poweron
179179
$(IPROG) poweron/wlan.py $(DESTDIR)$(PLUGINDIR)/wlan.py
180180
$(IPROG) poweron/wlan.py $(DESTDIR)$(PLUGINDIR)/wake-on-lan
181-
$(IPROG) poweron/DRAC.py $(DESTDIR)$(PLUGINDIR)/DRAC.py
181+
$(IPROG) poweron/IPMI.py $(DESTDIR)$(PLUGINDIR)/IPMI.py
182182
$(IPROG) poweron/power-on.py $(DESTDIR)$(PLUGINDIR)/power-on-host
183183
# YUM plugins
184184
$(IPROG) yum-plugins/accesstoken.py $(DESTDIR)$(YUMPLUGINDIR)

scripts/poweron/DRAC.py

Lines changed: 0 additions & 60 deletions
This file was deleted.

scripts/poweron/IPMI.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#!/usr/bin/env python3
2+
3+
import sys
4+
from xcp import cmd
5+
6+
class IPMI_POWERON_FAILED(Exception):
7+
"""IPMI Poweron exception"""
8+
pass
9+
10+
ipmi_path = "/usr/bin/ipmitool"
11+
12+
def IPMI(power_on_ip, user, password):
13+
(rc, stdout, stderr) = cmd.runCmd(
14+
[
15+
ipmi_path,
16+
"-H",
17+
power_on_ip,
18+
"-I", "lanplus",
19+
"-U",
20+
user,
21+
"-P",
22+
password,
23+
"chassis", "power", "on"
24+
],
25+
with_stdout=True,
26+
with_stderr=True,
27+
)
28+
if rc != 0:
29+
raise IPMI_POWERON_FAILED(stderr)
30+
return stdout
31+
32+
33+
def main():
34+
if len(sys.argv) < 3:
35+
sys.exit(1)
36+
ip = sys.argv[1]
37+
user = sys.argv[2]
38+
password = sys.argv[3]
39+
print(IPMI(ip, user, password))
40+
41+
42+
if __name__ == "__main__":
43+
main()

scripts/poweron/power-on.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ def main(session, args):
4141

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

44-
if mode == "DRAC":
44+
if mode == "IPMI":
4545
ip = power_on_config["power_on_ip"]
4646
user = power_on_config["power_on_user"]
4747
secret = power_on_config["power_on_password_secret"]
4848
secretref = session.xenapi.secret.get_by_uuid(secret)
4949
password = session.xenapi.secret.get_value(secretref)
50-
modu = __import__("DRAC")
51-
modu.DRAC(ip, user, password)
50+
modu = __import__("IPMI")
51+
modu.IPMI(ip, user, password)
5252
return waitForXapi(session, remote_host)
5353
elif mode == "wake-on-lan":
5454
modu = __import__("wlan")
@@ -60,8 +60,8 @@ def main(session, args):
6060
modu = __import__(mode)
6161
except ModuleNotFoundError as e:
6262
# iLO.py was removed as part of REQ-811, so tell user why they are receiving this error
63-
if mode == "iLO":
64-
syslog.syslog(syslog.LOG_ERR, "iLO script was removed")
63+
if mode in ["iLO", "DRAC"]:
64+
syslog.syslog(syslog.LOG_ERR, f"{mode} script has been removed")
6565
raise e
6666

6767
modu.custom(session, remote_host, power_on_config)

0 commit comments

Comments
 (0)