[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 6/7] Nested: Make Osstest::PDU::guest idempotent



These methods are supposed to succeed, silently, if the host is
already in the required power state.

Signed-off-by: Ian Jackson <Ian.Jackson@xxxxxxxxxxxxx>
---
 Osstest/PDU/guest.pm   |   13 +++++++++++--
 Osstest/TestSupport.pm |    3 ++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/Osstest/PDU/guest.pm b/Osstest/PDU/guest.pm
index b6bf9a1..b708af5 100755
--- a/Osstest/PDU/guest.pm
+++ b/Osstest/PDU/guest.pm
@@ -49,10 +49,19 @@ sub pdu_power_state {
     die "$child->{Name} ?" unless $parent;
 
     logm("power $child->{Name} nested on $parent->{Name} ".($on+0));
+
+    my $st = guest_get_state($parent, $child);
     if ($on) {
-       toolstack($parent)->create($child);
+       if ($st =~ m/^$guest_state_running_re$/o) {
+       } elsif (length($st)) { # exists but crashed or something ?
+           toolstack($parent)->destroy($child);
+       } else { # does not exist
+           toolstack($parent)->create($child);
+       }
     } else {
-       toolstack($parent)->destroy($child);
+       if (length($st)) {
+           toolstack($parent)->destroy($child);
+       }
     }
 }
 
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 6c08c6d..d1f7d36 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -97,7 +97,8 @@ BEGIN {
                       prepareguest_part_lvmdisk prepareguest_part_diskimg
                       prepareguest_part_xencfg
                       guest_umount_lv guest_await guest_await_dhcp_tcp
-                      guest_checkrunning target_check_ip guest_find_ether
+                      guest_checkrunning $guest_state_running_re
+                      target_check_ip guest_find_ether
                       guest_find_domid guest_check_up guest_check_up_quick
                       guest_get_state guest_await_reboot
                       guest_await_shutdown guest_await_destroy guest_destroy
-- 
1.7.10.4


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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.