diff mbox series

[OSSTEST,3/7] pdu-snmp: Centralise base OIDs

Message ID 20201027134354.25561-4-iwj@xenproject.org (mailing list archive)
State New, archived
Headers show
Series Prepare for ServerTech PDUs | expand

Commit Message

Ian Jackson Oct. 27, 2020, 1:43 p.m. UTC
Do not hardcoode .3 and .4 in the main logic.

No functional change.

Signed-off-by: Ian Jackson <iwj@xenproject.org>
---
 pdu-snmp | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/pdu-snmp b/pdu-snmp
index 581a60b0..a4918f53 100755
--- a/pdu-snmp
+++ b/pdu-snmp
@@ -27,8 +27,11 @@  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";
+my $baseoid_name= "$baseoid.4";
+my $baseoid_read= "$baseoid.3";
 
 while (@ARGV && $ARGV[0] =~ m/^-/) {
     $_ = shift @ARGV;
@@ -52,7 +55,7 @@  die "SNMP error $error " unless defined $session;
 
 sub getname ($) {
     my ($port) = @_;
-    my $oid= "$baseoid.4.$port";
+    my $oid= "$baseoid_name.$port";
     my $res= $session->get_request($oid);
     if ($res) {
         my $name= $res->{$oid};
@@ -96,7 +99,7 @@  if ($outlet =~ m/^\d+$/) {
     ($useport,$usename)= @{ $found[0] };
 }
 
-my $read_oid= "$baseoid.3.$useport";
+my $read_oid= "$baseoid_read.$useport";
 my $write_oid= "$baseoid_write.$useport";
 
 my @map= (undef, qw(