]> xenbits.xensource.com Git - osstest.git/commitdiff
PDU/MSU: Retransmit on/off until PDU has changed
authorIan Jackson <iwj@xenproject.org>
Wed, 21 Oct 2020 15:14:17 +0000 (16:14 +0100)
committerIan Jackson <iwj@xenproject.org>
Thu, 22 Oct 2020 16:35:40 +0000 (17:35 +0100)
The main effect of this is that the transcript will actually show the
new PDU state.  Previously we would call show(), but APC PDUs would
normally not change immediately, so the transcript would show the old
state.

This also guards against an unresponsive PDU or a packet getting lost.
I don't think we have ever seen that.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
pdu-msw

diff --git a/pdu-msw b/pdu-msw
index 2d4ec967a0377b07d3408e49e5f873f53029acdd..c57f9f7c25217df90fe21b5fa63a90407bf2fd84 100755 (executable)
--- a/pdu-msw
+++ b/pdu-msw
@@ -41,6 +41,7 @@ while (@ARGV && $ARGV[0] =~ m/^-/) {
 
 if (@ARGV<2 || @ARGV>3 || $ARGV[0] =~ m/^-/) { die "bad usage\n$usagemsg"; }
 
+our ($max_retries) = 16; # timeout = 0.05 * max_retries^2
 our ($dnsname,$outlet,$action) = @ARGV;
 
 my ($session,$error) = Net::SNMP->session(
@@ -142,7 +143,21 @@ if (!defined $action) {
 } else {
     my $valset = action_value();
     print "was: "; show();
-    set($valset);
-    print "now: "; show();
-    print "^ note, PDUs often do not update returned info immediately\n";
+
+    my $retries = 0;
+    for (;;) {
+       set($valset);
+       sleep $retries * 0.1;
+       print "now: "; my $got = show();
+       if ($got eq $map[$valset]) { last; }
+       if ($map[$valset] !~ m{^(?:off|on)$}) {
+           print
+ "^ note, PDUs often do not update returned info immediately\n";
+           last;
+       }
+       if ($retries >= $max_retries) {
+           die "PDU does not seem to be changing state!\n";
+       }
+       $retries++;
+    }
 }