generation dynamique de la route vers l'extrieur
par contre j'ai rien prvu si on regnre pendant que le traceroute vers l'extrieur ne marche pas, j'y songerai darcs-hash:20041025211207-4ec08-5ce080f9c1eed3af4ee870b436aede01761d3a23.gz
This commit is contained in:
parent
d4c2a45808
commit
8121508523
1 changed files with 66 additions and 17 deletions
|
@ -8,7 +8,7 @@ Utilis
|
|||
|
||||
# importation des fonctions et classes
|
||||
|
||||
import sys, os
|
||||
import sys, os, commands
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
from ldap_crans import crans
|
||||
from gen_confs import gen_config
|
||||
|
@ -35,20 +35,7 @@ class autostatus(gen_config) :
|
|||
|
||||
%%HTML: <TR><td colspan=3 class="table"><font size="+1"><B>Routeurs, dans l'ordre où ils sont entre le crans et l'extérieur :</font></b></TR>
|
||||
|
||||
komaz 138.231.136.4 none alerts@crans.org Notre routeur
|
||||
komaz-ext 138.231.135.6 komaz alerts@crans.org Patte externe de notre routeur.
|
||||
irts 138.231.135.5 komaz,komaz-ext alerts@crans.org Le routeur de l'ENS qui assure la liaison CRANS-ENS.
|
||||
irts-ext 138.231.132.5 komaz,komaz-ext,irts alerts@crans.org Patte externe du routeur IRTS.
|
||||
gateway.zrt 138.231.132.1 komaz,komaz-ext,irts,irts-ext alerts@crans.org Routeur de l'ENS
|
||||
kwai 138.231.176.9 komaz,komaz-ext,irts,irts-ext,gateway.zrt alerts@crans.org Routeur de l'ENS
|
||||
pioneer 138.231.176.1 komaz,komaz-ext,irts,irts-ext,gateway.zrt,kwai alerts@crans.org Le routeur principal de lENS, Interface interne.
|
||||
pioneer-ext 193.49.65.2 komaz,komaz-ext,irts,irts-ext,gateway.zrt,kwai,pioneer alerts@crans.org Le routeur principal de lENS, Interface externe.
|
||||
RenaterCachan 193.49.65.1 komaz,komaz-ext,irts,irts-ext,gateway.zrt,kwai,pioneer,pioneer-ext alerts@crans.org Routeur RENATER
|
||||
CachanCSSI1 193.51.181.186 komaz,komaz-ext,irts,irts-ext,gateway.zrt,kwai,pioneer,pioneer-ext,RenaterCachan alerts@crans.org Routeur RENATER
|
||||
CachanCSSI2 193.51.181.185 komaz,komaz-ext,irts,irts-ext,gateway.zrt,kwai,pioneer,pioneer-ext,RenaterCachan,CachanCSSI1 alerts@crans.org Routeur RENATER
|
||||
OrsayCSSI1 193.51.180.122 komaz,komaz-ext,irts,irts-ext,gateway.zrt,kwai,pioneer,pioneer-ext,RenaterCachan,CachanCSSI1,CachanCSSI2 alerts@crans.org Routeur RENATER
|
||||
OrsayCSSI2 193.51.180.121 komaz,komaz-ext,irts,irts-ext,gateway.zrt,kwai,pioneer,pioneer-ext,RenaterCachan,CachanCSSI1,CachanCSSI2,OrsayCSSI1 alerts@crans.org Routeur RENATER
|
||||
nriCSSI 193.51.179.41 komaz,komaz-ext,irts,irts-ext,gateway.zrt,kwai,pioneer,pioneer-ext,RenaterCachan,CachanCSSI1,CachanCSSI2,OrsayCSSI1,OrsayCSSI2 alerts@crans.org Routeur RENATER
|
||||
%(route)s
|
||||
|
||||
# serveurs du crans #
|
||||
#####################
|
||||
|
@ -87,6 +74,16 @@ Voila:80 195.101.94.80 irts,irts-ext,komaz,komaz-ext,gateway.zrt,kwai,p
|
|||
Yahoo!:80 66.94.230.39 irts,irts-ext,komaz,komaz-ext,gateway.zrt,kwai,pioneer,pioneer-ext,RenaterCachan nobody Est-ce que <a href="http://www.yahoo.com">Yahoo!</a> fonctionne ? (USA)
|
||||
Altavista:80 216.155.200.155 irts,irts-ext,komaz,komaz-ext,gateway.zrt,kwai,pioneer,pioneer-ext,RenaterCachan nobody Est-ce que <a href="http://www.altavista.com">Altavista</a> fonctionne ? (USA)
|
||||
"""
|
||||
# quelque descriptions de routeurs triés par IP
|
||||
infos_routeurs = {}
|
||||
infos_routeurs [ '138.231.136.4' ] = ['Komaz', 'Routeur principal du CRANS']
|
||||
infos_routeurs [ '138.231.135.5' ] = ['IRTS', 'Routeur de l\'ENS assurant la liaison CRANS<->ENS']
|
||||
infos_routeurs [ '138.231.132.1' ] = ['gateway', 'Routeur de l\'ENS']
|
||||
infos_routeurs [ '138.231.176.1' ] = ['Pioneer', 'Routeur principal de l\'ENS']
|
||||
infos_routeurs [ '193.49.65.1' ] = ['RenaterCachan1' , 'Routeur Renater' ]
|
||||
infos_routeurs [ '193.51.181.186' ] = ['RenaterCachan2', 'Routeur Renater']
|
||||
infos_routeurs [ '193.51.180.166' ] = ['RenaterJussieu1', 'Routeur Renater']
|
||||
infos_routeurs [ '193.51.180.158' ] = ['RenaterJussieu2', 'Routeur Renater']
|
||||
|
||||
# service à redémarer
|
||||
restart_cmd = ""
|
||||
|
@ -110,6 +107,8 @@ Altavista:80 216.155.200.155 irts,irts-ext,komaz,komaz-ext,gateway.zrt,kwai,p
|
|||
def _gen (self) :
|
||||
|
||||
# machines crans
|
||||
################
|
||||
|
||||
machines = crans().machines()
|
||||
|
||||
# tri des machines par type
|
||||
|
@ -162,15 +161,65 @@ Altavista:80 216.155.200.155 irts,irts-ext,komaz,komaz-ext,gateway.zrt,kwai,p
|
|||
serveurs[ nom ] = [ nom , m.nom() , 'none' , 'nobody' , m.info()[0] ]
|
||||
else :
|
||||
serveurs[ nom ] = [ nom , m.nom() , 'none' , 'nobody' , 'Infos non disponibles' ]
|
||||
|
||||
# route vers l'extérieur
|
||||
########################
|
||||
|
||||
# on récupère la route vers l'extérieur
|
||||
traceroute = commands.getoutput("/usr/bin/traceroute www.free.fr 2> /dev/null | sed 's/ */ /g' | sed 's/^ //g' | sed 's/[(,)]//g' | cut -d ' ' -f 2,3").split("\n")
|
||||
|
||||
# initialisation des variables
|
||||
in_renater = 0
|
||||
route_to_ext = ''
|
||||
depends_to_ext = ''
|
||||
|
||||
for routeur in traceroute :
|
||||
|
||||
# on commence à rentrer dans la chaine des routeurs renater
|
||||
if 'renater.fr' in routeur :
|
||||
in_renater = 1
|
||||
|
||||
# on est plus dans les routeurs renater donc on arrête
|
||||
if in_renater and not 'renater.fr' in routeur :
|
||||
continue
|
||||
|
||||
# ajout du routeur
|
||||
|
||||
# ip
|
||||
tmp_ip = routeur.split(' ')[1]
|
||||
|
||||
# nom & desciption
|
||||
if routeur.split(' ')[1] in self.infos_routeurs.keys() :
|
||||
tmp_name = self.infos_routeurs[tmp_ip][0]
|
||||
tmp_desc = self.infos_routeurs[tmp_ip][1]
|
||||
else :
|
||||
tmp_name = routeur.split(' ')[0].split('.')[0]
|
||||
tmp_desc = 'Pas de description'
|
||||
|
||||
# dépendances
|
||||
if not depends_to_ext :
|
||||
tmp_depends = 'none'
|
||||
depends_to_ext = tmp_name
|
||||
else :
|
||||
tmp_depends = depends_to_ext
|
||||
depends_to_ext += ',' + tmp_name
|
||||
|
||||
# on l'ajoute à la route
|
||||
if route_to_ext :
|
||||
route_to_ext += '\n'
|
||||
route_to_ext += '%s %s %s nobody@crans.org %s' % (tmp_name, tmp_ip, tmp_depends, tmp_desc)
|
||||
|
||||
# génération du fichier
|
||||
#######################
|
||||
|
||||
# début du fichier
|
||||
file = self._open_conf(self.CONFFILE, "#")
|
||||
|
||||
|
||||
# génère le dictionnaire pour les modifications
|
||||
dico = {}
|
||||
dico['switchs'] = self.make_config(switchs)
|
||||
dico['bornes'] = self.make_config(bornes)
|
||||
dico['serveurs'] = self.make_config(serveurs)
|
||||
dico['route'] = route_to_ext.encode('iso-8859-15')
|
||||
|
||||
# on écrit dans le fichier de configuration
|
||||
file.write( self.matrice % dico )
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue