bye bye secrets.py
On vire les dernières références à secrets.py via import direct de /etc/crans/secrets/secrets.py Ci-dessous une liste des trucs modifié et les raisons ./gestion/iscsi/nolslib.py:execfile("/etc/crans/secrets/nols.py") ./gestion/iscsi/slonlib.py:execfile("/etc/crans/secrets/slon.py") ./gestion/gen_confs/trigger.py:_args = ["ssh", "-4", "-i", "/etc/crans/secrets/trigger-generate" ] ./gestion/gen_confs/dhcpd_new.py: sys.path.append('/usr/scripts/gestion/secrets') ./gestion/gen_confs/dhcpd_new.py: from secrets import dhcp_omapi_keyname,dhcp_omapi_keys ./gestion/gen_confs/populate_sshFingerprint.py:sys.path.append('/etc/crans/secrets/') ./sip/sms_queuing:sys.path.insert(0, '/usr/scripts/gestion/secrets') ./sip/sms_queuing:from secrets import asterisk_sms_passwd ./sip/sip_multidial.py:sys.path.append('/etc/crans/secrets/') ./sip/sip_multidial.py:import secrets ./gestion/gen_confs/switchs.py: sys.path.append('/usr/scripts/gestion/secrets') ./gestion/gen_confs/switchs.py: from secrets import radius_key ./gestion/set_droits.sh: if [[ $1 = "$BASE/secrets" ]] ; then ./gestion/set_droits.sh: elif [[ $1 = "$BASE/secrets/secrets.py" ]] || [[ $1 = "$BASE/secrets/secrets.pyc" ]]; then ./admin/confmail/conf_mail.py:sys.path.append('/usr/scripts/gestion/secrets') ./admin/confmail/conf_mail.py:from secrets import secretConfirmMail
This commit is contained in:
parent
77e0b1daad
commit
92275f8948
11 changed files with 24 additions and 896 deletions
|
@ -1,208 +0,0 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
""" Génération de la configuration pour le dhcp
|
||||
|
||||
Copyright (C) Frédéric Pauget
|
||||
Licence : GPLv2
|
||||
"""
|
||||
|
||||
from iptools import AddrInNet, param
|
||||
from gen_confs import gen_config
|
||||
from ldap_crans import hostname
|
||||
|
||||
class dhcp(gen_config) :
|
||||
""" Génération du fichier de configuration pour dhcpd (DHCPD_CONF)
|
||||
Le fichier comporte une partie par réseau servi, chaque réseau
|
||||
servi doit être une clef du dictionnaire reseaux, la valeur correspondante
|
||||
est une chaine décrivant les options spécifiques à ce réseau.
|
||||
Les options communes sont celles de base_dhcp.
|
||||
|
||||
Chaque machines possède ensuite une entrée de la forme de host_template
|
||||
"""
|
||||
######################################PARTIE DE CONFIGURATION
|
||||
# Fichier à écire
|
||||
if hostname == 'ragnarok' :
|
||||
DHCPD_CONF='/etc/dhcpd.conf'
|
||||
else :
|
||||
DHCPD_CONF = '/etc/dhcp3/dhcpd.conf'
|
||||
|
||||
# Hotspot ENS plus utilisé...
|
||||
# elif hostname == 'ragnarok' :
|
||||
# On rajoute les IP dynamiques
|
||||
# base_conf = """
|
||||
# subnet 10.231.144.0 netmask 255.255.248.0 {
|
||||
# default-lease-time 900;
|
||||
# max-lease-time 900;
|
||||
# option subnet-mask 255.255.248.0;
|
||||
# option broadcast-address 10.231.151.255;
|
||||
# option routers 10.231.148.1;
|
||||
# option domain-name-servers 10.231.148.1;
|
||||
# option domain-name "ens-cachan.fr";
|
||||
# option option-119 "ens-cachan.fr";
|
||||
# option netbios-node-type 2;
|
||||
#
|
||||
# range dynamic-bootp 10.231.149.1 10.231.149.254;
|
||||
# }
|
||||
#"""
|
||||
|
||||
elif hostname == 'sable':
|
||||
# Options communes à toutes les réseaux servis
|
||||
base_conf="""
|
||||
# VLan accueil
|
||||
subnet 10.51.0.0 netmask 255.255.0.0 {
|
||||
range 10.51.0.10 10.51.255.200;
|
||||
# On n'a besoin que du dns ici (pour le portail captif)
|
||||
option domain-name-servers 10.51.0.1;
|
||||
}
|
||||
|
||||
# VLan isolement
|
||||
subnet 10.52.0.0 netmask 255.255.0.0 {
|
||||
range 10.52.0.10 10.52.255.200;
|
||||
option domain-name-servers 10.52.0.1;
|
||||
option routers 10.52.0.1;
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
else :
|
||||
base_conf = ''
|
||||
|
||||
# Réseaux servis avec leurs options spécifiques
|
||||
# if hostname == 'zamok':
|
||||
# reseaux = { '138.231.136.0/21' :
|
||||
#"""option routers 138.231.136.4;
|
||||
# option domain-name-servers 138.231.136.3, 138.231.136.9, 138.231.136.98;
|
||||
# option domain-name "crans.org";
|
||||
# option option-119 "crans.org wifi.crans.org";""" }
|
||||
if hostname == 'ragnarok':
|
||||
reseaux = { '138.231.144.0/21' :
|
||||
"""option routers 138.231.148.1;
|
||||
option domain-name-servers 138.231.148.1;
|
||||
option domain-name "crans.org";
|
||||
option option-119 "crans.org wifi.crans.org";
|
||||
option time-servers 138.231.136.3;
|
||||
option ntp-servers 138.231.136.3;
|
||||
option smtp-server 138.231.136.3;"""}
|
||||
|
||||
elif hostname == 'rouge':
|
||||
reseaux = { '138.231.136.0/21' :
|
||||
"""authoritative;
|
||||
option routers 138.231.136.4;
|
||||
option domain-name-servers 138.231.136.9, 138.231.136.98, 138.231.136.3;
|
||||
option domain-name "crans.org";
|
||||
option option-119 "crans.org wifi.crans.org";
|
||||
filename "pxelinux.0";
|
||||
option time-servers 138.231.136.3;
|
||||
option ntp-servers 138.231.136.3;
|
||||
option smtp-server 138.231.136.3;""" }
|
||||
|
||||
elif hostname == 'titanic':
|
||||
reseaux = {'10.2.9.0/24' :
|
||||
"""authoritative;
|
||||
option routers 10.2.9.1;
|
||||
option domain-name-servers 10.2.9.1;""" }
|
||||
|
||||
elif hostname == 'sable':
|
||||
# le vlan gratuit
|
||||
reseaux = {'10.42.0.0/16' :
|
||||
"""authoritative;
|
||||
option routers 10.42.0.1;
|
||||
option domain-name-servers 10.42.0.1;""" }
|
||||
|
||||
# Options communes à toutes les réseaux servis
|
||||
base_dhcp="""
|
||||
subnet %(network)s netmask %(netmask)s {
|
||||
default-lease-time 86400;
|
||||
option subnet-mask %(netmask)s;
|
||||
option broadcast-address %(broadcast)s;
|
||||
%(OPTIONS_RESEAU)s
|
||||
option ip-forwarding off;
|
||||
deny unknown-clients;
|
||||
%(HOSTs)s
|
||||
}
|
||||
"""
|
||||
|
||||
host_template="""
|
||||
host %(nom)s {
|
||||
hardware ethernet %(mac)s;
|
||||
fixed-address %(ip)s;
|
||||
option host-name "%(nom)s";
|
||||
}
|
||||
"""
|
||||
|
||||
host_template_ltsp_i386="""
|
||||
host %(nom)s {
|
||||
hardware ethernet %(mac)s;
|
||||
fixed-address %(ip)s;
|
||||
option host-name "%(nom)s";
|
||||
next-server 138.231.136.19;
|
||||
filename "/ltsp/pxelinux.0";
|
||||
option root-path "/opt/ltsp/i386";
|
||||
}
|
||||
"""
|
||||
|
||||
host_template_ltsp_powerpc="""
|
||||
host %(nom)s {
|
||||
hardware ethernet %(mac)s;
|
||||
fixed-address %(ip)s;
|
||||
option host-name "%(nom)s";
|
||||
next-server 138.231.136.98;
|
||||
filename "yaboot";
|
||||
option root-path "/opt/ltsp/powerpc";
|
||||
}
|
||||
"""
|
||||
|
||||
### Verbosité
|
||||
# Si =1 ralera (chaine warnings) si machines hors zone trouvée
|
||||
# Si =0 ralera seulement si réseau vide
|
||||
verbose = 1
|
||||
|
||||
# if hostname == 'zamok':
|
||||
# restart_cmd = '/etc/init.d/dhcp restart'
|
||||
if hostname == 'ragnarok':
|
||||
restart_cmd = 'pkill dhcpd ; sleep 1 ; dhcpd'
|
||||
elif hostname in ['rouge', 'titanic', 'sable'] :
|
||||
restart_cmd = '/etc/init.d/dhcp3-server restart'
|
||||
else:
|
||||
restart_cmd = 'true'
|
||||
|
||||
######################################FIN PARTIE DE CONFIGURATION
|
||||
def __str__(self) :
|
||||
return 'dhcp'
|
||||
|
||||
def _gen(self) :
|
||||
warnings =''
|
||||
|
||||
### Construction de la partie du fichier contenant les machines
|
||||
hosts={}
|
||||
|
||||
self.anim.iter=len(self.machines)
|
||||
for machine in self.machines :
|
||||
self.anim.cycle()
|
||||
t = 0
|
||||
for net in self.reseaux.keys() :
|
||||
if AddrInNet(machine.ip(),net) :
|
||||
host_template = self.host_template
|
||||
# variable pour remplir le template
|
||||
d = { 'nom' : machine.nom().split('.')[0] , 'mac' : machine.mac() , 'ip' : machine.ip() }
|
||||
try : hosts[net] += host_template % d
|
||||
except : hosts[net] = host_template % d
|
||||
t = 1
|
||||
|
||||
### Ecriture du fichier
|
||||
fd = self._open_conf(self.DHCPD_CONF,'#')
|
||||
fd.write(self.base_conf)
|
||||
for net, options in self.reseaux.items() :
|
||||
if not hosts.has_key(net) :
|
||||
warnings += u'Réseau %s ignoré : aucune machine à servir\n' % net
|
||||
continue
|
||||
d = param(net)
|
||||
d['OPTIONS_RESEAU'] = options
|
||||
d['HOSTs'] = hosts[net]
|
||||
|
||||
fd.write(self.base_dhcp % d)
|
||||
|
||||
fd.close()
|
||||
|
||||
return warnings
|
1
gestion/gen_confs/dhcpd.py
Symbolic link
1
gestion/gen_confs/dhcpd.py
Symbolic link
|
@ -0,0 +1 @@
|
|||
dhcpd_new.py
|
Loading…
Add table
Add a link
Reference in a new issue