From 58d7b76ea3e2fdace361dbfe6d6a173fb779f8d8 Mon Sep 17 00:00:00 2001 From: Antoine Durand-Gasselin Date: Thu, 11 Feb 2010 13:02:38 +0100 Subject: [PATCH] =?UTF-8?q?[gestion/hptools.py]=20PasD=C3=A9sautomatisatio?= =?UTF-8?q?n=20de=20la=20requ=C3=AAte=20ldap=20lors=20de=20la=20cr=C3=A9at?= =?UTF-8?q?ion=20d'une=20classe=20snmp?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit darcs-hash:20100211120238-bd074-1ff13de72abc96c36dbda7ad6b446316d8a8da87.gz --- gestion/hptools.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gestion/hptools.py b/gestion/hptools.py index e9e8545a..a6eb6423 100644 --- a/gestion/hptools.py +++ b/gestion/hptools.py @@ -124,15 +124,6 @@ class snmp : self.host = host self.version = version - 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 : %s" % host) - - # l'engineid du switch n'est que sa mac avec quelques fioritures autour... - mac = self._machine.mac().replace(':', '') - self._engineid = '0000000b0000%(mac)s0' % {'mac': mac[:-1]} - if version == '1' or version == '2c' : self.options = "-v %s -c '%s' %s " % ( version, community, host ) elif version =='3' : @@ -143,6 +134,16 @@ class snmp : else : raise ValueError('Version incorrecte') + def __init_ldap(self): + try: + self._machine = cl.search("host=%(host)s" % {'host': self.host})["machineCrans"][0] + except IndexError: + 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(':', '') + self._engineid = '0000000b0000%(mac)s0' % {'mac': mac[:-1]} + def __exec(self,cmd) : s, r = getstatusoutput(cmd) if s :