[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
|
from os import system
|
||||||
import xml.dom.minidom
|
import xml.dom.minidom
|
||||||
|
|
||||||
def get_wifi_connected_client():
|
def get_wifi_connected_client(host):
|
||||||
f = open('/usr/scripts/var/wifi_xml/diomede.xml','r')
|
f = open('/usr/scripts/var/wifi_xml/%s.xml' % host,'r')
|
||||||
doc = xml.dom.minidom.parse(f)
|
doc = xml.dom.minidom.parse(f)
|
||||||
f.close()
|
f.close()
|
||||||
return [ mac.firstChild.nodeValue for mac in doc.getElementsByTagName('mac') ]
|
return [ mac.firstChild.nodeValue for mac in doc.getElementsByTagName('mac') ]
|
||||||
|
|
||||||
def liste_kfet():
|
def liste_kfet():
|
||||||
sw = hpswitch('batb-0')
|
sw = hpswitch('backbone.adm.crans.org')
|
||||||
db = crans_ldap()
|
db = crans_ldap()
|
||||||
try:
|
try:
|
||||||
macs = sw.show_prise_mac(47) #Devine quoi, c'est la prise de la kfet
|
macs = sw.show_prise_mac(45) #Devine quoi, c'est la prise de la kfet
|
||||||
# macs += sw.show_prise_mac(46) #Et la borne valhalla
|
macs +=get_wifi_connected_client('diomede')
|
||||||
macs +=get_wifi_connected_client()
|
macs +=get_wifi_connected_client('nanom5')
|
||||||
except ConversationError:
|
except ConversationError:
|
||||||
cprint("Impossible de communiquer avec le switch !", 'rouge')
|
cprint("Impossible de communiquer avec le switch !", 'rouge')
|
||||||
return
|
return
|
||||||
|
@ -39,9 +39,9 @@ def liste_kfet():
|
||||||
machines_crans = []
|
machines_crans = []
|
||||||
for mac in macs:
|
for mac in macs:
|
||||||
fm = db.search("mac=%s" % mac)
|
fm = db.search("mac=%s" % mac)
|
||||||
if len(fm['machine']) != 0:
|
if fm['machine']:
|
||||||
m = fm['machine'][0]
|
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
|
# On filtre ceux qui ont des droits et qui sont pas des machines crans
|
||||||
machines.append(m)
|
machines.append(m)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue