vlan and linux_bond members for contrail vrouter

Currently the contrail vrouter interface member interface can
only be of type interface. vlan and linux_bond are needed,

Change-Id: I3e7cf56b0c237a8b791fedbeb255beb60ce3d7c6
This commit is contained in:
Michael Henkel 2018-06-22 11:08:36 +02:00 committed by Andrey Pavlov
parent 1f691d47a6
commit 40ce571209
7 changed files with 83 additions and 2 deletions

View File

@ -0,0 +1,15 @@
{ "network_config": [
{
"type": "contrail_vrouter",
"name": "vhost0",
"members": [
{
"type": "vlan",
"vlan_id": 100,
"device": "em3"
}
],
"mtu": 1500
}
]
}

View File

@ -0,0 +1,10 @@
network_config:
-
type: contrail_vrouter
name: vhost0
members:
-
type: vlan
vlan_id: 100
device: em3
mtu: 1500

View File

@ -735,7 +735,8 @@ class IfcfgNetConfig(os_net_config.NetConfig):
"""
logger.info('adding contrail_vrouter interface: %s'
% contrail_vrouter.name)
# Contrail vrouter will have theeeee only member (of type Interface)
# Contrail vrouter will have the only member (of type interface,
# vlan or linux_bond)
ifname = contrail_vrouter.members[0].name
data = self._add_common(contrail_vrouter)
data += "DEVICETYPE=vhost\n"

View File

@ -816,7 +816,10 @@ definitions:
members:
type: array
items:
- $ref: "#/definitions/interface"
oneof:
- $ref: "#/definitions/interface"
- $ref: "#/definitions/vlan"
- $ref: "#/definitions/linux_bond"
minItems: 1
maxItems: 1
# common options:

View File

@ -320,6 +320,25 @@ class TestCli(base.TestCase):
self.assertIn(dev, stdout_yaml)
self.assertEqual(stdout_yaml, stdout_json)
def test_contrail_vrouter_vlan_noop_output(self):
cvi_yaml = os.path.join(SAMPLE_BASE, 'contrail_vrouter_vlan.yaml')
cvi_json = os.path.join(SAMPLE_BASE, 'contrail_vrouter_vlan.json')
stdout_yaml, stderr = self.run_cli('ARG0 --provider=ifcfg --noop '
'--exit-on-validation-errors '
'-c %s' % cvi_yaml)
self.assertEqual('', stderr)
stdout_json, stderr = self.run_cli('ARG0 --provider=ifcfg --noop '
'--exit-on-validation-errors '
'-c %s' % cvi_json)
self.assertEqual('', stderr)
sanity_devices = ['DEVICE=vhost0',
'BIND_INT=vlan100',
'DEVICETYPE=vhost',
'TYPE=kernel_mode']
for dev in sanity_devices:
self.assertIn(dev, stdout_yaml)
self.assertEqual(stdout_yaml, stdout_json)
def test_contrail_vrouter_dpdk_noop_output(self):
cvi_yaml = os.path.join(SAMPLE_BASE, 'contrail_vrouter_dpdk.yaml')
cvi_json = os.path.join(SAMPLE_BASE, 'contrail_vrouter_dpdk.json')

View File

@ -407,6 +407,20 @@ TYPE=kernel_mode
BIND_INT=em3
"""
_CONTRAIL_VROUTER_VLAN_IFACE = """# This file is autogenerated by os-net-config
DEVICE=vhost0
ONBOOT=yes
HOTPLUG=no
NM_CONTROLLED=no
PEERDNS=no
BOOTPROTO=static
IPADDR=10.0.0.30
NETMASK=255.255.255.0
DEVICETYPE=vhost
TYPE=kernel_mode
BIND_INT=vlan100
"""
_CONTRAIL_VROUTER_DPDK_IFACE = """# This file is autogenerated by os-net-config
DEVICE=vhost0
ONBOOT=yes
@ -807,6 +821,17 @@ class TestIfcfgNetConfig(base.TestCase):
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')
cvi = objects.ContrailVrouter('vhost0', addresses=addresses,
members=[interface1],)
self.provider.add_contrail_vrouter(cvi)
self.assertEqual(
_CONTRAIL_VROUTER_VLAN_IFACE,
self.provider.interface_data['vhost0'])
self.assertEqual('', self.get_route_config('vhost0'))
def test_add_contrail_vrouter_with_nic_mapping(self):
nic_mapping = {'nic1': 'em3'}
self.stubbed_mapped_nics = nic_mapping

View File

@ -0,0 +1,8 @@
---
issues:
- |
Currently the member interface for a contrail vrouter interface can only
be of type interface. Types vlan and linux_bond are needed.
fixes:
- |
This fix adds support for member interfaces of type vlan and linux_bond