All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ian Jackson <iwj@xenproject.org>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <iwj@xenproject.org>
Subject: [OSSTEST PATCH 4/7] pdu-snmp: Refactor model handling
Date: Tue, 27 Oct 2020 13:43:51 +0000	[thread overview]
Message-ID: <20201027134354.25561-5-iwj@xenproject.org> (raw)
In-Reply-To: <20201027134354.25561-1-iwj@xenproject.org>

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@xenproject.org>
---
 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



  parent reply	other threads:[~2020-10-27 13:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-27 13:43 [OSSTEST PATCH 0/7] Prepare for ServerTech PDUs Ian Jackson
2020-10-27 13:43 ` [OSSTEST PATCH 1/7] README: Fix a typo Ian Jackson
2020-10-27 13:43 ` [OSSTEST PATCH 2/7] pdu-snmp: Rename from pdu-msw Ian Jackson
2020-10-27 13:43 ` [OSSTEST PATCH 3/7] pdu-snmp: Centralise base OIDs Ian Jackson
2020-10-27 13:43 ` Ian Jackson [this message]
2020-10-27 13:43 ` [OSSTEST PATCH 5/7] pdu-snmp: Support ServerTech PDUs "Pro 1/2" aka "Sentry4" Ian Jackson
2020-10-27 13:43 ` [OSSTEST PATCH 6/7] PDU::snmp, PDU::msw: Rename from msw to snmp Ian Jackson
2020-10-27 13:43 ` [OSSTEST PATCH 7/7] pdu-snmp: Fix sleeping Ian Jackson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201027134354.25561-5-iwj@xenproject.org \
    --to=iwj@xenproject.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.