]> xenbits.xensource.com Git - people/iwj/osstest.git/commitdiff
PowerMethod: New pause functionality
authorIan Jackson <ian.jackson@eu.citrix.com>
Fri, 29 Jun 2018 16:32:16 +0000 (16:32 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 4 Jul 2018 15:42:46 +0000 (16:42 +0100)
And, an abbreviation for invoking it: just writing numbers (or
<on>/<off> pair of numbers).

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
Osstest/PDU/pause.pm [new file with mode: 0644]
Osstest/TestSupport.pm

diff --git a/Osstest/PDU/pause.pm b/Osstest/PDU/pause.pm
new file mode 100644 (file)
index 0000000..b1160c0
--- /dev/null
@@ -0,0 +1,49 @@
+# 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::pause;
+
+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, $on, $off) = @_;
+    return bless [ $off, $on ], $class;
+}
+
+sub pdu_power_state {
+    my ($mo, $on) = @_;
+    my $delay = $mo->[!!$on];
+    logm("power: pdu operation pausing for ${delay}s");
+    sleep $delay;
+}
+
+1;
index ad877e2e864c47993f5df5904a2236dd8ef1ec71..004e6448f5ad72262651bf611cdc56357b0ca3a4 100644 (file)
@@ -922,6 +922,9 @@ sub power_cycle_host_setup ($) {
     foreach my $meth (split /\;\s*/, ($ho->{Power} // 'unsupported')) {
         if ($meth eq 'nest') {
             push @$methobjs, $meth;
+        } elsif ($meth =~ m{^(\d+)(?:/(\d+))$}) {
+            require Osstest::PDU::pause;
+            push @$methobjs, new Osstest::PDU::pause $ho, 'pause', $1, $2//$1;
         } else {
             push @$methobjs, get_host_method_object($ho,'PDU',$meth);
         }