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
|
||||
*~
|
||||
.*.swp
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode
|
||||
|
@ -1102,6 +1102,12 @@ class IfcfgNetConfig(os_net_config.NetConfig):
|
||||
data = self._add_common(linux_tap)
|
||||
data += "TYPE=Tap\n"
|
||||
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):
|
||||
"""Generate configuration content for ivs."""
|
||||
|
@ -602,15 +602,23 @@ DRIVER=uio_pci_generic
|
||||
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
|
||||
DEVICE=tap0
|
||||
ONBOOT=yes
|
||||
HOTPLUG=no
|
||||
NM_CONTROLLED=no
|
||||
PEERDNS=no
|
||||
BOOTPROTO=none
|
||||
BOOTPROTO=static
|
||||
IPADDR=192.168.1.2
|
||||
NETMASK=255.255.255.0
|
||||
TYPE=Tap
|
||||
"""
|
||||
|
||||
_SRIOV_PF_IFCFG = """# This file is autogenerated by os-net-config
|
||||
DEVICE=enp3s0f0
|
||||
ONBOOT=yes
|
||||
@ -1155,11 +1163,22 @@ class TestIfcfgNetConfig(base.TestCase):
|
||||
self.assertEqual('', self.get_route_config('vhost0'))
|
||||
|
||||
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.assertEqual(
|
||||
_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):
|
||||
vlan = objects.Vlan('em1', 5)
|
||||
|
Loading…
Reference in New Issue
Block a user