diff --git a/gestion/tools/who2b.py b/gestion/tools/who2b.py index d095f9f2..f4aeb91d 100755 --- a/gestion/tools/who2b.py +++ b/gestion/tools/who2b.py @@ -6,17 +6,23 @@ sys.path.append('/usr/scripts/gestion') from ldap_crans import crans_ldap from hptools import hpswitch, ConversationError from affich_tools import coul, cprint -import whos +from whos import aff def liste_machines_fixe(): - sw = hpswitch('batb-0') ## Quel switch il faut ? + sw = hpswitch('backbone') db = crans_ldap() try: - macs = sw.show_prise_mac(48): ## Quelle prise il faut ? + macs = sw.show_prise_mac(87) except ConversationError: print coul("Impossible de communiquer avec le switch !") + machines = [] for mac in macs: - machines = db.search("mac=%s" % mac) + m = db.search("mac=%s" % mac)['machine'] + if m: + machines.append(m[0]) + else: + print "Machine inconnue: %s" % mac + aff(machines) liste_machines_fixe()