[gestion/hptools] Correction de bugs
* Plus besoin de faire de requête ldap * Correction de la récupération du nombre de prises darcs-hash:20100211145443-bd074-6333f33e9efa98c59bbf34c5d6c8c18bfb290bdf.gz
This commit is contained in:
parent
fcdf94565f
commit
fce734a464
1 changed files with 9 additions and 1 deletions
|
@ -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 """
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue