Merge lp:~rvb/maas/amt_wsman-1.7 into lp:maas/1.7

Proposed by Raphaël Badin
Status: Merged
Merged at revision: 3349
Proposed branch: lp:~rvb/maas/amt_wsman-1.7
Merge into: lp:maas/1.7
Diff against target: 278 lines (+180/-19)
1 file modified
etc/maas/templates/power/amt.template (+180/-19)
To merge this branch: bzr merge lp:~rvb/maas/amt_wsman-1.7
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+251618@code.launchpad.net

Commit message

Backport revision 3567: AMT power template changes to use in place of for any AMT versions > 8.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

Simple backport: self-approving.

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (22.0 KiB)

The attempt to merge lp:~rvb/maas/amt_wsman-1.7 into lp:maas/1.7 failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Get:2 http://security.ubuntu.com trusty-security Release [62.0 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates Release [62.0 kB]
Get:5 http://security.ubuntu.com trusty-security/main Sources [71.4 kB]
Get:6 http://security.ubuntu.com trusty-security/universe Sources [17.9 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Get:7 http://security.ubuntu.com trusty-security/main amd64 Packages [220 kB]
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [87.7 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:9 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [181 kB]
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [105 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [446 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [254 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 1,509 kB in 3s (503 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools gjs ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-amqplib python-bson python-bzrlib python-celery python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mimeparse python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexpect python-pip python-pocket-lint python-psycopg2 pyth...

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (22.0 KiB)

The attempt to merge lp:~rvb/maas/amt_wsman-1.7 into lp:maas/1.7 failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Get:2 http://security.ubuntu.com trusty-security Release [62.0 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates Release [62.0 kB]
Get:5 http://security.ubuntu.com trusty-security/main Sources [71.4 kB]
Get:6 http://security.ubuntu.com trusty-security/universe Sources [17.9 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Get:7 http://security.ubuntu.com trusty-security/main amd64 Packages [220 kB]
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [87.7 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:9 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [181 kB]
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [105 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [446 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [254 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 1,509 kB in 4s (359 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools gjs ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-amqplib python-bson python-bzrlib python-celery python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mimeparse python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexpect python-pip python-pocket-lint python-psycopg2 pyth...

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (22.0 KiB)

The attempt to merge lp:~rvb/maas/amt_wsman-1.7 into lp:maas/1.7 failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Get:2 http://security.ubuntu.com trusty-security Release [62.0 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates Release [62.0 kB]
Get:5 http://security.ubuntu.com trusty-security/main Sources [71.4 kB]
Get:6 http://security.ubuntu.com trusty-security/universe Sources [17.9 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Get:7 http://security.ubuntu.com trusty-security/main amd64 Packages [220 kB]
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [87.7 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:9 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [181 kB]
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [105 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [446 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [254 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 1,509 kB in 3s (407 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools gjs ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-amqplib python-bson python-bzrlib python-celery python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mimeparse python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexpect python-pip python-pocket-lint python-psycopg2 pyth...

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (21.8 KiB)

The attempt to merge lp:~rvb/maas/amt_wsman-1.7 into lp:maas/1.7 failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Hit http://security.ubuntu.com trusty-security Release.gpg
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Hit http://security.ubuntu.com trusty-security Release
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Hit http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Hit http://security.ubuntu.com trusty-security/main Sources
Hit http://nova.clouds.archive.ubuntu.com trusty-updates Release
Hit http://security.ubuntu.com trusty-security/universe Sources
Hit http://security.ubuntu.com trusty-security/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Hit http://security.ubuntu.com trusty-security/universe amd64 Packages
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools gjs ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-amqplib python-bson python-bzrlib python-celery python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mimeparse python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexpect python-pip python-pocket-lint python-psycopg2 python-pyinotify python-seamicroclient python-simplejson python-simplestreams python-sphinx python-subunit python-tempita python-testresources python-testscenarios python-testt...

Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (22.0 KiB)

The attempt to merge lp:~rvb/maas/amt_wsman-1.7 into lp:maas/1.7 failed. Below is the output from the failed tests.

Ign http://security.ubuntu.com trusty-security InRelease
Get:1 http://security.ubuntu.com trusty-security Release.gpg [933 B]
Get:2 http://security.ubuntu.com trusty-security Release [62.0 kB]
Ign http://nova.clouds.archive.ubuntu.com trusty InRelease
Ign http://nova.clouds.archive.ubuntu.com trusty-updates InRelease
Hit http://nova.clouds.archive.ubuntu.com trusty Release.gpg
Get:3 http://nova.clouds.archive.ubuntu.com trusty-updates Release.gpg [933 B]
Hit http://nova.clouds.archive.ubuntu.com trusty Release
Get:4 http://nova.clouds.archive.ubuntu.com trusty-updates Release [62.0 kB]
Get:5 http://security.ubuntu.com trusty-security/main Sources [71.4 kB]
Get:6 http://security.ubuntu.com trusty-security/universe Sources [17.9 kB]
Get:7 http://security.ubuntu.com trusty-security/main amd64 Packages [220 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty/main Sources
Get:8 http://security.ubuntu.com trusty-security/universe amd64 Packages [87.7 kB]
Hit http://security.ubuntu.com trusty-security/main Translation-en
Hit http://security.ubuntu.com trusty-security/universe Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Sources
Hit http://nova.clouds.archive.ubuntu.com trusty/main amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/universe amd64 Packages
Hit http://nova.clouds.archive.ubuntu.com trusty/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en
Get:9 http://nova.clouds.archive.ubuntu.com trusty-updates/main Sources [181 kB]
Get:10 http://nova.clouds.archive.ubuntu.com trusty-updates/universe Sources [105 kB]
Get:11 http://nova.clouds.archive.ubuntu.com trusty-updates/main amd64 Packages [446 kB]
Get:12 http://nova.clouds.archive.ubuntu.com trusty-updates/universe amd64 Packages [254 kB]
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/main Translation-en
Hit http://nova.clouds.archive.ubuntu.com trusty-updates/universe Translation-en
Ign http://nova.clouds.archive.ubuntu.com trusty/main Translation-en_US
Ign http://nova.clouds.archive.ubuntu.com trusty/universe Translation-en_US
Fetched 1,509 kB in 3s (405 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
     --no-install-recommends install apache2 authbind bind9 bind9utils build-essential bzr-builddeb curl daemontools debhelper dh-apport distro-info dnsutils firefox freeipmi-tools gjs ipython isc-dhcp-common libjs-raphael libjs-yui3-full libjs-yui3-min libpq-dev make pep8 postgresql pyflakes python-amqplib python-bson python-bzrlib python-celery python-convoy python-crochet python-cssselect python-curtin python-dev python-distro-info python-django python-django-piston python-django-south python-djorm-ext-pgarray python-docutils python-extras python-fixtures python-flake8 python-formencode python-hivex python-httplib2 python-jinja2 python-jsonschema python-lockfile python-lxml python-mimeparse python-mock python-netaddr python-netifaces python-nose python-oauth python-openssl python-paramiko python-pexpect python-pip python-pocket-lint python-psycopg2 pyth...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'etc/maas/templates/power/amt.template'
--- etc/maas/templates/power/amt.template 2015-01-29 17:17:57 +0000
+++ etc/maas/templates/power/amt.template 2015-03-03 15:50:25 +0000
@@ -38,17 +38,27 @@
38 exit $138 exit $1
39}39}
4040
41# XXX: bladernr 2015-02-04 bug=1331214: AMT ver > 8 needs wsman not amttool
42# Check the version of AMT on node.
43check_amt_version() {
44 amt_version=$(issue_amt_command info 2>&1 | grep version | awk '{print $NF}')
45 major_version=$(echo $amt_version | awk -F'.' '{print $1}')
46 return $major_version
47}
48
4149
42# Perform a command using amttool.50# Perform a command using amttool.
43issue_amt_command() {51issue_amt_command() {
44 LC_ALL='C' AMT_PASSWORD="$power_pass" amttool "$ip_address" "$@"52 LC_ALL='C' AMT_PASSWORD="$power_pass" amttool "$ip_address" "$@"
45}53}
4654
55
47# Check that amttool is present.56# Check that amttool is present.
48check_amt_command() {57check_amt_command() {
49 command -v amttool >/dev/null 2>&1 || { fail 2 "Missing amttool (amtterm package)"; }58 command -v amttool >/dev/null 2>&1 || { fail 2 "Missing amttool (amtterm package)"; }
50}59}
5160
61
52# Check that a node host has been passed.62# Check that a node host has been passed.
53check_bmc_host() {63check_bmc_host() {
54 if [ -z "$ip_address" ]; then64 if [ -z "$ip_address" ]; then
@@ -59,11 +69,11 @@
59 fi69 fi
60}70}
6171
62# Ask for node's power state: 'on' or 'off'.72
63query_state() {73# Ask for node's power state: 'on' or 'off', via amttool.
74amt_query_state() {
64 # Retry the state if it fails because it often fails the first time.75 # Retry the state if it fails because it often fails the first time.
65 local state=76 local state=
66 local count=
67 for attempts in $(seq 0 10)77 for attempts in $(seq 0 10)
68 do78 do
69 state=$(issue_amt_command info | grep '^Powerstate:' | awk '{print $2}')79 state=$(issue_amt_command info | grep '^Powerstate:' | awk '{print $2}')
@@ -91,21 +101,20 @@
91}101}
92102
93103
94# Power-cycle the machine, and boot it using the requested boot mode.104# Power-cycle the machine via amttool, and boot it using the requested boot mode.
95restart() {105amt_restart() {
96 yes | issue_amt_command powercycle "$amt_boot_mode"106 yes | issue_amt_command powercycle "$amt_boot_mode"
97}107}
98108
99109
100# Power the machine on, and boot it using PXE.110# Power the machine on via amttool, and boot it using PXE.
101power_on() {111amt_power_on() {
102 local attempts=
103 # Try several times. Power commands often fail the first time.112 # Try several times. Power commands often fail the first time.
104 for attempts in $(seq 0 10)113 for attempts in $(seq 0 10)
105 do114 do
106 # Issue the AMT command; amttool will prompt for confirmation.115 # Issue the AMT command; amttool will prompt for confirmation.
107 yes | issue_amt_command powerup "$amt_boot_mode"116 yes | issue_amt_command powerup "$amt_boot_mode"
108 if [ "$(query_state)" = 'on' ]117 if [ "$(amt_query_state)" = 'on' ]
109 then118 then
110 # Success. Machine is on.119 # Success. Machine is on.
111 return 0120 return 0
@@ -116,13 +125,12 @@
116}125}
117126
118127
119# Power the machine off.128# Power the machine off amttool.
120power_off() {129amt_power_off() {
121 local attempts=
122 # Try several times. Power commands often fail the first time.130 # Try several times. Power commands often fail the first time.
123 for attempts in $(seq 0 10)131 for attempts in $(seq 0 10)
124 do132 do
125 if [ "$(query_state)" = 'off' ]133 if [ "$(amt_query_state)" = 'off' ]
126 then134 then
127 # Success. Machine is off.135 # Success. Machine is off.
128 return 0136 return 0
@@ -135,28 +143,181 @@
135}143}
136144
137145
146# Check that wsman is present.
147check_wsman_command() {
148 command -v wsman >/dev/null 2>&1 || { fail 2 "Missing wsman (wsmancli package)"; }
149}
150
151# Issue the wsman command.
152issue_wsman_command() {
153 POWER_TEMPLATE_HEAD='
154<p:RequestPowerStateChange_INPUT xmlns:p="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService">
155 <p:PowerState>'
156 POWER_TEMPLATE_TAIL='</p:PowerState>
157 <p:ManagedElement xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
158 xmlns:wsman="http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd">
159 <wsa:Address>http://schemas.xmlsoap.org/ws/2004/08/addressing/role/anonymous</wsa:Address>
160 <wsa:ReferenceParameters>
161 <wsman:ResourceURI>http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ComputerSystem</wsman:ResourceURI>
162 <wsman:SelectorSet>
163 <wsman:Selector Name="CreationClassName">CIM_ComputerSystem</wsman:Selector>
164 <wsman:Selector Name="Name">ManagedSystem</wsman:Selector>
165 </wsman:SelectorSet>
166 </wsa:ReferenceParameters>
167 </p:ManagedElement>
168</p:RequestPowerStateChange_INPUT>
169'
170 # Usage: issue_wsman_command on|off|restart|query
171 ACTION="invoke -a RequestPowerStateChange"
172 SCHEMA_URI='http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_PowerManagementService?SystemCreationClassName="CIM_ComputerSystem",SystemName="Intel(r) AMT",CreationClassName="CIM_PowerManagementService",Name="Intel(r) AMT Power Management Service"'
173 OPTS="--port 16992 --hostname $ip_address --username admin -p $power_pass -V -v"
174 case $1 in
175 on)
176 template=${POWER_TEMPLATE_HEAD}2${POWER_TEMPLATE_TAIL}
177 echo ${template} | wsman ${ACTION} "${SCHEMA_URI}" ${OPTS} -J -
178 ;;
179 off)
180 template=${POWER_TEMPLATE_HEAD}8${POWER_TEMPLATE_TAIL}
181 echo ${template} | wsman ${ACTION} "${SCHEMA_URI}" ${OPTS} -J -
182 ;;
183 restart)
184 template=${POWER_TEMPLATE_HEAD}10${POWER_TEMPLATE_TAIL}
185 echo ${template} | wsman ${ACTION} "${SCHEMA_URI}" ${OPTS} -J -
186 ;;
187 query)
188 ACTION="enumerate"
189 SCHEMA_URI='http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_AssociatedPowerManagementService'
190 OPTS="${OPTS} -o -j utf-8"
191 wsman ${ACTION} "${SCHEMA_URI}" ${OPTS}
192 ;;
193 *)
194 fail 2 "Unknown command issued to wsman"
195 ;;
196 esac
197}
198
199
200# Ask for node's power state: 'on' or 'off', via wsman.
201wsman_query_state() {
202 # Retry the state if it fails because it often fails the first time.
203 local state=
204 for attempts in $(seq 0 10)
205 do
206 state=$(issue_wsman_command query | grep "h:PowerState" | awk -F [\<\>] '{print $3}')
207 if [ -n "$state" ]
208 then
209 break
210 fi
211 # Wait 1 second between retries. AMT controllers are generally very
212 # light and may not be comfortable with more frequent queries.
213 sleep 1
214 done
215 case "$state" in
216 # There are a LOT of possible power states
217 # 1: Other 9: Power Cycle (Off - Hard)
218 # 2: On 10: Master Bus Reset
219 # 3: Sleep - Light 11: Diagnostic Interrupt (NMI)
220 # 4: Sleep - Deep 12: Off - Soft Graceful
221 # 5: Power Cycle (Off - Soft) 13: Off - Hard Graceful
222 # 6: Off - Hard 14: Master Bus Reset Graceful
223 # 7: Hibernate (Off - Soft) 15: Power Cycle (Off - Soft Graceful)
224 # 8: Off - Soft 16: Power Cycle (Off - Hard Graceful
225 # 17: Diagnostic Interrupt (INIT)
226
227 # These are all power states that indicate that the system is either ON or
228 # will resume function in an ON or Powered Up state (e.g. being power
229 # cycled currently)
230 [2,3,4,5,7,9,10,14,15,16])
231 echo 'on'
232 ;;
233 # These 4 states should leave system completely powered down
234 [6,8,12,13])
235 echo 'off'
236 ;;
237 *)
238 fail 1 "Got unknown power state from node: '$state'"
239 ;;
240 esac
241}
242
243
244# Power-cycle the machine via wsman, and boot it using the requested boot mode.
245wsman_restart() {
246 issue_wsman_command restart
247}
248
249
250# Power the machine on via wsman, and boot it using PXE.
251wsman_power_on() {
252 # Issue the wsman command to change power state
253 issue_wsman_command on
254 # Check power state several times. It usually takes a second or two to get
255 # the correct state.
256 for attempts in $(seq 0 10)
257 do
258 if [ "$(wsman_query_state)" = 'on' ]
259 then
260 # Success. Machine is on.
261 return 0
262 fi
263 sleep 1
264 done
265 fail 1 "Machine is not powering on. Giving up."
266}
267
268# Power the machine off via wsman.
269# Currently commented out because we need a way to power query the machines
270wsman_power_off() {
271 # Issue the wsman command to change power state
272 issue_wsman_command off
273 # Check power state several times. It usually takes a second or two to get
274 # the correct state
275 for attempts in $(seq 0 10)
276 do
277 if [ "$(wsman_query_state)" = 'off' ]
278 then
279 # Success. Machine is off.
280 return 0
281 fi
282 sleep 1
283 done
284 fail 1 "Machine is not powering off. Giving up."
285}
286
138main() {287main() {
139 check_bmc_host288 check_bmc_host
140 check_amt_command289 check_amt_command
290 # Check AMT version
291 check_amt_version
292 amt_version=$?
293 if [ ${amt_version} -gt 8 ]; then
294 # version > 8, use wsman
295 check_wsman_command
296 tool="wsman"
297 else
298 # Use amttool
299 tool="amt"
300 fi
301
141 case "${power_change}" in302 case "${power_change}" in
142 'on')303 'on')
143 if [ "$(query_state)" = 'on' ]304 if [ "${tool}_query_state" = 'on' ]
144 then305 then
145 # The machine is already up, so powering it up will do nothing.306 # The machine is already up, so powering it up will do nothing.
146 # Cycle the power instead.307 # Cycle the power instead.
147 restart308 ${tool}_restart
148 else309 else
149 power_on310 ${tool}_power_on
150 fi311 fi
151 ;;312 ;;
152 'off')313 'off')
153 if [ "$(query_state)" != 'off' ]314 if [ "${tool}_query_state" != 'off' ]
154 then315 then
155 power_off316 ${tool}_power_off
156 fi317 fi
157 ;;318 ;;
158 'query')319 'query')
159 query_state320 ${tool}_query_state
160 ;;321 ;;
161 *)322 *)
162 fail 1 "Unknown power command: '$1'"323 fail 1 "Unknown power command: '$1'"

Subscribers

People subscribed via source and target branches

to all changes: