]> xenbits.xensource.com Git - osstest.git/commitdiff
Implement direct IPMI power control. flight-27153 flight-27158 flight-27159 flight-27160 flight-27161 flight-27164 flight-27165 flight-27166 flight-27168 flight-27169 flight-27171 flight-27173 flight-27201 flight-27203 flight-27218 flight-27248 flight-27249 flight-27280 flight-27282 flight-27293 flight-27300 flight-27315 flight-27316 flight-27321 flight-27330 flight-27352 flight-27357 flight-27358 flight-27380 flight-27391 flight-27392 flight-27393 flight-27394 flight-27395 flight-27396 flight-27401 flight-27402 flight-27403 flight-27404 flight-27405 flight-27406 flight-27407 flight-27408 flight-27409 flight-27410 flight-27411 flight-27412 flight-27413 flight-27414 flight-27415 flight-27416 flight-27417 flight-27418 flight-27419 flight-27420 flight-27421 flight-27422 flight-27423 flight-27424 flight-27425 flight-27426 flight-27427 flight-27428 flight-27429 flight-27430 flight-27431 flight-27432 flight-27433 flight-27434 flight-27435 flight-27436 flight-27437 flight-27438 flight-27439 flight-27440 flight-27441 flight-27442 flight-27443 flight-27444 flight-27445 flight-27446 flight-27447 flight-27448 flight-27449 flight-27450 flight-27452 flight-27456 flight-27462 flight-27463 flight-27464 flight-27465 flight-27466 flight-27467 flight-27468 flight-27469 flight-27473 flight-27474 flight-27475 flight-27476 flight-27477 flight-27478 flight-27479 flight-27480 flight-27481 flight-27482
authorIan Campbell <ian.campbell@citrix.com>
Mon, 16 Jun 2014 08:51:21 +0000 (09:51 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 16 Jun 2014 10:06:56 +0000 (11:06 +0100)
The xenuse module currently used to control some machines (specifically the ARM
marilith machines) is unreliable and subject to breakages on the xenrt server
side.

Since xenuse/xenrt is just wrapping IPMI for these machines implement direct
control via a new Osstest::PDI::impi module.

This is distinct from the existing impiextra (arbitrary ipmi commands on power
status change) because IPMI power control is not idempotent, therefore it is
necessary to query the current status before turning the machine on or off.

After this change the correct power method for a marilith node is:
    ipmiextra on marilith-n0-mgmt.uk.xensource.com <user> <pass> chassis bootdev pxe;ipmi marilith-n0-mgmt.uk.xensource.com <user> <pass>

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
---
Ian, when we discussed this on IRC you expressed a preference for using
freeipmitools, but since the existing ipmiextra module uses ipmitool I figured
it would be better to be consistent.

Osstest/PDU/ipmi.pm [new file with mode: 0644]

diff --git a/Osstest/PDU/ipmi.pm b/Osstest/PDU/ipmi.pm
new file mode 100644 (file)
index 0000000..bff1143
--- /dev/null
@@ -0,0 +1,67 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2014 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+package Osstest::PDU::ipmi;
+
+use strict;
+use warnings;
+
+use Osstest;
+use Osstest::TestSupport;
+use IO::File;
+
+BEGIN {
+    use Exporter ();
+    our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+    $VERSION     = 1.00;
+    @ISA         = qw(Exporter);
+    @EXPORT      = qw();
+    %EXPORT_TAGS = ( );
+
+    @EXPORT_OK   = qw();
+}
+
+sub new {
+    my ($class, $ho, $methname, $mgmt, $user, $pass, @opts) = @_;
+    return bless { Host => $ho,
+                  Mgmt => $mgmt,
+                  User => $user,
+                  Pass => $pass,
+                  Opts => \@opts }, $class;
+}
+
+sub pdu_power_state {
+    my ($mo, $on) = @_;
+    my $onoff= $on ? "on" : "off";
+
+    my $cmd = "ipmitool -H $mo->{Mgmt} -U $mo->{User} -P $mo->{Pass}";
+
+    my $status = `$cmd power status`
+       or die "Cannot retrieve current power status";
+    chomp($status);
+    logm("$status (want $onoff)");
+    $status =~ s/^Chassis Power is (on|off)$/$1/
+       or die "Cannot parse current power status: $status";
+
+    if ( $status eq $onoff ) {
+       logm("Current power status is correct");
+       return;
+    }
+
+    system_checked("$cmd power $onoff")
+}
+
+1;