diff --git a/gestion/tools/whokfet.py b/gestion/tools/whokfet.py index 3bef177d..f19ce15a 100755 --- a/gestion/tools/whokfet.py +++ b/gestion/tools/whokfet.py @@ -18,19 +18,19 @@ from whos import aff from os import system import xml.dom.minidom -def get_wifi_connected_client(): - f = open('/usr/scripts/var/wifi_xml/diomede.xml','r') +def get_wifi_connected_client(host): + f = open('/usr/scripts/var/wifi_xml/%s.xml' % host,'r') doc = xml.dom.minidom.parse(f) f.close() return [ mac.firstChild.nodeValue for mac in doc.getElementsByTagName('mac') ] def liste_kfet(): - sw = hpswitch('batb-0') + sw = hpswitch('backbone.adm.crans.org') db = crans_ldap() try: - macs = sw.show_prise_mac(47) #Devine quoi, c'est la prise de la kfet - # macs += sw.show_prise_mac(46) #Et la borne valhalla - macs +=get_wifi_connected_client() + macs = sw.show_prise_mac(45) #Devine quoi, c'est la prise de la kfet + macs +=get_wifi_connected_client('diomede') + macs +=get_wifi_connected_client('nanom5') except ConversationError: cprint("Impossible de communiquer avec le switch !", 'rouge') return @@ -39,9 +39,9 @@ def liste_kfet(): machines_crans = [] for mac in macs: fm = db.search("mac=%s" % mac) - if len(fm['machine']) != 0: + if fm['machine']: m = fm['machine'][0] - if len(fm['machineCrans']) == 0 and hasattr(m.proprietaire(),'droits') and len(m.proprietaire().droits()) != 0: + if not fm['machineCrans'] and hasattr(m.proprietaire(),'droits') and m.proprietaire().droits(): # On filtre ceux qui ont des droits et qui sont pas des machines crans machines.append(m) else: