# -*- coding: utf-8; mode: python -*- include("ip") info["owner"] = "root" info["group"] = "root" info["perms"] = 0644 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: - 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.9 138.231.136.3 dns-search crans.org""" % { 'interface': interface, 'ip': pubip() } for line in additionnals: print " ", line print pub6(interface) elif mode == "adm": 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 138.231.136.9 10.231.136.3 dns-search adm.crans.org""" % { 'interface': interface, 'ip': admip() } for line in additionnals: print " ", line print print """iface %(interface)s inet6 static address %(ip6)s netmask 64 """ % { 'interface': interface, 'ip6': admip6(interface) } elif mode == "radin": print """auto %(interface)s iface %(interface)s inet static address %(ip)s network 10.42.0.0 netmask 255.255.0.0 broadcast 10.42.255.255 mtu 1496""" % { 'interface': interface, 'ip': radinip() } elif mode == "accueil": print """auto %(interface)s iface %(interface)s inet static address %(ip)s network 10.51.0.0 netmask 255.255.0.0 broadcast 10.51.255.255 mtu 1496""" % { 'interface': interface, 'ip': accueilip() } elif mode == "ens": print """auto %(interface)s iface %(interface)s inet static address %(ip)s network 10.2.9.0 netmask 255.255.255.0 broadcast 10.2.9.255 mtu 1496""" % { 'interface': interface, 'ip': appt_ens_ip() } elif mode == "isolement": print """auto %(interface)s iface %(interface)s inet static address %(ip)s network 10.52.0.0 netmask 255.255.0.0 broadcast 10.52.255.255 mtu 1496""" % { 'interface': interface, 'ip': isolementip() } elif mode == "manuel": print """auto %(interface)s iface %(interface)s inet static""" % { 'interface': interface } elif mode == "vide": try: iface, vlan = interface.split('.') except ValueError: vlan = None if vlan: print """auto %(interface)s iface %(interface)s inet manual pre-up vconfig add %(iface)s %(vlan)s post-down vconfig rem %(iface)s.%(vlan)s up ip l set %(interface)s up down ip l set %(interface)s down""" % { 'interface': interface, 'iface':iface,'vlan':vlan } else: print """auto %(interface)s iface %(interface)s inet manual up ip l set %(interface)s up down ip l set %(interface)s down""" % { 'interface': interface } else: raise NotImplementedError, "Mode de réseau inconnu : %s" % mode if mode != "pub" and mode != "adm": for line in additionnals: print " ", line print # Définitions communes print """auto lo iface lo inet loopback """ def pubip6(If): return "2a01:240:fe3d:4:" + If_Mac[If] def admip6(If): return "2a01:240:fe3d:c804:" + If_Mac[If] def pub6(interface): print """iface %(interface)s inet6 static address %(ip6)s netmask 64 gateway fe80::219:bbff:fe31:3b80 """ % { 'interface': interface, 'ip6': pubip6(interface) } Probe_Mac = metadata.Probes["mac"].split('\n') If_Mac = dict(zip(Probe_Mac[:-1:2], Probe_Mac[1::2])) exec metadata.Probes["interfaces_local"]