[annuaire] On passe sur ula base de données PgSQL
darcs-hash:20100831065041-ffbb2-c44e28237d99ba472e0465ad88f1cd7149e3081d.gz
This commit is contained in:
parent
337905013d
commit
a1427076b5
15 changed files with 32 additions and 35 deletions
|
@ -12,7 +12,7 @@ Il affiche 3 colonnes :
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
from annuaires import reverse
|
from annuaires_pg import reverse
|
||||||
from ldap_crans import crans_ldap
|
from ldap_crans import crans_ldap
|
||||||
from affich_tools import tableau
|
from affich_tools import tableau
|
||||||
db = crans_ldap()
|
db = crans_ldap()
|
||||||
|
|
|
@ -10,7 +10,7 @@ prise [chambre] [on|off]
|
||||||
import sys, os
|
import sys, os
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
|
|
||||||
from annuaires import chbre_prises
|
from annuaires_pg import chbre_prises
|
||||||
from hptools import hpswitch
|
from hptools import hpswitch
|
||||||
|
|
||||||
if len(sys.argv)!=3 or not sys.argv[2] in ['on','off']:
|
if len(sys.argv)!=3 or not sys.argv[2] in ['on','off']:
|
||||||
|
@ -22,7 +22,7 @@ bat = sys.argv[1][0].lower()
|
||||||
chbre = sys.argv[1][1:].lower()
|
chbre = sys.argv[1][1:].lower()
|
||||||
|
|
||||||
# determination de la prise sur le switch
|
# determination de la prise sur le switch
|
||||||
prise = chbre_prises[bat][chbre]
|
prise = chbre_prises(bat, chbre)
|
||||||
switch = prise[0]
|
switch = prise[0]
|
||||||
prise = prise[1:]
|
prise = prise[1:]
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,8 @@ import sys, os
|
||||||
|
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
|
|
||||||
|
raise EnvironmentError("Ce script est *vieux*")
|
||||||
|
|
||||||
from annuaires import chbre_prises, reverse, bat_switchs
|
from annuaires import chbre_prises, reverse, bat_switchs
|
||||||
from affich_tools import cprint
|
from affich_tools import cprint
|
||||||
|
|
||||||
|
@ -60,7 +62,7 @@ prise doit être de la forme bnnn[g/d], ou nnn[g/d], dans ce dernier cas le bât
|
||||||
|
|
||||||
prise = prise[1:]
|
prise = prise[1:]
|
||||||
|
|
||||||
if chbre_prises[bat].get(chbre):
|
if chbre_prises(bat).get(chbre):
|
||||||
return 'chambre_deja_cablee'
|
return 'chambre_deja_cablee'
|
||||||
|
|
||||||
# dico = reverse(bat)
|
# dico = reverse(bat)
|
||||||
|
|
|
@ -19,14 +19,12 @@ import sys, os, commands, smtplib, tempfile, getopt
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
from hptools import hpswitch, sw_chbre
|
from hptools import hpswitch, sw_chbre
|
||||||
from ldap_crans import crans_ldap, BorneWifi
|
from ldap_crans import crans_ldap, BorneWifi
|
||||||
from annuaires import chbre_prises, uplink_prises, reverse, bat_manuels, all_switchs
|
from annuaires_pg import uplink_prises, reverse, bat_manuels, all_switchs, bat_switchs
|
||||||
from random import shuffle
|
from random import shuffle
|
||||||
from gen_confs import *
|
from gen_confs import *
|
||||||
from time import localtime
|
from time import localtime
|
||||||
import config
|
import config
|
||||||
|
|
||||||
from annuaires import bat_switchs
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
any
|
any
|
||||||
except NameError:
|
except NameError:
|
||||||
|
|
|
@ -13,7 +13,7 @@ from time import sleep
|
||||||
from popen2 import popen3
|
from popen2 import popen3
|
||||||
from sys import stderr, path
|
from sys import stderr, path
|
||||||
from commands import getstatusoutput
|
from commands import getstatusoutput
|
||||||
from annuaires import chbre_prises, all_switchs
|
from annuaires_pg import chbre_prises, all_switchs
|
||||||
from os.path import exists
|
from os.path import exists
|
||||||
from os import system
|
from os import system
|
||||||
import sys
|
import sys
|
||||||
|
@ -415,7 +415,7 @@ class sw_chbre(hpswitch) :
|
||||||
self.chbre = chbre
|
self.chbre = chbre
|
||||||
try :
|
try :
|
||||||
bat = chbre[0].lower()
|
bat = chbre[0].lower()
|
||||||
prise = chbre_prises[bat][chbre[1:]]
|
prise = chbre_prises(bat, chbre[1:])
|
||||||
self.prise_brute = prise
|
self.prise_brute = prise
|
||||||
self.switch = 'bat%s-%i.adm.crans.org' % (bat , int(prise[0]) )
|
self.switch = 'bat%s-%i.adm.crans.org' % (bat , int(prise[0]) )
|
||||||
if prise[-1] == '-' :
|
if prise[-1] == '-' :
|
||||||
|
|
|
@ -13,7 +13,8 @@ from socket import gethostname
|
||||||
import smtplib, re, os, random, string, time, sys, pwd
|
import smtplib, re, os, random, string, time, sys, pwd
|
||||||
import ldap, ldap.modlist, ldap_passwd
|
import ldap, ldap.modlist, ldap_passwd
|
||||||
|
|
||||||
import config, annuaires, iptools, cPickle, config_mail
|
import annuaires_pg as annuaires
|
||||||
|
import config, iptools, cPickle, config_mail
|
||||||
from chgpass import chgpass
|
from chgpass import chgpass
|
||||||
from affich_tools import coul, prompt, cprint
|
from affich_tools import coul, prompt, cprint
|
||||||
from email_tools import send_email
|
from email_tools import send_email
|
||||||
|
@ -875,7 +876,7 @@ class CransLdap:
|
||||||
"""
|
"""
|
||||||
Renvoie un proprietaire ou un adherent correspondant au
|
Renvoie un proprietaire ou un adherent correspondant au
|
||||||
login/ mot de passe (mot de passe facultatif)
|
login/ mot de passe (mot de passe facultatif)
|
||||||
"""
|
"""
|
||||||
recherche = self.search(("uid=%s" % uid), mode)
|
recherche = self.search(("uid=%s" % uid), mode)
|
||||||
proprio = None
|
proprio = None
|
||||||
|
|
||||||
|
@ -1949,9 +1950,9 @@ class Adherent(BaseProprietaire):
|
||||||
new = new.capitalize()
|
new = new.capitalize()
|
||||||
bat = new[0].lower()
|
bat = new[0].lower()
|
||||||
|
|
||||||
if bat in annuaires.chbre_prises.keys():
|
if bat in annuaires.bat_switchs:
|
||||||
# On a la liste des chambres
|
# On a la liste des chambres
|
||||||
chbres = annuaires.chbre_prises[bat].keys()
|
chbres = annuaires.chbre_prises(bat).keys()
|
||||||
if new[1:] not in chbres or len(new)<4 or not new[1:4].isdigit():
|
if new[1:] not in chbres or len(new)<4 or not new[1:4].isdigit():
|
||||||
chbres.sort()
|
chbres.sort()
|
||||||
aide = u"Chambre inconnue dans le batiment, les chambres valides sont :"
|
aide = u"Chambre inconnue dans le batiment, les chambres valides sont :"
|
||||||
|
@ -1965,7 +1966,6 @@ class Adherent(BaseProprietaire):
|
||||||
aide += c.ljust(5)
|
aide += c.ljust(5)
|
||||||
a = a+1
|
a = a+1
|
||||||
aide += u'\n'
|
aide += u'\n'
|
||||||
aide += u" " + annuaires.aide.get(bat, '')
|
|
||||||
raise ValueError(aide)
|
raise ValueError(aide)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
@ -2781,9 +2781,9 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3)
|
||||||
return decode(self._data.get('prise', ['N/A'])[0])
|
return decode(self._data.get('prise', ['N/A'])[0])
|
||||||
else:
|
else:
|
||||||
chbre = self.proprietaire().chbre()
|
chbre = self.proprietaire().chbre()
|
||||||
if chbre and chbre[0].lower() in annuaires.chbre_prises.keys():
|
if chbre and chbre[0].lower() in annuaires.bat_switchs:
|
||||||
try:
|
try:
|
||||||
return annuaires.chbre_prises[chbre[0].lower()][chbre[1:]]
|
return annuaires.chbre_prises(chbre[0], chbre[1:])
|
||||||
except:
|
except:
|
||||||
return 'N/A'
|
return 'N/A'
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ J.Benoist Leger
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from annuaires import all_switchs
|
from annuaires_pg import all_switchs
|
||||||
import pexpect
|
import pexpect
|
||||||
import getopt
|
import getopt
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -9,7 +9,7 @@ import threading
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
from ldap_crans import crans_ldap
|
from ldap_crans import crans_ldap
|
||||||
import whos
|
import whos
|
||||||
from annuaires import reverse, all_switchs
|
from annuaires_pg import all_switchs
|
||||||
from hptools import hpswitch
|
from hptools import hpswitch
|
||||||
|
|
||||||
# mise en forme d'une adresse mac
|
# mise en forme d'une adresse mac
|
||||||
|
|
|
@ -1152,13 +1152,10 @@ def __recherche() :
|
||||||
prise = arg.split('=')[1]
|
prise = arg.split('=')[1]
|
||||||
# Récupération de la chambre
|
# Récupération de la chambre
|
||||||
try:
|
try:
|
||||||
from annuaires import reverse
|
from annuaires_pg import reverse
|
||||||
chbre = reverse(prise[0].lower())[prise[1:]]
|
chbre = reverse(prise[0].lower(), prise[1:])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
try:
|
chbre=None
|
||||||
chbre = reverse(prise[0].lower())[prise[1:]+'-']
|
|
||||||
except KeyError:
|
|
||||||
chbre=None
|
|
||||||
|
|
||||||
if chbre:
|
if chbre:
|
||||||
if len(chbre) != 1 :
|
if len(chbre) != 1 :
|
||||||
|
|
|
@ -10,7 +10,7 @@ Frédéric Pauget, Nicolas Salles, Etienne Chové
|
||||||
import sys, os
|
import sys, os
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
from hptools import hpswitch
|
from hptools import hpswitch
|
||||||
from annuaires import all_switchs, uplink_prises
|
from annuaires_pg import all_switchs, uplink_prises
|
||||||
|
|
||||||
####################################################################
|
####################################################################
|
||||||
## Définition des chaines à audimater
|
## Définition des chaines à audimater
|
||||||
|
|
|
@ -98,7 +98,7 @@ for net in config.NETs:
|
||||||
hosts_plugins["munin"]["stats-ip_%s" % net] = "stats-ip_"
|
hosts_plugins["munin"]["stats-ip_%s" % net] = "stats-ip_"
|
||||||
|
|
||||||
# Stats de peuplement des bâtiments
|
# Stats de peuplement des bâtiments
|
||||||
for bat in annuaires.chbre_prises:
|
for bat in annuaires.bat_switchs:
|
||||||
if bat not in ('v',):
|
if bat not in ('v',):
|
||||||
hosts_plugins["munin"]["stats-batiment_%s" % bat] = "stats-batiment_"
|
hosts_plugins["munin"]["stats-batiment_%s" % bat] = "stats-batiment_"
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
import sys,os,string
|
import sys,os,string
|
||||||
|
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
from annuaires import reverse, chbre_prises, bat_switchs, all_switchs, uplink_prises
|
from annuaires_pg import reverse, chbre_prises, bat_switchs, all_switchs, uplink_prises
|
||||||
from hptools import hpswitch
|
from hptools import hpswitch
|
||||||
from ldap_crans import crans_ldap
|
from ldap_crans import crans_ldap
|
||||||
|
|
||||||
|
@ -127,6 +127,6 @@ else :
|
||||||
|
|
||||||
if BAT in BAT_CHBRES.keys() :
|
if BAT in BAT_CHBRES.keys() :
|
||||||
print "chbres.value %d" % BAT_CHBRES[BAT]
|
print "chbres.value %d" % BAT_CHBRES[BAT]
|
||||||
print "connues.value %d" % len(chbre_prises[BAT].keys())
|
print "connues.value %d" % len(chbre_prises(BAT).keys())
|
||||||
else :
|
else :
|
||||||
print "chbres.value %d" % len(chbre_prises[BAT].keys())
|
print "chbres.value %d" % len(chbre_prises(BAT).keys())
|
||||||
|
|
|
@ -10,7 +10,7 @@ Auteur :
|
||||||
import sys, os
|
import sys, os
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
from hptools import hpswitch
|
from hptools import hpswitch
|
||||||
from annuaires import all_switchs, bat_switchs, reverse, uplink_prises
|
from annuaires_pg import all_switchs, bat_switchs, reverse, uplink_prises
|
||||||
from ldap_crans import crans_ldap
|
from ldap_crans import crans_ldap
|
||||||
from affich_tools import anim, OK
|
from affich_tools import anim, OK
|
||||||
from email_tools import send_email
|
from email_tools import send_email
|
||||||
|
|
|
@ -30,7 +30,7 @@ import sys
|
||||||
sys.path.append('/usr/scripts/gestion')
|
sys.path.append('/usr/scripts/gestion')
|
||||||
|
|
||||||
from ldap_crans import crans_ldap
|
from ldap_crans import crans_ldap
|
||||||
from annuaires import chbre_prises, reverse
|
from annuaires_pg import chbre_prises, reverse
|
||||||
from affich_tools import cprint
|
from affich_tools import cprint
|
||||||
import sys, datetime
|
import sys, datetime
|
||||||
|
|
||||||
|
@ -65,7 +65,7 @@ def trouve_prise(chbre):
|
||||||
return chbre
|
return chbre
|
||||||
else:
|
else:
|
||||||
bat = chbre[0].lower()
|
bat = chbre[0].lower()
|
||||||
prise = bat + chbre_prises[bat][chbre[1:]]
|
prise = bat + chbre_prises(bat, chbre[1:])
|
||||||
if prise[-1] == '-':
|
if prise[-1] == '-':
|
||||||
prise = prise[:-1]
|
prise = prise[:-1]
|
||||||
return prise
|
return prise
|
||||||
|
|
|
@ -18,7 +18,7 @@ from sys import path
|
||||||
|
|
||||||
path.append('/usr/scripts/gestion')
|
path.append('/usr/scripts/gestion')
|
||||||
|
|
||||||
from annuaires import chbre_prises
|
from annuaires_pg import chbre_prises, bat_switchs
|
||||||
from affich_tools import *
|
from affich_tools import *
|
||||||
from ldap_crans import crans_ldap
|
from ldap_crans import crans_ldap
|
||||||
from ldap_crans import MachineCrans, MachineWifi, BorneWifi
|
from ldap_crans import MachineCrans, MachineWifi, BorneWifi
|
||||||
|
@ -61,7 +61,7 @@ def scan_bats(bats, annuaire=chbre_prises, verbose=False):
|
||||||
# On Commence par itérer sur chaque batiment :
|
# On Commence par itérer sur chaque batiment :
|
||||||
for bat in bats:
|
for bat in bats:
|
||||||
prises = dict()
|
prises = dict()
|
||||||
for chbre, prise in annuaire[bat].iteritems():
|
for chbre, prise in annuaire(bat).iteritems():
|
||||||
prises[prise] = chbre
|
prises[prise] = chbre
|
||||||
|
|
||||||
current_switch = -1
|
current_switch = -1
|
||||||
|
@ -232,7 +232,7 @@ if __name__ == "__main__":
|
||||||
|
|
||||||
if bats == 'all':
|
if bats == 'all':
|
||||||
# On récupère tous les bâtiments contenus dans l'annuaire :
|
# On récupère tous les bâtiments contenus dans l'annuaire :
|
||||||
lbats = chbre_prises.keys()
|
lbats = bat_switchs
|
||||||
else:
|
else:
|
||||||
# On génère une liste avec les bâtiments pour être propre
|
# On génère une liste avec les bâtiments pour être propre
|
||||||
lbats = [bat for bat in bats]
|
lbats = [bat for bat in bats]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue