Merge "Update the file for IPv4-only or IPv6-only network"

This commit is contained in:
Zuul
2022-07-18 05:00:34 +00:00
committed by Gerrit Code Review
2 changed files with 52 additions and 4 deletions
@@ -738,6 +738,52 @@ iface eth0 inet6 static
template = self._setup_injected_network_scenario(use_ipv4=False)
self.assertEqual(expected, template)
def test_injection_ipv6_only(self):
expected = '''\
# Injected by Nova on instance boot
#
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet6 static
hwaddress ether aa:aa:aa:aa:aa:aa
address 1234:567::2
netmask 48
gateway 1234:567::1
dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
'''
template = self._setup_injected_network_scenario(use_ipv4=False,
use_ipv6=True)
self.assertEqual(expected, template)
def test_injection_ipv6_only_no_gateway(self):
expected = '''\
# Injected by Nova on instance boot
#
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet6 static
hwaddress ether aa:aa:aa:aa:aa:aa
address 1234:567::2
netmask 48
dns-nameservers 2001:4860:4860::8888 2001:4860:4860::8844
'''
template = self._setup_injected_network_scenario(use_ipv4=False,
use_ipv6=True,
gateway=False)
self.assertEqual(expected, template)
def test_injection_ipv6_two_interfaces(self):
expected = """\
# Injected by Nova on instance boot
+6 -4
View File
@@ -9,6 +9,7 @@ iface lo inet loopback
{% for ifc in interfaces %}
auto {{ ifc.name }}
{% if ifc.address %}
iface {{ ifc.name }} inet static
hwaddress ether {{ ifc.hwaddress }}
address {{ ifc.address }}
@@ -20,11 +21,11 @@ iface {{ ifc.name }} inet static
{% if ifc.dns %}
dns-nameservers {{ ifc.dns }}
{% endif %}
{% if use_ipv6 %}
{% if libvirt_virt_type == 'lxc' %}
{% if ifc.address_v6 %}
post-up ip -6 addr add {{ ifc.address_v6 }}/{{ifc.netmask_v6 }} dev ${IFACE}
{% endif %}
{% if use_ipv6 %}
{% if ifc.address_v6 %}
{% if libvirt_virt_type == 'lxc' %}
post-up ip -6 addr add {{ ifc.address_v6 }}/{{ifc.netmask_v6 }} dev ${IFACE}
{% if ifc.gateway_v6 %}
post-up ip -6 route add default via {{ ifc.gateway_v6 }} dev ${IFACE}
{% endif %}
@@ -41,4 +42,5 @@ iface {{ ifc.name }} inet6 static
{% endif %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}