Allow linux tap to use routes
Change-Id: I7bbebca40b7070f3944ba64029171c8bf471cd51
(cherry picked from commit 1ae025476f
)
This commit is contained in:
parent
69699cda8f
commit
8f08b73878
3
.gitignore
vendored
3
.gitignore
vendored
@ -48,3 +48,6 @@ ChangeLog
|
|||||||
# Editors
|
# Editors
|
||||||
*~
|
*~
|
||||||
.*.swp
|
.*.swp
|
||||||
|
|
||||||
|
# Visual Studio Code
|
||||||
|
.vscode
|
||||||
|
@ -1102,6 +1102,12 @@ class IfcfgNetConfig(os_net_config.NetConfig):
|
|||||||
data = self._add_common(linux_tap)
|
data = self._add_common(linux_tap)
|
||||||
data += "TYPE=Tap\n"
|
data += "TYPE=Tap\n"
|
||||||
self.interface_data[linux_tap.name] = data
|
self.interface_data[linux_tap.name] = data
|
||||||
|
if linux_tap.routes:
|
||||||
|
self._add_routes(linux_tap.name,
|
||||||
|
linux_tap.routes)
|
||||||
|
if linux_tap.rules:
|
||||||
|
self._add_rules(linux_tap.name,
|
||||||
|
linux_tap.rules)
|
||||||
|
|
||||||
def generate_ivs_config(self, ivs_uplinks, ivs_interfaces):
|
def generate_ivs_config(self, ivs_uplinks, ivs_interfaces):
|
||||||
"""Generate configuration content for ivs."""
|
"""Generate configuration content for ivs."""
|
||||||
|
@ -602,15 +602,23 @@ DRIVER=uio_pci_generic
|
|||||||
CPU_LIST=2,3
|
CPU_LIST=2,3
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_LINUX_TAP_ROUTES = """default via 192.168.1.1 dev tap0 metric 10
|
||||||
|
172.19.0.0/24 via 192.168.1.1 dev tap0
|
||||||
|
172.20.0.0/24 via 192.168.1.5 dev tap0 metric 100
|
||||||
|
"""
|
||||||
|
|
||||||
_LINUX_TAP_IFACE = """# This file is autogenerated by os-net-config
|
_LINUX_TAP_IFACE = """# This file is autogenerated by os-net-config
|
||||||
DEVICE=tap0
|
DEVICE=tap0
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
HOTPLUG=no
|
HOTPLUG=no
|
||||||
NM_CONTROLLED=no
|
NM_CONTROLLED=no
|
||||||
PEERDNS=no
|
PEERDNS=no
|
||||||
BOOTPROTO=none
|
BOOTPROTO=static
|
||||||
|
IPADDR=192.168.1.2
|
||||||
|
NETMASK=255.255.255.0
|
||||||
TYPE=Tap
|
TYPE=Tap
|
||||||
"""
|
"""
|
||||||
|
|
||||||
_SRIOV_PF_IFCFG = """# This file is autogenerated by os-net-config
|
_SRIOV_PF_IFCFG = """# This file is autogenerated by os-net-config
|
||||||
DEVICE=enp3s0f0
|
DEVICE=enp3s0f0
|
||||||
ONBOOT=yes
|
ONBOOT=yes
|
||||||
@ -1155,11 +1163,22 @@ class TestIfcfgNetConfig(base.TestCase):
|
|||||||
self.assertEqual('', self.get_route_config('vhost0'))
|
self.assertEqual('', self.get_route_config('vhost0'))
|
||||||
|
|
||||||
def test_add_linux_tap(self):
|
def test_add_linux_tap(self):
|
||||||
tap = objects.LinuxTap('tap0', nm_controlled=False)
|
v4_addr = objects.Address('192.168.1.2/24')
|
||||||
|
route1 = objects.Route('192.168.1.1', default=True,
|
||||||
|
route_options="metric 10")
|
||||||
|
route2 = objects.Route('192.168.1.1', '172.19.0.0/24')
|
||||||
|
route3 = objects.Route('192.168.1.5', '172.20.0.0/24',
|
||||||
|
route_options="metric 100")
|
||||||
|
tap = objects.LinuxTap('tap0', addresses=[v4_addr],
|
||||||
|
nm_controlled=False,
|
||||||
|
routes=[route1, route2, route3])
|
||||||
self.provider.add_linux_tap(tap)
|
self.provider.add_linux_tap(tap)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
_LINUX_TAP_IFACE,
|
_LINUX_TAP_IFACE,
|
||||||
self.provider.interface_data['tap0'])
|
self.get_interface_config('tap0'))
|
||||||
|
self.assertEqual(
|
||||||
|
_LINUX_TAP_ROUTES,
|
||||||
|
self.get_route_config('tap0'))
|
||||||
|
|
||||||
def test_add_vlan(self):
|
def test_add_vlan(self):
|
||||||
vlan = objects.Vlan('em1', 5)
|
vlan = objects.Vlan('em1', 5)
|
||||||
|
Loading…
Reference in New Issue
Block a user