[hptools] On contourne les macs indélicates (genre "ord(r):ord(a):ord(d):ord(i):ord(u):ord(s)")
Ignore-this: 41ab1e2013da859fbbe7965565191e77 darcs-hash:20091011024124-ffbb2-9d9b652c0b9aee1a68acc16c1b8dd0cd975b27b9.gz
This commit is contained in:
parent
36c523e640
commit
b8392ae781
1 changed files with 13 additions and 2 deletions
|
@ -224,7 +224,15 @@ class hpswitch :
|
||||||
if self.__debug : self.__logDest.write("HP DEBUG : show_prise_mac(prise=%s)\n" % prise)
|
if self.__debug : self.__logDest.write("HP DEBUG : show_prise_mac(prise=%s)\n" % prise)
|
||||||
try:
|
try:
|
||||||
data = self.walk('STATISTICS-MIB::hpSwitchPortFdbAddress.%d' % int(prise))
|
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:
|
except ValueError:
|
||||||
# Pas de MAC trouvée
|
# Pas de MAC trouvée
|
||||||
return []
|
return []
|
||||||
|
@ -243,7 +251,10 @@ class hpswitch :
|
||||||
|
|
||||||
# On cherche dans data la bonne adresse MAC
|
# On cherche dans data la bonne adresse MAC
|
||||||
for (onesnmp, onemac) in data.iteritems():
|
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])
|
return int(onesnmp.split(".")[1])
|
||||||
|
|
||||||
# On a rien trouvé
|
# On a rien trouvé
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue