Update the file for IPv4-only or IPv6-only network
Clean the interface template file by making both IP versions independent, including when using LXC containers. Co-Authored-By: Yongfeng Du <dolpher.du@intel.com> Change-Id: If0843502fe0a85cbd5eff777d9260c90cea4812a Closes-Bug:#1355171
This commit is contained in:
committed by
Stephen Finucane
parent
2fd78b35f3
commit
8107e5ced8
@@ -743,6 +743,52 @@ iface eth0 inet6 static
|
|||||||
template = self._setup_injected_network_scenario(use_ipv4=False)
|
template = self._setup_injected_network_scenario(use_ipv4=False)
|
||||||
self.assertEqual(expected, template)
|
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):
|
def test_injection_ipv6_two_interfaces(self):
|
||||||
expected = """\
|
expected = """\
|
||||||
# Injected by Nova on instance boot
|
# Injected by Nova on instance boot
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ iface lo inet loopback
|
|||||||
{% for ifc in interfaces %}
|
{% for ifc in interfaces %}
|
||||||
|
|
||||||
auto {{ ifc.name }}
|
auto {{ ifc.name }}
|
||||||
|
{% if ifc.address %}
|
||||||
iface {{ ifc.name }} inet static
|
iface {{ ifc.name }} inet static
|
||||||
hwaddress ether {{ ifc.hwaddress }}
|
hwaddress ether {{ ifc.hwaddress }}
|
||||||
address {{ ifc.address }}
|
address {{ ifc.address }}
|
||||||
@@ -20,11 +21,11 @@ iface {{ ifc.name }} inet static
|
|||||||
{% if ifc.dns %}
|
{% if ifc.dns %}
|
||||||
dns-nameservers {{ ifc.dns }}
|
dns-nameservers {{ ifc.dns }}
|
||||||
{% endif %}
|
{% 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 %}
|
{% 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 %}
|
{% if ifc.gateway_v6 %}
|
||||||
post-up ip -6 route add default via {{ ifc.gateway_v6 }} dev ${IFACE}
|
post-up ip -6 route add default via {{ ifc.gateway_v6 }} dev ${IFACE}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -41,4 +42,5 @@ iface {{ ifc.name }} inet6 static
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
Reference in New Issue
Block a user