[whokfet] elle est branchée au backbone
This commit is contained in:
parent
a8ce357228
commit
f6af9c9a0e
1 changed files with 8 additions and 8 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue