Merge "contrail: add vrouter VIF plugin type support"

This commit is contained in:
Jenkins 2017-06-07 17:38:57 +00:00 committed by Gerrit Code Review
commit bdd6876b8f
4 changed files with 75 additions and 0 deletions

View File

@ -83,6 +83,10 @@ VIF_DETAILS_VHOSTUSER_OVS_PLUG = 'vhostuser_ovs_plug'
# Specifies whether vhost-user socket should be used to
# create a fp netdevice interface.
VIF_DETAILS_VHOSTUSER_FP_PLUG = 'vhostuser_fp_plug'
# Specifies whether vhost-user socket should be used to
# create a vrouter netdevice interface
# TODO(mhenkel): Consider renaming this to be contrail-specific.
VIF_DETAILS_VHOSTUSER_VROUTER_PLUG = 'vhostuser_vrouter_plug'
# ovs vhost user interface type name
OVS_VHOSTUSER_INTERFACE_TYPE = 'dpdkvhostuser'

View File

@ -333,6 +333,12 @@ def _nova_to_osvif_vif_vhostuser(vif):
obj.bridge_name = vif["network"]["bridge"]
_set_vhostuser_settings(vif, obj)
return obj
elif vif['details'].get(model.VIF_DETAILS_VHOSTUSER_VROUTER_PLUG, False):
obj = _get_vif_instance(vif, objects.vif.VIFVHostUser,
plugin="contrail_vrouter",
vif_name=_get_vif_name(vif))
_set_vhostuser_settings(vif, obj)
return obj
else:
raise NotImplementedError()

View File

@ -817,3 +817,59 @@ class OSVIFUtilTestCase(test.NoDBTestCase):
self.assertRaises(exception.NovaException,
os_vif_util.nova_to_osvif_vif,
vif)
def test_nova_to_osvif_vhostuser_vrouter(self):
vif = model.VIF(
id="dc065497-3c8d-4f44-8fb4-e1d33c16a536",
type=model.VIF_TYPE_VHOSTUSER,
address="22:52:25:62:e2:aa",
network=model.Network(
id="b82c1929-051e-481d-8110-4669916c7915",
label="Demo Net",
subnets=[]),
details={
model.VIF_DETAILS_VHOSTUSER_MODE: 'client',
model.VIF_DETAILS_VHOSTUSER_VROUTER_PLUG: True,
model.VIF_DETAILS_VHOSTUSER_SOCKET: '/fake/socket',
}
)
actual = os_vif_util.nova_to_osvif_vif(vif)
expect = osv_objects.vif.VIFVHostUser(
id="dc065497-3c8d-4f44-8fb4-e1d33c16a536",
active=False,
address="22:52:25:62:e2:aa",
plugin="contrail_vrouter",
vif_name="nicdc065497-3c",
path='/fake/socket',
mode='client',
has_traffic_filtering=False,
preserve_on_delete=False,
network=osv_objects.network.Network(
id="b82c1929-051e-481d-8110-4669916c7915",
bridge_interface=None,
label="Demo Net",
subnets=osv_objects.subnet.SubnetList(
objects=[])))
self.assertObjEqual(expect, actual)
def test_nova_to_osvif_vhostuser_vrouter_no_socket_path(self):
vif = model.VIF(
id="dc065497-3c8d-4f44-8fb4-e1d33c16a536",
type=model.VIF_TYPE_VHOSTUSER,
address="22:52:25:62:e2:aa",
network=model.Network(
id="b82c1929-051e-481d-8110-4669916c7915",
label="Demo Net",
subnets=[]),
details={
model.VIF_DETAILS_VHOSTUSER_MODE: 'client',
model.VIF_DETAILS_VHOSTUSER_VROUTER_PLUG: True,
}
)
self.assertRaises(exception.VifDetailsMissingVhostuserSockPath,
os_vif_util.nova_to_osvif_vif,
vif)

View File

@ -0,0 +1,9 @@
---
features:
- |
The model name vhostuser_vrouter_plug is set by the neutron contrail
plugin during a VM (network port) creation.
The libvirt compute driver now supports plugging virtual interfaces
of type "contrail_vrouter" which are provided by
the contrail-nova-vif-driver plugin [1].
[1] https://github.com/Juniper/contrail-nova-vif-driver