From fce734a464cc1679307295f18e62fff64bda504e Mon Sep 17 00:00:00 2001 From: Antoine Durand-Gasselin Date: Thu, 11 Feb 2010 15:54:43 +0100 Subject: [PATCH] [gestion/hptools] Correction de bugs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Plus besoin de faire de requête ldap * Correction de la récupération du nombre de prises darcs-hash:20100211145443-bd074-6333f33e9efa98c59bbf34c5d6c8c18bfb290bdf.gz --- gestion/hptools.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/gestion/hptools.py b/gestion/hptools.py index a6eb6423..f769bc20 100644 --- a/gestion/hptools.py +++ b/gestion/hptools.py @@ -127,6 +127,7 @@ class snmp : if version == '1' or version == '2c' : self.options = "-v %s -c '%s' %s " % ( version, community, host ) elif version =='3' : + self.fetch_engineid() self.options = "-v 3 -e %s -u %s -a %s -A '%s' -l authNoPriv" % ( self._engineid, username, authentication_protocol, authentication_pass ) if privacy_pass : self.options += " -x DES -X '%s' -l authPriv" % privacy_pass @@ -134,6 +135,13 @@ class snmp : else : raise ValueError('Version incorrecte') + def get_mac(self): + s, r = getstatusoutput("arp -a %s | perl -nle '{print $& if /00(:[0-9a-f]{2}){5}/}'" % self.host) + return r + + def fetch_engineid(self): + self._engineid = '0000000b000%s0' % self.get_mac().replace(':', '') + def __init_ldap(self): try: self._machine = cl.search("host=%(host)s" % {'host': self.host})["machineCrans"][0] @@ -313,7 +321,7 @@ class hpswitch : def nb_prises(self) : """ Retourne le nombre de prises du switch """ if self.__debug : self.__logDest.write("HP DEBUG : nb_prises()\n") - return int(findall(r'Switch 26([0-9]{2})', self.version())[0]) + return int(self.get('SNMPv2-SMI::mib-2.17.1.2.0')) def version(self) : """ Retourne la version du firmware du switch """