From: Ian Jackson Date: Wed, 21 Oct 2020 15:05:36 +0000 (+0100) Subject: PDU/MSW: Break out action_value() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=bc5367caff00a384dbe29f1b315fb25e9dfd7f12;p=osstest.git PDU/MSW: Break out action_value() This is going to be useful in a moment. Signed-off-by: Ian Jackson --- diff --git a/pdu-msw b/pdu-msw index 58c3395..03b0f34 100755 --- a/pdu-msw +++ b/pdu-msw @@ -121,13 +121,17 @@ sub show () { printf "pdu-msw $dnsname: #%s \"%s\" = %s\n", $useport, $usename, $mean; } -sub set () { +sub action_value () { my $delayadd= ($action =~ s/^delayed-// ? 3 : 0); my $valset= ($action =~ m/^(?:0|off)$/ ? 2 : $action =~ m/^(?:1|on)$/ ? 1 : $action =~ m/^(?:reboot)$/ ? 3 : die "unknown action $action\n$usagemsg"); - + return $valset; +} + +sub set ($) { + my ($valset) = @_; my $res= $session->set_request(-varbindlist => [ $write_oid, INTEGER, $valset ]); die "SNMP set ".$session->error()." " unless $res; } @@ -135,8 +139,9 @@ sub set () { if (!defined $action) { show(); } else { + my $valset = action_value(); print "was: "; show(); - set(); + set($valset); print "now: "; show(); print "^ note, PDUs often do not update returned info immediately\n"; }