I guess the last one should have been patch 1, oh well live and learn. This builds on the last patch to allow for the configuration of the snmpget location. I tested the module, it continues to work as expected, no changes to the interface, yet. Does it make it simpler if I break these patches up? Or should it all be in one? Again, any advice is welcome. -Erinn
>From 0783440273c832e8d4bd1ecf73dada88cf6971c3 Mon Sep 17 00:00:00 2001 From: Erinn Looney-Triggs <erinn.looneytriggs@xxxxxxxxx> Date: Wed, 5 Oct 2011 14:57:38 -0800 Subject: [PATCH 4/4] Allowed the location of snmpget to be set in config file. --- func/minion/modules/snmp.py | 12 +++++++++--- 1 files changed, 9 insertions(+), 3 deletions(-) diff --git a/func/minion/modules/snmp.py b/func/minion/modules/snmp.py index 0f2bec5..6f7ae2d 100644 --- a/func/minion/modules/snmp.py +++ b/func/minion/modules/snmp.py @@ -20,7 +20,7 @@ try: except ImportError: from func.minion import sub_process as subprocess -base_snmp_command = '/usr/bin/snmpget -v2c -Ov -OQ' +from certmaster.config import BaseConfig, Option class Snmp(func_module.FuncModule): @@ -29,12 +29,18 @@ class Snmp(func_module.FuncModule): api_version = "0.0.1" description = "SNMP related calls through FUNC." + class Config(BaseConfig): + snmpget = Option('/usr/bin/snmpget') + def get(self, oid, rocommunity, hostname='localhost'): """ Runs an snmpget on a specific oid returns the output of the call. """ - command = '%s -c %s %s %s' % (base_snmp_command, rocommunity, - hostname, oid) + snmpget_options = '-v2c -Ov -OQ' + + command = '%s %s -c %s %s %s' % (self.options.snmpget, + snmpget_options, rocommunity, + hostname, oid) cmdref = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=False, -- 1.7.6.4
_______________________________________________ Func-list mailing list Func-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/func-list