launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #09890
[Merge] lp:~andreserl/maas/maas_ipmi_support into lp:maas
Andres Rodriguez has proposed merging lp:~andreserl/maas/maas_ipmi_support into lp:maas.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~andreserl/maas/maas_ipmi_support/+merge/114726
--
https://code.launchpad.net/~andreserl/maas/maas_ipmi_support/+merge/114726
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~andreserl/maas/maas_ipmi_support into lp:maas.
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py 2012-07-11 15:49:34 +0000
+++ src/maasserver/models/node.py 2012-07-12 20:56:24 +0000
@@ -553,6 +553,7 @@
power_params.setdefault('system_id', self.system_id)
power_params.setdefault('virsh', '/usr/bin/virsh')
+ power_params.setdefault('ipmitool', '/usr/bin/ipmitool')
power_params.setdefault('power_address', 'qemu://localhost/system')
power_params.setdefault('username', '')
power_params.setdefault('power_id', self.system_id)
=== modified file 'src/maasserver/power_parameters.py'
--- src/maasserver/power_parameters.py 2012-06-07 15:44:06 +0000
+++ src/maasserver/power_parameters.py 2012-07-12 20:56:24 +0000
@@ -68,10 +68,10 @@
[
(
'power_address',
- forms.CharField(label="Address", required=False)),
+ forms.CharField(label="IP Address or Hostname", required=False)),
(
'power_user',
- forms.CharField(label="User", required=False)),
+ forms.CharField(label="Username", required=False)),
(
'power_pass',
forms.CharField(label="Password", required=False)),
@@ -82,14 +82,14 @@
DictCharField(
[
(
+ 'power_address',
+ forms.CharField(label="IP Address or Hostname", required=False)),
+ (
'power_user',
- forms.CharField(label="User", required=False)),
+ forms.CharField(label="Username", required=False)),
(
'power_pass',
forms.CharField(label="Password", required=False)),
- (
- 'power_id',
- forms.CharField(label="Power ID", required=False)),
],
required=False,
skip_check=True),
=== added file 'src/provisioningserver/power/templates/ipmilan.template'
--- src/provisioningserver/power/templates/ipmilan.template 1970-01-01 00:00:00 +0000
+++ src/provisioningserver/power/templates/ipmilan.template 2012-07-12 20:56:24 +0000
@@ -0,0 +1,40 @@
+# -*- mode: shell-script -*-
+#
+# Control a system via ipmitool LAN
+#
+
+# Parameters.
+power_change={{power_change}}
+power_address={{power_address}}
+power_user={{power_user}}
+power_pass={{power_pass}}
+ipmitool={{ipmitool}}
+
+
+formulate_power_state() {
+ case $1 in
+ 'Chassis Power is on') echo 'on' ;;
+ 'Chassis Power is off') echo 'off' ;;
+ *)
+ echo "Got unknown power state from ipmitool: '$1'" >&2
+ exit 1
+ esac
+}
+
+# Issue command to ipmitool, for the given system.
+issue_ipmi_command() {
+ ${ipmitool} -I lan -H ${power_address} -U ${power_user} -P ${power_pass} power $1
+}
+
+
+# Get the given system's power state: 'on' or 'off'.
+get_power_state() {
+ ipmi_state=$(issue_ipmi_command status)
+ formulate_power_state ${ipmi_state}
+}
+
+
+if [ "$(get_power_state)" != "${power_change}" ]
+then
+ issue_ipmi_command ${power_change}
+fi
=== added file 'src/provisioningserver/power/templates/ipmitool.template'
--- src/provisioningserver/power/templates/ipmitool.template 1970-01-01 00:00:00 +0000
+++ src/provisioningserver/power/templates/ipmitool.template 2012-07-12 20:56:24 +0000
@@ -0,0 +1,40 @@
+# -*- mode: shell-script -*-
+#
+# Control a system via ipmitool
+#
+
+# Parameters.
+power_change={{power_change}}
+power_address={{power_address}}
+power_user={{power_user}}
+power_pass={{power_pass}}
+ipmitool={{ipmitool}}
+
+
+formulate_power_state() {
+ case $1 in
+ 'Chassis Power is on') echo 'on' ;;
+ 'Chassis Power is off') echo 'off' ;;
+ *)
+ echo "Got unknown power state from ipmitool: '$1'" >&2
+ exit 1
+ esac
+}
+
+# Issue command to ipmitool, for the given system.
+issue_ipmi_command() {
+ ${ipmitool} -H ${power_address} -U ${power_user} -P ${power_pass} power $1
+}
+
+
+# Get the given system's power state: 'on' or 'off'.
+get_power_state() {
+ ipmi_state=$(issue_ipmi_command status)
+ formulate_power_state ${ipmi_state}
+}
+
+
+if [ "$(get_power_state)" != "${power_change}" ]
+then
+ issue_ipmi_command ${power_change}
+fi
=== modified file 'src/provisioningserver/power/tests/test_poweraction.py'
--- src/provisioningserver/power/tests/test_poweraction.py 2012-06-28 07:09:01 +0000
+++ src/provisioningserver/power/tests/test_poweraction.py 2012-07-12 20:56:24 +0000
@@ -156,3 +156,21 @@
power_id='mysystem', username='me', virsh='echo')
stdout, stderr = action.run_shell(script)
self.assertIn("Got unknown power state from virsh", stderr)
+
+ def test_ipmi_lan_checks_status(self):
+ action = PowerAction(POWER_TYPE.IPMI_LAN)
+ script = action.render_template(
+ action.get_template(), power_change='on',
+ power_address='mystystem', power_user='me',
+ power_pass='me', ipmitool='echo')
+ stdout, stderr = action.run_shell(script)
+ self.assertIn("Got unknown power state from ipmitool", stderr)
+
+ def test_ipmi_checks_status(self):
+ action = PowerAction(POWER_TYPE.IPMI_LAN)
+ script = action.render_template(
+ action.get_template(), power_change='on',
+ power_address='mystystem', power_user='me',
+ power_pass='me', ipmitool='echo')
+ stdout, stderr = action.run_shell(script)
+ self.assertIn("Got unknown power state from ipmitool", stderr)
Follow ups