allow vhost0 to pass list of members

- in case of L3MH Contrail feature for kernel mode
BIND_INT might be a list

Change-Id: I2c44d86822b7bf74a10e7e7e81abcb22b5f639ae
(cherry picked from commit 178564dccd)
This commit is contained in:
Alexey 2021-08-17 21:15:17 +03:00 committed by alexey-mr
parent 2e29b5a435
commit 69699cda8f
3 changed files with 25 additions and 5 deletions

View File

@ -1048,13 +1048,11 @@ class IfcfgNetConfig(os_net_config.NetConfig):
"""
logger.info('adding contrail_vrouter interface: %s'
% contrail_vrouter.name)
# Contrail vrouter will have the only member (of type interface,
# vlan or linux_bond)
ifname = contrail_vrouter.members[0].name
ifnames = ",".join([m.name for m in contrail_vrouter.members])
data = self._add_common(contrail_vrouter)
data += "DEVICETYPE=vhost\n"
data += "TYPE=kernel_mode\n"
data += "BIND_INT=%s\n" % ifname
data += "BIND_INT=%s\n" % ifnames
logger.debug('contrail data: %s' % data)
self.interface_data[contrail_vrouter.name] = data
if contrail_vrouter.routes:

View File

@ -985,7 +985,6 @@ definitions:
- $ref: "#/definitions/vlan"
- $ref: "#/definitions/linux_bond"
minItems: 1
maxItems: 1
# common options:
use_dhcp:
$ref: "#/definitions/bool_or_param"

View File

@ -524,6 +524,18 @@ TYPE=kernel_mode
BIND_INT=em3
"""
_CONTRAIL_VROUTER_IFACE_L3MH = """# This file is autogenerated by os-net-config
DEVICE=vhost0
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
PEERDNS=no
BOOTPROTO=none
DEVICETYPE=vhost
TYPE=kernel_mode
BIND_INT=em3,em4
"""
_CONTRAIL_VROUTER_VLAN_IFACE = """# This file is autogenerated by os-net-config
DEVICE=vhost0
ONBOOT=yes
@ -1025,6 +1037,17 @@ class TestIfcfgNetConfig(base.TestCase):
self.provider.interface_data['vhost0'])
self.assertEqual('', self.get_route_config('vhost0'))
def test_add_contrail_vrouter_l3mh(self):
interface1 = objects.Interface('em3')
interface2 = objects.Interface('em4')
cvi = objects.ContrailVrouter('vhost0',
members=[interface1, interface2],)
self.provider.add_contrail_vrouter(cvi)
self.assertEqual(
_CONTRAIL_VROUTER_IFACE_L3MH,
self.provider.interface_data['vhost0'])
self.assertEqual('', self.get_route_config('vhost0'))
def test_add_contrail_vrouter_vlan(self):
addresses = [objects.Address('10.0.0.30/24')]
interface1 = objects.Interface('vlan100')