Misc s/func/certmaster/ replacements
[certmaster.git] / certmaster / minion / modules / snmp.py
1 # Copyright 2007, Red Hat, Inc
2 # James Bowes <jbowes@redhat.com>
3 # Seth Vidal modified command.py to be snmp.py
4 #
5 # This software may be freely redistributed under the terms of the GNU
6 # general public license.
7 #
8 # You should have received a copy of the GNU General Public License
9 # along with this program; if not, write to the Free Software
10 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
11
12 """
13 Abitrary command execution module for func.
14 """
15
16 import func_module
17 import sub_process
18 base_snmp_command = '/usr/bin/snmpget -v2c -Ov -OQ'
19
20 class Snmp(func_module.FuncModule):
21
22 version = "0.0.1"
23 api_version = "0.0.1"
24 description = "SNMP related calls through func."
25
26 def get(self, oid, rocommunity, hostname='localhost'):
27 """
28 Runs an snmpget on a specific oid returns the output of the call.
29 """
30 command = '%s -c %s %s %s' % (base_snmp_command, rocommunity, hostname, oid)
31
32 cmdref = sub_process.Popen(command.split(),stdout=sub_process.PIPE,stderr=sub_process.PIPE, shell=False)
33 data = cmdref.communicate()
34 return (cmdref.returncode, data[0], data[1])
35
36 #def walk(self, oid, rocommunity):
37
38 #def table(self, oid, rocommunity):