Merge lp:~andreserl/maas/backport_rev1410_to_stabilization into lp:maas/1.2

Proposed by Andres Rodriguez
Status: Merged
Approved by: Andres Rodriguez
Approved revision: 1339
Merged at revision: 1340
Proposed branch: lp:~andreserl/maas/backport_rev1410_to_stabilization
Merge into: lp:maas/1.2
Diff against target: 147 lines (+92/-0)
5 files modified
src/maasserver/models/node.py (+1/-0)
src/maasserver/power_parameters.py (+19/-0)
src/provisioningserver/enum.py (+4/-0)
src/provisioningserver/power/templates/fence_cdu.template (+54/-0)
src/provisioningserver/power/tests/test_poweraction.py (+14/-0)
To merge this branch: bzr merge lp:~andreserl/maas/backport_rev1410_to_stabilization
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+140907@code.launchpad.net

Commit message

Backport rev1410: Add fence_cdu power type.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) :
review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :

The Jenkins job https://jenkins.qa.ubuntu.com/job/maas-merger-quantal/309/console reported an error when processing this lp:~andreserl/maas/backport_rev1410_to_stabilization branch.
Not merging it.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/node.py'
2--- src/maasserver/models/node.py 2012-11-16 13:50:43 +0000
3+++ src/maasserver/models/node.py 2012-12-20 14:32:21 +0000
4@@ -752,6 +752,7 @@
5
6 power_params.setdefault('system_id', self.system_id)
7 power_params.setdefault('virsh', '/usr/bin/virsh')
8+ power_params.setdefault('fence_cdu', '/usr/sbin/fence_cdu')
9 power_params.setdefault('ipmipower', '/usr/sbin/ipmipower')
10 power_params.setdefault(
11 'ipmi_chassis_config', '/usr/sbin/ipmi-chassis-config')
12
13=== modified file 'src/maasserver/power_parameters.py'
14--- src/maasserver/power_parameters.py 2012-09-17 17:27:02 +0000
15+++ src/maasserver/power_parameters.py 2012-12-20 14:32:21 +0000
16@@ -64,6 +64,25 @@
17 ],
18 required=False,
19 skip_check=True),
20+ POWER_TYPE.CDU:
21+ DictCharField(
22+ [
23+ (
24+ 'power_id',
25+ forms.CharField(label="Power ID", required=False)),
26+ (
27+ 'power_address',
28+ forms.CharField(label="IP Address or Hostname",
29+ required=False)),
30+ (
31+ 'power_user',
32+ forms.CharField(label="Username", required=False)),
33+ (
34+ 'power_pass',
35+ forms.CharField(label="Password", required=False)),
36+ ],
37+ required=False,
38+ skip_check=True),
39 POWER_TYPE.IPMI:
40 DictCharField(
41 [
42
43=== modified file 'src/provisioningserver/enum.py'
44--- src/provisioningserver/enum.py 2012-09-17 17:27:02 +0000
45+++ src/provisioningserver/enum.py 2012-12-20 14:32:21 +0000
46@@ -33,6 +33,9 @@
47 # Network wake-up.
48 WAKE_ON_LAN = 'ether_wake'
49
50+ # Sentry Switch CDU's.
51+ CDU = 'fence_cdu'
52+
53 # IPMI (Intelligent Platform Management Interface).
54 IPMI = 'ipmi'
55
56@@ -40,6 +43,7 @@
57 POWER_TYPE_CHOICES = (
58 (POWER_TYPE.VIRSH, "virsh (virtual systems)"),
59 (POWER_TYPE.WAKE_ON_LAN, "Wake-on-LAN"),
60+ (POWER_TYPE.CDU, "Sentry Switch CDU"),
61 (POWER_TYPE.IPMI, "IPMI"),
62 )
63
64
65=== added file 'src/provisioningserver/power/templates/fence_cdu.template'
66--- src/provisioningserver/power/templates/fence_cdu.template 1970-01-01 00:00:00 +0000
67+++ src/provisioningserver/power/templates/fence_cdu.template 2012-12-20 14:32:21 +0000
68@@ -0,0 +1,54 @@
69+# -*- mode: shell-script -*-
70+#
71+# Control virtual system's "power" through virsh.
72+#
73+
74+# Parameters.
75+# Choose command for virsh to make the requested power change happen.
76+power_change={{power_change}}
77+power_address={{power_address}}
78+power_user={{power_user}}
79+power_pass={{power_pass}}
80+power_id={{power_id}}
81+fence_cdu={{fence_cdu}}
82+
83+
84+formulate_power_command() {
85+ if [ ${power_change} = 'on' ]
86+ then
87+ echo 'on'
88+ else
89+ echo 'off'
90+ fi
91+}
92+
93+
94+# Express system's current state as expressed by virsh as "on" or "off".
95+formulate_power_state() {
96+ case $2 in
97+ 'on'|'ON') echo 'on' ;;
98+ 'off'|'OFF') echo 'off' ;;
99+ *)
100+ echo "Got unknown power state from fence_cdu: '$1'" >&2
101+ exit 1
102+ esac
103+}
104+
105+
106+# Issue command to virsh, for the given system.
107+issue_fence_cdu_command() {
108+ ${fence_cdu} -a ${power_address} -n ${power_id} -l ${power_user} -p ${power_pass} -o "$@"
109+}
110+
111+
112+# Get the given system's power state: 'on' or 'off'.
113+get_power_state() {
114+ fence_cdu_state=$(issue_fence_cdu_command status)
115+ formulate_power_state ${fence_cdu_state}
116+}
117+
118+
119+if [ "$(get_power_state)" != "${power_change}" ]
120+then
121+ issue_fence_cdu_command $(formulate_power_command)
122+fi
123
124=== modified file 'src/provisioningserver/power/tests/test_poweraction.py'
125--- src/provisioningserver/power/tests/test_poweraction.py 2012-10-05 16:33:37 +0000
126+++ src/provisioningserver/power/tests/test_poweraction.py 2012-12-20 14:32:21 +0000
127@@ -159,6 +159,20 @@
128 stdout, stderr = action.run_shell(script)
129 self.assertIn("Got unknown power state from virsh", stderr)
130
131+ def test_fence_cdu_checks_state(self):
132+ # We can't test the fence_cdu template in detail (and it may be
133+ # customized), but by making it use "echo" instead of a real
134+ # fence_cdu we can make it get a bogus answer from its status check.
135+ # The bogus answer is actually the rest of the fence_cdu command
136+ # line. It will complain about this and fail.
137+ action = PowerAction(POWER_TYPE.CDU)
138+ script = action.render_template(
139+ action.get_template(), power_change='on',
140+ power_address='mysystem', power_id='system',
141+ power_user='me', power_pass='me', fence_cdu='echo')
142+ stdout, stderr = action.run_shell(script)
143+ self.assertIn("Got unknown power state from fence_cdu", stderr)
144+
145 def test_ipmi_checks_state(self):
146 action = PowerAction(POWER_TYPE.IPMI)
147 script = action.render_template(

Subscribers

People subscribed via source and target branches

to status/vote changes: