From 04f8dcd7d5586efc151d45efd03d1c3cdd0b41a8 Mon Sep 17 00:00:00 2001 From: BenjiReis Date: Mon, 3 May 2021 16:02:48 +0200 Subject: [PATCH] Add IPv6 to installer net files Signed-off-by: BenjiReis --- netinterface.py | 36 +++++++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/netinterface.py b/netinterface.py index c2be043..a83e0a1 100644 --- a/netinterface.py +++ b/netinterface.py @@ -156,13 +156,12 @@ def writeDebStyleInterface(self, iface, f): # Debian style interfaces are only used for the installer; dom0 only uses CentOS style # IPv6 is only enabled through answerfiles and so is not supported here. - assert self.modev6 is None - assert self.mode + assert self.modev6 or self.mode iface_vlan = self.getInterfaceName(iface) if self.mode == self.DHCP: f.write("iface %s inet dhcp\n" % iface_vlan) - else: + elif self.mode == self.Static: # CA-11825: broadcast needs to be determined for non-standard networks bcast = self.getBroadcast() f.write("iface %s inet static\n" % iface_vlan) @@ -173,32 +172,55 @@ def writeDebStyleInterface(self, iface, f): if self.gateway: f.write(" gateway %s\n" % self.gateway) + if self.modev6 == self.DHCP: + f.write("iface %s inet6 dhcp\n" % iface_vlan) + elif self.modev6 == self.Static: + f.write("iface %s inet6 static\n" % iface_vlan) + f.write(" address %s\n" % self.ipv6addr) + if self.ipv6_gateway: + f.write(" gateway %s\n" % self.ipv6_gateway) + def writeRHStyleInterface(self, iface): """ Write a RedHat-style configuration entry for this interface to file object f using interface name iface. """ - assert self.modev6 is None - assert self.mode + assert self.modev6 or self.mode iface_vlan = self.getInterfaceName(iface) f = open('/etc/sysconfig/network-scripts/ifcfg-%s' % iface_vlan, 'w') f.write("DEVICE=%s\n" % iface_vlan) f.write("ONBOOT=yes\n") - if self.mode == self.DHCP: + if self.mode == self.DHCP or self.modev6 == self.DHCP: f.write("BOOTPROTO=dhcp\n") f.write("PERSISTENT_DHCLIENT=1\n") else: + f.write("BOOTPROTO=none\n") + + if self.mode == self.Static: # CA-11825: broadcast needs to be determined for non-standard networks bcast = self.getBroadcast() - f.write("BOOTPROTO=none\n") f.write("IPADDR=%s\n" % self.ipaddr) if bcast is not None: f.write("BROADCAST=%s\n" % bcast) f.write("NETMASK=%s\n" % self.netmask) if self.gateway: f.write("GATEWAY=%s\n" % self.gateway) + + if self.modev6: + f.write("NETWORKING_IPV6=yes\n") + f.write("IPV6INIT=yes\n") + f.write("IPV6_AUTOCONF=no\n") + if self.modev6 == self.DHCP: + f.write("DHCPV6C=yes\n") + elif self.modev6 == self.Static: + f.write("IPV6ADDR=%s\n" % self.ipv6addr) + if self.ipv6_gateway: + prefix = self.ipv6addr.split("/")[1] + f.write("IPV6_DEFAULTGW=%s/%s\n" % (self.ipv6_gateway, prefix)) + if self.vlan: f.write("VLAN=yes\n") + f.close()