diff --git a/gestion/whos.py b/gestion/whos.py index 5d49c5bf..f5872e76 100755 --- a/gestion/whos.py +++ b/gestion/whos.py @@ -45,9 +45,10 @@ try: except: pass -from ldap_crans import is_actif , crans_ldap, ann_scol, crans +from ldap_crans import is_actif , crans_ldap, ann_scol, crans, hostname from affich_tools import * from hptools import sw_chbre +import popen2 limit_aff_details = 1 limit_aff_historique = 4 @@ -426,6 +427,19 @@ def machine_details(machine) : else: f += coul(u'borne éteinte','rouge') f += '\n' + # S'il y a des clients, on les liste + clients = borne_clients(machine.nom()) + if clients: + f += coul(u'Clients : \n','gras') + for client in clients: + # On va chercher le nom correspondant à l'adresse MAC + res = base.search("mac=%s" % client)['machine'] + if not res: + client_nom = '????' + else: + client_nom = ", ".join([x.nom() for x in res]) + f += u'\t%s (%s)\n' % (client, client_nom) + if aff_ipsec and machine.ipsec() : f += coul(u'Clef IPsec : ','gras') + machine.ipsec() @@ -579,6 +593,22 @@ def borne_etat(borne) : except: return False +def borne_clients(borne) : + """Renvoie la liste des adresses MAC associées à la borne""" + macs = [] + # Sur nectaris uniquement dans un premier temps + if hostname == 'nectaris': + try: + wl = popen2.Popen3("ssh -o StrictHostKeyChecking=no -i /etc/wifi/ssh/wifi root@%s wl assoclist 2> /dev/null" % borne) + wl.tochild.close() + for line in wl.fromchild.readlines(): + # Chaque ligne est de la forme + # assoclist 00:11:22:33:44:55 + macs.append(line.split(" ")[1].strip()) + except: + pass + return macs + def prise_etat(chbre) : f = '' try :