launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14854
[Merge] lp:~andreserl/maas/backport_rev1410_to_stabilization into lp:maas/1.2
Andres Rodriguez has proposed merging lp:~andreserl/maas/backport_rev1410_to_stabilization into lp:maas/1.2.
Commit message:
Backport rev1410: Add fence_cdu power type.
Requested reviews:
MAAS Maintainers (maas-maintainers)
For more details, see:
https://code.launchpad.net/~andreserl/maas/backport_rev1410_to_stabilization/+merge/140907
--
https://code.launchpad.net/~andreserl/maas/backport_rev1410_to_stabilization/+merge/140907
Your team MAAS Maintainers is requested to review the proposed merge of lp:~andreserl/maas/backport_rev1410_to_stabilization into lp:maas/1.2.
=== modified file 'src/maasserver/models/node.py'
--- src/maasserver/models/node.py 2012-11-16 13:50:43 +0000
+++ src/maasserver/models/node.py 2012-12-20 14:23:24 +0000
@@ -752,6 +752,7 @@
power_params.setdefault('system_id', self.system_id)
power_params.setdefault('virsh', '/usr/bin/virsh')
+ power_params.setdefault('fence_cdu', '/usr/sbin/fence_cdu')
power_params.setdefault('ipmipower', '/usr/sbin/ipmipower')
power_params.setdefault(
'ipmi_chassis_config', '/usr/sbin/ipmi-chassis-config')
=== modified file 'src/maasserver/power_parameters.py'
--- src/maasserver/power_parameters.py 2012-09-17 17:27:02 +0000
+++ src/maasserver/power_parameters.py 2012-12-20 14:23:24 +0000
@@ -64,6 +64,25 @@
],
required=False,
skip_check=True),
+ POWER_TYPE.CDU:
+ DictCharField(
+ [
+ (
+ 'power_id',
+ forms.CharField(label="Power ID", required=False)),
+ (
+ 'power_address',
+ forms.CharField(label="IP Address or Hostname",
+ required=False)),
+ (
+ 'power_user',
+ forms.CharField(label="Username", required=False)),
+ (
+ 'power_pass',
+ forms.CharField(label="Password", required=False)),
+ ],
+ required=False,
+ skip_check=True),
POWER_TYPE.IPMI:
DictCharField(
[
=== modified file 'src/provisioningserver/enum.py'
--- src/provisioningserver/enum.py 2012-09-17 17:27:02 +0000
+++ src/provisioningserver/enum.py 2012-12-20 14:23:24 +0000
@@ -33,6 +33,9 @@
# Network wake-up.
WAKE_ON_LAN = 'ether_wake'
+ # Sentry Switch CDU's.
+ CDU = 'fence_cdu'
+
# IPMI (Intelligent Platform Management Interface).
IPMI = 'ipmi'
@@ -40,6 +43,7 @@
POWER_TYPE_CHOICES = (
(POWER_TYPE.VIRSH, "virsh (virtual systems)"),
(POWER_TYPE.WAKE_ON_LAN, "Wake-on-LAN"),
+ (POWER_TYPE.CDU, "Sentry Switch CDU"),
(POWER_TYPE.IPMI, "IPMI"),
)
=== added file 'src/provisioningserver/power/templates/fence_cdu.template'
--- src/provisioningserver/power/templates/fence_cdu.template 1970-01-01 00:00:00 +0000
+++ src/provisioningserver/power/templates/fence_cdu.template 2012-12-20 14:23:24 +0000
@@ -0,0 +1,54 @@
+# -*- mode: shell-script -*-
+#
+# Control virtual system's "power" through virsh.
+#
+
+# Parameters.
+# Choose command for virsh to make the requested power change happen.
+power_change={{power_change}}
+power_address={{power_address}}
+power_user={{power_user}}
+power_pass={{power_pass}}
+power_id={{power_id}}
+fence_cdu={{fence_cdu}}
+
+
+formulate_power_command() {
+ if [ ${power_change} = 'on' ]
+ then
+ echo 'on'
+ else
+ echo 'off'
+ fi
+}
+
+
+# Express system's current state as expressed by virsh as "on" or "off".
+formulate_power_state() {
+ case $2 in
+ 'on'|'ON') echo 'on' ;;
+ 'off'|'OFF') echo 'off' ;;
+ *)
+ echo "Got unknown power state from fence_cdu: '$1'" >&2
+ exit 1
+ esac
+}
+
+
+# Issue command to virsh, for the given system.
+issue_fence_cdu_command() {
+ ${fence_cdu} -a ${power_address} -n ${power_id} -l ${power_user} -p ${power_pass} -o "$@"
+}
+
+
+# Get the given system's power state: 'on' or 'off'.
+get_power_state() {
+ fence_cdu_state=$(issue_fence_cdu_command status)
+ formulate_power_state ${fence_cdu_state}
+}
+
+
+if [ "$(get_power_state)" != "${power_change}" ]
+then
+ issue_fence_cdu_command $(formulate_power_command)
+fi
=== modified file 'src/provisioningserver/power/tests/test_poweraction.py'
--- src/provisioningserver/power/tests/test_poweraction.py 2012-10-05 16:33:37 +0000
+++ src/provisioningserver/power/tests/test_poweraction.py 2012-12-20 14:23:24 +0000
@@ -159,6 +159,20 @@
stdout, stderr = action.run_shell(script)
self.assertIn("Got unknown power state from virsh", stderr)
+ def test_fence_cdu_checks_state(self):
+ # We can't test the fence_cdu template in detail (and it may be
+ # customized), but by making it use "echo" instead of a real
+ # fence_cdu we can make it get a bogus answer from its status check.
+ # The bogus answer is actually the rest of the fence_cdu command
+ # line. It will complain about this and fail.
+ action = PowerAction(POWER_TYPE.CDU)
+ script = action.render_template(
+ action.get_template(), power_change='on',
+ power_address='mysystem', power_id='system',
+ power_user='me', power_pass='me', fence_cdu='echo')
+ stdout, stderr = action.run_shell(script)
+ self.assertIn("Got unknown power state from fence_cdu", stderr)
+
def test_ipmi_checks_state(self):
action = PowerAction(POWER_TYPE.IPMI)
script = action.render_template(
Follow ups