[dhcp_new,generate,switchs,ldap_crans] On ajoute dhcp à générate et son ip dans dhcp-snooping, on active le dhcp-nopping sur tous les vlan.

Ignore-this: c3a151a94e71f2bb4761a9ecc9707bcf

darcs-hash:20121025212409-3a55a-cd8c2857721d655c5dd67124a380fbe7eb5161b3.gz
This commit is contained in:
Valentin Samir 2012-10-25 23:24:09 +02:00
parent f33d5aa50b
commit ce443b9bfa
4 changed files with 39 additions and 7 deletions

View file

@ -32,12 +32,19 @@ class dhcp(gen_config) :
elif hostname == 'gordon':
restart_cmd = '/etc/init.d/isc-dhcp-server restart'
reseaux = { '138.231.144.0/21' : '/etc/dhcp3/generated/wifi.liste' }
elif hostname == 'dhcp':
restart_cmd = '/etc/init.d/isc-dhcp-server restart'
reseaux = { '138.231.136.0/21' : '/etc/dhcp3/generated/adherents.liste',
'10.42.0.0/16' : '/etc/dhcp3/generated/gratuit.liste',
'10.2.9.0/24' : '/etc/dhcp3/generated/appartements.liste',
'138.231.144.0/21' : '/etc/dhcp3/generated/wifi.liste' }
host_template = """
host %(nom)s {
hardware ethernet %(mac)s;
fixed-address %(ip)s;
option host-name "%(nom)s";
option host-name "%(host)s";
}
"""
@ -45,7 +52,7 @@ class dhcp(gen_config) :
host %(nom)s {
hardware ethernet %(mac)s;
fixed-address %(ip)s;
option host-name "%(nom)s";
option host-name "%(host)s";
next-server 138.231.136.98;
filename "yaboot";
option root-path "/opt/ltsp/powerpc";
@ -77,7 +84,8 @@ class dhcp(gen_config) :
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() }
#d = { 'nom' : machine.nom().split('.')[0] , 'mac' : machine.mac() , 'ip' : machine.ip() }
d = { 'nom' : machine.nom() , 'host' : machine.nom().split('.')[0],'mac' : machine.mac() , 'ip' : machine.ip() }
try :
hosts[net] += host_template % d
except : hosts[net] = host_template % d

View file

@ -246,6 +246,11 @@ class dyson(base_reconfigure):
from gen_confs.dhcpd_new import dhcp
self._do(dhcp(), self._machines())
class dhcp(base_reconfigure):
def dhcp(self):
from gen_confs.dhcpd_new import dhcp
self._do(dhcp(), self._machines())
class sable(base_reconfigure):
def dhcp(self):
from gen_confs.dhcpd_new import dhcp

View file

@ -143,10 +143,16 @@ no stack
"""
dhcp_snooping_template = """;------------------------------------------------------- DHCP Snooping
dhcp-snooping vlan %(vlan_adherent)s
dhcp-snooping vlan %(vlan_adherent)s %(vlan_wifi)s %(vlan_accueil)s %(vlan_gratuit)s %(vlan_isolement)s %(vlan_appts)s
dhcp-snooping trust %(uplinks)s
no dhcp-snooping trust %(non_uplinks)s
dhcp-snooping authorized-server %(dhcp)s
dhcp-snooping authorized-server %(dhcp-1)s
dhcp-snooping authorized-server %(dhcp-3)s
dhcp-snooping authorized-server %(dhcp-6)s
dhcp-snooping authorized-server %(dhcp-7)s
dhcp-snooping authorized-server %(dhcp-9)s
dhcp-snooping authorized-server %(dhcp-21)s
; Activation
dhcp-snooping"""
@ -162,7 +168,15 @@ exit
rad_template = "radius-server host %s\n"
# Serveur DHCP du vlan par défaut
dhcp_server = "138.231.136.9"
dhcp_servers = { '0':'138.231.136.9',
'1':'138.231.136.34',
'3':'138.231.148.34',
'6':'10.42.0.34',
'7':'10.51.0.34',
'9':'10.52.0.34',
'21':'10.2.9.34'
}
def __init__(self,truc):
""" truc est soit :
@ -279,7 +293,7 @@ exit
# Batiment et numéro du switch
bat = switch[3].lower()
sw_num = int(switch[5])
dhcp_server = self.dhcp_server
dhcp_servers = self.dhcp_servers
# Conf radius
sys.path.append('/usr/scripts/gestion/secrets')
from secrets import radius_key
@ -294,7 +308,9 @@ exit
params = { 'switch' : switch, 'bat' : bat.upper() ,
'radius_key' : radius_key ,
'radius-serveurs' : rad[:-1] % tuple(self.rad_servs),
'dhcp': dhcp_server}
'dhcp': dhcp_servers['0']}
for i in dhcp_servers.keys():
params['dhcp-%s' % i]=dhcp_servers[i]
self.aff.cycle()

View file

@ -1817,6 +1817,7 @@ class BaseProprietaire(BaseClasseCrans):
self.services_to_restart('macip', [m.ip()] )
self.services_to_restart('classify', [m.ip()] )
self.services_to_restart('dns')
self.services_to_restart('dhcp-dhcp')
if isinstance(m, MachineWifi):
self.services_to_restart('conf_wifi_ng')
self.services_to_restart('gordon-dhcp')
@ -3061,6 +3062,7 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3)
if reconf_ip:
self.services_to_restart('macip', reconf_ip)
self.services_to_restart('classify', reconf_ip)
self.services_to_restart('dhcp-dhcp')
if isinstance(self, MachineWifi) or isinstance(self, BorneWifi):
self.services_to_restart('gordon-dhcp')
else:
@ -3128,6 +3130,7 @@ Contactez nounou si la MAC est bien celle d'une carte.""", 3)
self._delete(self.dn, comment)
# Services à redémarrer
self.services_to_restart('dhcp-dhcp')
if isinstance(self, MachineWifi):
self.services_to_restart('conf_wifi_ng')
self.services_to_restart('gordon-dhcp')