diff --git a/gestion/hptools.py b/gestion/hptools.py index 8d64edb4..ac1609da 100644 --- a/gestion/hptools.py +++ b/gestion/hptools.py @@ -16,6 +16,7 @@ from commands import getstatusoutput from annuaires import chbre_prises, all_switchs from os.path import exists from os import system +import sys from re import findall from config import vlans @@ -126,7 +127,7 @@ class snmp : try: self._machine = cl.search("host=%(host)s" % {'host': host})["machineCrans"][0] except IndexError: - raise ValueError(u"Cette machine n'est pas un switch du Cr@ns") + raise ValueError(u"Cette machine n'est pas un switch du Cr@ns : %s" % host) # l'engineid du switch n'est que sa mac avec quelques fioritures autour... mac = self._machine.mac().replace(':', '') @@ -246,7 +247,11 @@ class hpswitch : mac[6:8], mac[8:10], mac[10:12]) # On interroge le switch - data = self.walk('STATISTICS-MIB::hpSwitchPortFdbAddress'); + try: + data = self.walk('STATISTICS-MIB::hpSwitchPortFdbAddress') + except ValueError: + print >> sys.stderr, "Le switch %s fait du caca..." % self.switch + return None # On cherche dans data la bonne adresse MAC for (onesnmp, onemac) in data.iteritems():