[hptools] Utilisation directe de l'adresse mac plutôt que des secrets pour l'engineid
darcs-hash:20081021143624-ffbb2-c8e48773081e97d21998276a1990059c490d5739.gz
This commit is contained in:
parent
148a75af9f
commit
1a1dabf255
1 changed files with 16 additions and 2 deletions
|
@ -19,9 +19,13 @@ from os import system
|
||||||
from re import findall
|
from re import findall
|
||||||
from config import vlans
|
from config import vlans
|
||||||
|
|
||||||
|
path.append('/usr/scripts/gestion')
|
||||||
|
from ldap_crans import crans_ldap
|
||||||
|
cl = crans_ldap()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
path.append('/usr/scripts/gestion/secrets')
|
path.append('/usr/scripts/gestion/secrets')
|
||||||
from secrets import config_snmp_secrete, reconf_snmp, engineid
|
from secrets import config_snmp_secrete, reconf_snmp
|
||||||
except:
|
except:
|
||||||
# Si a pas le droit de lire config_snmp_secrete
|
# Si a pas le droit de lire config_snmp_secrete
|
||||||
# on va tenter de tout faire en snmpv1 et communauté public
|
# on va tenter de tout faire en snmpv1 et communauté public
|
||||||
|
@ -118,10 +122,20 @@ class snmp :
|
||||||
"""
|
"""
|
||||||
self.host = host
|
self.host = host
|
||||||
self.version = version
|
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")
|
||||||
|
|
||||||
|
# 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' :
|
if version == '1' or version == '2c' :
|
||||||
self.options = "-v %s -c '%s' %s " % ( version, community, host )
|
self.options = "-v %s -c '%s' %s " % ( version, community, host )
|
||||||
elif version =='3' :
|
elif version =='3' :
|
||||||
self.options = "-v 3 -e %s -u %s -a %s -A '%s' -l authNoPriv" % ( engineid[host.split('.',1)[0]], username, authentication_protocol, authentication_pass )
|
self.options = "-v 3 -e %s -u %s -a %s -A '%s' -l authNoPriv" % ( self._engineid, username, authentication_protocol, authentication_pass )
|
||||||
if privacy_pass :
|
if privacy_pass :
|
||||||
self.options += " -x DES -X '%s' -l authPriv" % privacy_pass
|
self.options += " -x DES -X '%s' -l authPriv" % privacy_pass
|
||||||
self.options += " %s " % host
|
self.options += " %s " % host
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue