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

[OSSTEST PATCH 06/16] PDU/MSW: Break out action_value()



This is going to be useful in a moment.

Signed-off-by: Ian Jackson <iwj@xxxxxxxxxxxxxx>
---
 pdu-msw | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/pdu-msw b/pdu-msw
index 58c33952..03b0f342 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";
 }
-- 
2.20.1




 


Rackspace

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