From: Ian Jackson Date: Wed, 21 Oct 2020 15:14:17 +0000 (+0100) Subject: PDU/MSU: Retransmit on/off until PDU has changed X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=9497c17d320dfcff7cb9fd979a791709224bef6e;p=osstest.git PDU/MSU: Retransmit on/off until PDU has changed 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 --- diff --git a/pdu-msw b/pdu-msw index 2d4ec96..c57f9f7 100755 --- 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++; + } }