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

[Xen-devel] [OSSTEST PATCH 02/32] PDU: pdu-msw: Split $read_oid and $write_oid



Some PDUs have a different OID space for turning ports on and off, to
the one for querying.  To make this easier to handle, split the
variable $oid into $read_oid and $write_oid.

Also move $baseoid settings earlier so that we can modify them with
command-line arguments.

No functional change in this patch.

Signed-off-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
 pdu-msw |   18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/pdu-msw b/pdu-msw
index 075f9b8..fc4d314 100755
--- a/pdu-msw
+++ b/pdu-msw
@@ -26,13 +26,14 @@ use strict qw(refs vars);
 use Net::SNMP;
 use Data::Dumper;
 
+my $community= 'private';
+my $baseoid= '.1.3.6.1.4.1.318.1.1.4.4.2.1';
+my $baseoid_write= "$baseoid.3";
+
 if (@ARGV<2 || @ARGV>3 || $ARGV[0] =~ m/^-/) { die "bad usage\n$usagemsg"; }
 
 our ($dnsname,$outlet,$action) = @ARGV;
 
-my $community= 'private';
-my $baseoid= '.1.3.6.1.4.1.318.1.1.4.4.2.1';
-
 my ($session,$error) = Net::SNMP->session(
                                           -hostname => $dnsname,
                                           -community => $community,
@@ -83,7 +84,8 @@ if ($outlet =~ m/^\d+$/) {
     ($useport,$usename)= @{ $found[0] };
 }
 
-my $oid= "$baseoid.3.$useport";
+my $read_oid= "$baseoid.3.$useport";
+my $write_oid= "$baseoid_write.$useport";
 
 my @map= (undef, qw(
                     on
@@ -94,9 +96,9 @@ my @map= (undef, qw(
                     delayed-reboot));
 
 sub show () {
-    my $got= $session->get_request($oid);
-    die "SNMP error reading $oid ".$session->error()." " unless $got;
-    my $val= $got->{$oid};
+    my $got= $session->get_request($read_oid);
+    die "SNMP error reading $read_oid ".$session->error()." " unless $got;
+    my $val= $got->{$read_oid};
     die unless $val;
     my $mean= $map[$val];
     die "$val ?" unless defined $mean;
@@ -110,7 +112,7 @@ sub set () {
                  $action =~ m/^(?:reboot)$/ ? 3 :
                  die "unknown action $action\n$usagemsg");
         
-    my $res= $session->set_request(-varbindlist => [ $oid, INTEGER, $valset ]);
+    my $res= $session->set_request(-varbindlist => [ $write_oid, INTEGER, 
$valset ]);
     die "SNMP set ".$session->error()." " unless $res;
 }
 
-- 
1.7.10.4


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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