diff --git a/gestion/hptools.py b/gestion/hptools.py index 68e08cfc..ec416e91 100644 --- a/gestion/hptools.py +++ b/gestion/hptools.py @@ -224,7 +224,15 @@ class hpswitch : if self.__debug : self.__logDest.write("HP DEBUG : show_prise_mac(prise=%s)\n" % prise) try: data = self.walk('STATISTICS-MIB::hpSwitchPortFdbAddress.%d' % int(prise)) - return map(lambda x:findall('".*"',":".join(x.lower().split(' ')))[0][1:-2],data.values()) + macs = [] + for value in data.itervalues(): + mac = findall('".*"', value)[0][1:-1] + if ' ' in mac: + macs.append(":".join(mac.lower().split(" "))) + else: + macs.append(":".join("%02x" % ord(digit) for digit in mac)) + print macs + return macs except ValueError: # Pas de MAC trouvée return [] @@ -243,7 +251,10 @@ class hpswitch : # On cherche dans data la bonne adresse MAC for (onesnmp, onemac) in data.iteritems(): - if onemac[1:-2] == mac: + onemac = findall('".*"', onemac)[0][1:-1] + if ' ' not in onemac: + onemac = " ".join("%02x" % ord(digit) for digit in mac) + if onemac.startswith(mac): return int(onesnmp.split(".")[1]) # On a rien trouvé