Skip to content

Commit

Permalink
Add IPv6 to installer net files
Browse files Browse the repository at this point in the history
Signed-off-by: BenjiReis <[email protected]>
  • Loading branch information
benjamreis committed May 3, 2021
1 parent d9e0feb commit 04f8dcd
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions netinterface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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()


Expand Down

0 comments on commit 04f8dcd

Please sign in to comment.