For nested host/guest, its power on/off method shall be
its host invoke $(toolstack)->create/destroy method.
---
 Osstest/PDU/guest.pm   | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++
 Osstest/TestSupport.pm |  3 +++
 2 files changed, 66 insertions(+)
 create mode 100755 Osstest/PDU/guest.pm

diff --git a/Osstest/PDU/guest.pm b/Osstest/PDU/guest.pm
new file mode 100755
index 0000000..8b4b9f5
--- /dev/null
+++ b/Osstest/PDU/guest.pm
@@ -0,0 +1,63 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2015 Intel.
+# 
+# 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::guest;
+
+use strict;
+use warnings;
+use Switch;
+
+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) = @_;
+    return bless { Host => $ho }, $class;
+}
+
+sub pdu_power_state {
+    my ($mo, $on) = @_;
+    my $onoff= $on ? "on" : "off";
+    my $ho;
+    my $gho;
+
+    switch ($mo->{Host}{Ident}){
+       case /l1/       {($ho,$gho)=ts_get_host_guest('host',$mo->{Host}{Name})}
+       case /l2/       {($ho,$gho)=ts_get_host_guest('l1',$mo->{Host}{Name})}
+       else            {logm("Unkown Host Ident $mo->{Host}{Ident}");die;}
+    }
+
+    logm("$ho->{Name} going to power $onoff $gho->{Name}");
+    switch ($onoff){
+       case /on/       {toolstack($ho)->create($gho)}
+       case /off/      {toolstack($ho)->destroy($gho)}
+    }
+}
+
+1;
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 1768c5e..06a0c57 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -878,6 +878,9 @@ sub selecthost ($) {
     $ho->{Ether}= get_host_property($ho,'ether');
     $ho->{DiskDevice}= get_host_property($ho,'disk-device');
     $ho->{Power}= get_host_property($ho,'power-method');
+    if ($ho->{Ident} =~ m/l1|l2/) {
+       $ho->{Power} = 'guest';
+    }
 
     $mhostdb->default_methods($ho);
 
-- 
1.8.3.1


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

Reply via email to