|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [OSSTEST PATCH 07/26] power: PowerApproaches replaces $ho->{PowerMethobjs}
This new variable contains a list of different approaches to try.
* Move the meat of power_state into power_approach_invoke.
* power_state now looks for a single approach to try.
* The default for power_state is to pick the last approach in
the list, which by definition is supposed to be the most reliable.
* Currently there will only be one approach, `Only'.
No overall functional change other than to log messages.
Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
Osstest/TestSupport.pm | 35 +++++++++++++++++++++++++++++------
1 file changed, 29 insertions(+), 6 deletions(-)
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index fb6a407c..fa7c36e1 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -935,8 +935,15 @@ sub power_cycle_parse_method ($$) {
sub power_cycle_host_setup ($) {
my ($ho) = @_;
- $spec = ($ho->{Power} // 'unsupported');
- $ho->{PowerMethobjs} = power_cycle_parse_method($ho,$spec);
+ my $spec = ($ho->{Power} // 'unsupported');
+ # $ho->{PowerApproaches}[]{Name} see below
+ # $ho->{PowerApproaches}[]{MethObjs}[] each has ->pdu_power_state($on)
+ # `Name's are:
+ # Only Host only supports one method and this is it
+ $ho->{PowerApproaches} = {
+ Name => 'Only',
+ MethObjs => power_cycle_parse_method($ho, $spec),
+ };
}
sub power_reboot_attempts ($$$) {
@@ -978,10 +985,10 @@ sub power_cycle ($) {
power_state($ho, 1);
}
-sub power_state ($$) {
- my ($ho, $on) = @_;
- logm("power: setting $on for $ho->{Name}");
- my @methobjs = @{ $ho->{PowerMethobjs} };
+sub power_approach_invoke ($$$) {
+ my ($ho, $approach, $on) = @_;
+ logm("power: setting $on (using $approach->{Name}) for $ho->{Name}");
+ my @methobjs = @{ $approach->{MethObjs} };
if ($methobjs[0] eq 'nest') {
shift @methobjs;
@methobjs = reverse @methobjs if !$on;
@@ -991,6 +998,22 @@ sub power_state ($$) {
}
}
+sub power_state ($$;$) {
+ my ($ho, $on, $approach_re) = @_;
+ my @approaches = @{ $ho->{PowerApproaches} };
+ my $approach;
+ if (defined $approach_re) {
+ ($approach) = grep { $_->{Name} =~ qr{$approach_re} } @approaches
+ or die ("No matching power approach for $ho->{Name}".
+ " (wanted $approach_re) (available: ".
+ join(' ', map { $_->{Name} } @approaches).
+ ")\n");
+ } else {
+ $approach = $approaches[-1];
+ }
+ power_approach_invoke($ho,$approach,$on);
+}
+
#---------- host selection and properties ----------
sub selecthost ($);
--
2.11.0
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |