Amlioration de la lisibilit.
darcs-hash:20070928133838-68412-9f7147534d8da0bbe861c4946b4a668291991b65.gz
This commit is contained in:
parent
3d624f7347
commit
f910406096
1 changed files with 8 additions and 5 deletions
|
@ -10,7 +10,8 @@ sys.path.append('/usr/scripts/gestion')
|
||||||
from ldap_crans import crans_ldap
|
from ldap_crans import crans_ldap
|
||||||
import whos
|
import whos
|
||||||
from annuaires import reverse, all_switchs
|
from annuaires import reverse, all_switchs
|
||||||
from hptools import hpswitch
|
from hptools import hpswitch, ConversationError
|
||||||
|
from affich_tools import coul, cprint
|
||||||
|
|
||||||
# mise en forme d'une adresse mac
|
# mise en forme d'une adresse mac
|
||||||
def format_mac(unformated_mac):
|
def format_mac(unformated_mac):
|
||||||
|
@ -32,7 +33,10 @@ class interroge_switch (threading.Thread) :
|
||||||
prise = None
|
prise = None
|
||||||
iteration = 3
|
iteration = 3
|
||||||
while (prise==None) & (iteration > 0):
|
while (prise==None) & (iteration > 0):
|
||||||
prise = sw.where_is_mac(self.mac)
|
try:
|
||||||
|
prise = sw.where_is_mac(self.mac)
|
||||||
|
except ConversationError:
|
||||||
|
self.reponse = coul("Impossible de communiquer avec %s !" % self.switch, "jaune")
|
||||||
iteration = iteration-1
|
iteration = iteration-1
|
||||||
if (prise != None):
|
if (prise != None):
|
||||||
nom=sw.nom(None,prise)
|
nom=sw.nom(None,prise)
|
||||||
|
@ -66,8 +70,6 @@ def trace_machine(mac, affiche_uplinks=False):
|
||||||
for t in tableau:
|
for t in tableau:
|
||||||
t.join()
|
t.join()
|
||||||
|
|
||||||
resultat = u'Traçage de %s...\n' % mac
|
|
||||||
|
|
||||||
tracage = u''
|
tracage = u''
|
||||||
for t in tableau:
|
for t in tableau:
|
||||||
if t.reponse:
|
if t.reponse:
|
||||||
|
@ -75,12 +77,13 @@ def trace_machine(mac, affiche_uplinks=False):
|
||||||
if tracage == u'':
|
if tracage == u'':
|
||||||
tracage = u"Adresse MAC inconnue des switchs\n"
|
tracage = u"Adresse MAC inconnue des switchs\n"
|
||||||
|
|
||||||
return (resultat + tracage)
|
return tracage
|
||||||
|
|
||||||
|
|
||||||
# on interroge les switchs et on fait un whos sur la mac
|
# on interroge les switchs et on fait un whos sur la mac
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
mac = format_mac(sys.argv[1])
|
mac = format_mac(sys.argv[1])
|
||||||
affiche_uplinks = len(sys.argv) > 2 and bool(sys.argv[2])
|
affiche_uplinks = len(sys.argv) > 2 and bool(sys.argv[2])
|
||||||
|
cprint(u'Traçage de %s...\n' % mac, "rouge")
|
||||||
print trace_machine(mac, affiche_uplinks)
|
print trace_machine(mac, affiche_uplinks)
|
||||||
print system('/usr/scripts/gestion/whos.py -a mac=%s' % mac)
|
print system('/usr/scripts/gestion/whos.py -a mac=%s' % mac)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue