From 5c2cae01ef5491647f3f3b20390ec3b84a5285f2 Mon Sep 17 00:00:00 2001 From: Nicolas Dandrimont Date: Thu, 21 Jan 2010 01:56:03 +0100 Subject: [PATCH] [hptools] Un peu plus de diagnostics... darcs-hash:20100121005603-ffbb2-8112a623215196f73881692a19479cf52b9f6df1.gz --- gestion/hptools.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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():