From 2c871ebe221f848391ddbc90b15a3e1535d503ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Dimino?= Date: Sun, 10 Feb 2008 16:50:51 +0100 Subject: [PATCH] =?UTF-8?q?Autog=C3=A9n=C3=A9ration=20de=20/etc/network/in?= =?UTF-8?q?terfaces.local?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit darcs-hash:20080210155051-41f88-47060e3196b5245eadaa494503c47a45d48e47d5.gz --- Base/needed.xml | 6 +++++ Metadata/groups.xml | 3 +++ Probes/interfaces.local | 10 +++++++++ Python/etc/network/interfaces | 42 +++++++++++++++++++++++++++++++++++ 4 files changed, 61 insertions(+) create mode 100755 Probes/interfaces.local create mode 100644 Python/etc/network/interfaces diff --git a/Base/needed.xml b/Base/needed.xml index 8ef55f2..aea4043 100644 --- a/Base/needed.xml +++ b/Base/needed.xml @@ -17,10 +17,16 @@ + + + + + + diff --git a/Metadata/groups.xml b/Metadata/groups.xml index 6e28fdc..180e61c 100644 --- a/Metadata/groups.xml +++ b/Metadata/groups.xml @@ -428,4 +428,7 @@ + + diff --git a/Probes/interfaces.local b/Probes/interfaces.local new file mode 100755 index 0000000..1690802 --- /dev/null +++ b/Probes/interfaces.local @@ -0,0 +1,10 @@ +#!/bin/bash + +if [ ! -f /etc/network/interfaces.local ]; then + echo "none" + exit 0 +fi + +echo "group:interfaces.local" + +exec cat /etc/network/interfaces.local diff --git a/Python/etc/network/interfaces b/Python/etc/network/interfaces new file mode 100644 index 0000000..2eb4630 --- /dev/null +++ b/Python/etc/network/interfaces @@ -0,0 +1,42 @@ +# -*- coding: utf-8; mode: python -*- + +include("ip") + +header(""" +Les modifications locales sont à mettre dans le fichier /etc/network/interfaces.local + +Voir http://wiki.crans.org/CransTechnique/Bcfg2/... pour plus d'explications. +""") + +def dev(interface, mode, additionnals=[]): + """Génération de la conf d'une interface: + + - mode est soit pub soit adm + - additionnals contient des lignes à mettre en plus à la définition""" + + if mode == "pub": + print """auto %(interface)s +iface %(interface)s inet static + address %(ip)s + network 138.231.136.0 + netmask 255.255.248.0 + broadcast 138.231.143.255 + gateway 138.231.136.4 + dns-nameservers 138.231.136.10 138.231.136.3 + dns-search crans.org""" % { 'interface': interface, 'ip': pubip() } + else: + print """auto %(interface)s +iface %(interface)s inet static + address %(ip)s + network 10.231.136.0 + netmask 255.255.255.0 + broadcast 10.231.136.255 + mtu 1496 + dns-nameservers 10.231.136.10 + dns-search adm.crans.org""" % { 'interface': interface, 'ip': admip() } + + for line in additionnals: + print " ", line + print + +exec metadata.probes["interfaces.local"]