[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [OSSTEST PATCH 4/7] pdu-snmp: Refactor model handling
This makes it easier to see waht is going on and to add new model(s). No functional change. Signed-off-by: Ian Jackson <iwj@xxxxxxxxxxxxxx> --- pdu-snmp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/pdu-snmp b/pdu-snmp index a4918f53..74244145 100755 --- a/pdu-snmp +++ b/pdu-snmp @@ -28,15 +28,28 @@ 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"; +our ($baseoid, $baseoid_write, $baseoid_name, $baseoid_read); + +sub model_msw () { + # APC MasterSwitch + $baseoid= '.1.3.6.1.4.1.318.1.1.4.4.2.1'; + $baseoid_name= "$baseoid.4"; + $baseoid_read= "$baseoid.3"; + $baseoid_write= "$baseoid.3"; +} + +sub model_apc6 () { + # APC MasterSwitch protocol version 6 (?) + model_msw(); + $baseoid_write= '.1.3.6.1.4.1.318.1.1.12.3.3.1.1.4'; +} + +my $model_name = 'msw'; while (@ARGV && $ARGV[0] =~ m/^-/) { $_ = shift @ARGV; - if (m/^--apc6$/) { - $baseoid_write= '.1.3.6.1.4.1.318.1.1.12.3.3.1.1.4'; + if (m/^--(\w+)$/ && ${*::}{"model_$1"}) { + $model_name= $1; } else { die "$_ ?"; } @@ -44,6 +57,8 @@ while (@ARGV && $ARGV[0] =~ m/^-/) { if (@ARGV<2 || @ARGV>3 || $ARGV[0] =~ m/^-/) { die "bad usage\n$usagemsg"; } +${*::}{"model_$model_name"}->(); + our ($max_retries) = 16; # timeout = 0.05 * max_retries^2 our ($dnsname,$outlet,$action) = @ARGV; -- 2.20.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |