]> xenbits.xensource.com Git - people/iwj/osstest.git/commitdiff
PDU: Refactor magic IPMI commands from xenuse module
authorIan Campbell <ian.campbell@citrix.com>
Wed, 11 Sep 2013 09:22:46 +0000 (10:22 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Wed, 11 Sep 2013 09:22:46 +0000 (10:22 +0100)
These are now in a separate ipmiextra module. The correct PowerMethod config
for a marilith machine is:
    ipmiextra on admin admin chassis bootdev pxe;xenuse

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

diff --git a/Osstest/PDU/ipmiextra.pm b/Osstest/PDU/ipmiextra.pm
new file mode 100644 (file)
index 0000000..d510e87
--- /dev/null
@@ -0,0 +1,58 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2013 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::ipmiextra;
+
+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, $when, $user, $pass, @opts) = @_;
+    return bless { Host => $ho,
+                  When => $when,
+                  User => $user,
+                  Pass => $pass,
+                  Opts => \@opts }, $class;
+}
+
+sub pdu_power_state {
+    my ($mo, $on) = @_;
+    my $onoff= $on ? "on" : "off";
+
+    system_checked("ipmitool",
+                  "-H", "$mo->{Host}{Name}-mgmt",
+                  "-U", $mo->{User},
+                  "-P", $mo->{Pass},
+                  @{$mo->{Opts}})
+       if $onoff eq $mo->{When} || $mo->{When} eq "both";
+}
+
+1;
index c06bc0c0e87322d91c9bed7f837c677b3a23bbfc..0860abdf1e518dd154027a774ca505acd7c4efcf 100644 (file)
@@ -1,5 +1,5 @@
 # This is part of "osstest", an automated testing framework for Xen.
-# Copyright (C) 2009-2013 Citrix Inc.
+# Copyright (C) 2013 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
@@ -35,11 +35,8 @@ BEGIN {
     @EXPORT_OK   = qw();
 }
 
-our $tty;
-
 sub new {
     my ($class, $ho) = @_;
-    logm("new xenuse PDU for $ho->{Name}");
     return bless { Host => $ho }, $class;
 }
 
@@ -47,13 +44,7 @@ sub pdu_power_state {
     my ($mo, $on) = @_;
     my $onoff= $on ? "on" : "off";
 
-    if ( $on ) {
-       #XXX this should be conditional
-       system_checked(qw(ipmitool -H), "$mo->{Host}{Name}-mgmt",qw(-U admin -P admin chassis bootdev pxe)) if $mo->{Host}{Flags}{'need-ipmi-pxe'};
-       system_checked(qw(xenuse --on), "$mo->{Host}{Name}");
-    } else {
-       system_checked(qw(xenuse --off), "$mo->{Host}{Name}");
-    }  
+    system_checked("xenuse", "--$onoff", "$mo->{Host}{Name}");
 }
 
 1;