Ca marche
darcs-hash:20070521184444-c992d-9cd4ef41bd31b10a7d2a54598c049ed4d1e4b83c.gz
This commit is contained in:
parent
961663c979
commit
ddf12f6a1a
1 changed files with 17 additions and 14 deletions
|
@ -10,26 +10,29 @@ Licence : GPLv2
|
||||||
|
|
||||||
|
|
||||||
from config import NETs
|
from config import NETs
|
||||||
from iptools import AddrInNet
|
from iptools import AddrInNet
|
||||||
|
|
||||||
noms_fichiers = {
|
|
||||||
'ip_fil' : '/usr/scripts/var/numeros_disponibles/ip_fixes',
|
|
||||||
'ip_wifi-adh' : '/usr/scripts/var/numeros_disponibles/ip_wifi-adh'
|
|
||||||
}
|
|
||||||
|
|
||||||
|
repertoire = '/usr/scripts/var/numeros_disponibles/'
|
||||||
|
|
||||||
|
def lister_ip_dispo(plage):
|
||||||
|
f = open(repertoire + 'ip_' + plage)
|
||||||
|
lignes = f.readlines()
|
||||||
|
liste = []
|
||||||
|
for l in lignes:
|
||||||
|
liste.append(l.strip())
|
||||||
|
return liste
|
||||||
|
|
||||||
def lister_ip_utilisees():
|
def lister_ip_utilisees():
|
||||||
liste = []
|
liste = []
|
||||||
from ldap_crans import crans_ldap
|
from ldap_crans import crans_ldap
|
||||||
db = crans_ldap()
|
db = crans_ldap()
|
||||||
r = db.search('mid=*')
|
r = db.search('mid=*')
|
||||||
machines = r['machineFixe'] + r['machineWifi'] + r['machineCrans']
|
machines = r['machineFixe'] + r['machineWifi'] + r['machineCrans'] + r['borneWifi']
|
||||||
for m in machines:
|
for m in machines:
|
||||||
liste.append(m.ip())
|
liste.append(m.ip())
|
||||||
return liste
|
return liste
|
||||||
|
|
||||||
def _update_ip(plage, fichier, occupees):
|
def update_ip(plage, occupees):
|
||||||
net = NETs[plage]
|
net = NETs[plage]
|
||||||
pool_ip = [] # Pool d'IP à tester
|
pool_ip = [] # Pool d'IP à tester
|
||||||
for ne in net:
|
for ne in net:
|
||||||
|
@ -57,17 +60,17 @@ def _update_ip(plage, fichier, occupees):
|
||||||
if ip not in occupees :
|
if ip not in occupees :
|
||||||
resultat += '%s\n' % ip
|
resultat += '%s\n' % ip
|
||||||
|
|
||||||
f = open(noms_fichiers[fichier],'w')
|
f = open(repertoire + 'ip_' + plage,'w')
|
||||||
f.write(resultat)
|
f.write(resultat)
|
||||||
f.close
|
f.close
|
||||||
|
|
||||||
def update_ip_fixe(occupees):
|
def update_ip_fixe(occupees):
|
||||||
_update_ip('fil', 'ip_fil', occupees)
|
update_ip('fil', 'ip_fil', occupees)
|
||||||
|
|
||||||
def update_ip_wifi_adh(occupees):
|
def update_ip_wifi_adh(occupees):
|
||||||
_update_ip('wifi-adh','ip_wifi-adh', occupees)
|
update_ip('wifi-adh','ip_wifi-adh', occupees)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
occupees = lister_ip_utilisees()
|
ip_occupees = lister_ip_utilisees()
|
||||||
update_ip_fixe(occupees)
|
for net in NETs.keys():
|
||||||
update_ip_wifi_adh(occupees)
|
update_ip(net, ip_occupees)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue