[OVN] Adding support for VNIC type virtio-forwarder.
The virtio-forwarder related code has already been written in other neutron components except OVN. Added logic solving virtio-forwarder in OVN plugin.Add unit tests of virtio-forwarder VNIC type. Test cases include test_create_port_with_vnic_virtio_forwarder, test_bind_virtio_forwarder_port_geneve, test_bind_virtio_forwarder_port_vxlan. Closes-Bug: #1988542 Change-Id: I80f32db761f5813409c6f789177b2fdebf643305
This commit is contained in:
@@ -431,4 +431,5 @@ OVN_SUPPORTED_VNIC_TYPES = [portbindings.VNIC_NORMAL,
|
||||
portbindings.VNIC_VHOST_VDPA,
|
||||
portbindings.VNIC_REMOTE_MANAGED,
|
||||
portbindings.VNIC_BAREMETAL,
|
||||
portbindings.VNIC_VIRTIO_FORWARDER,
|
||||
]
|
||||
|
||||
@@ -213,6 +213,10 @@ class OVNMechanismDriver(api.MechanismDriver):
|
||||
portbindings.CAP_PORT_FILTER: self.sg_enabled,
|
||||
portbindings.VIF_DETAILS_CONNECTIVITY: self.connectivity,
|
||||
},
|
||||
portbindings.VIF_TYPE_AGILIO_OVS: {
|
||||
portbindings.CAP_PORT_FILTER: self.sg_enabled,
|
||||
portbindings.VIF_DETAILS_CONNECTIVITY: self.connectivity,
|
||||
},
|
||||
portbindings.VIF_TYPE_VHOST_USER: {
|
||||
portbindings.CAP_PORT_FILTER: False,
|
||||
portbindings.VHOST_USER_MODE:
|
||||
@@ -1021,6 +1025,17 @@ class OVNMechanismDriver(api.MechanismDriver):
|
||||
vif_details = dict(self.vif_details[vif_type])
|
||||
vif_details[portbindings.VHOST_USER_SOCKET] = (
|
||||
vhost_user_socket)
|
||||
elif (vnic_type == portbindings.VNIC_VIRTIO_FORWARDER):
|
||||
vhost_user_socket = ovn_utils.ovn_vhu_sockpath(
|
||||
ovn_conf.get_ovn_vhost_sock_dir(), port['id'])
|
||||
vif_type = portbindings.VIF_TYPE_AGILIO_OVS
|
||||
port[portbindings.VIF_DETAILS].update({
|
||||
portbindings.VHOST_USER_SOCKET: vhost_user_socket})
|
||||
vif_details = dict(self.vif_details[vif_type])
|
||||
vif_details[portbindings.VHOST_USER_SOCKET] = (
|
||||
vhost_user_socket)
|
||||
vif_details[portbindings.VHOST_USER_MODE] = (
|
||||
portbindings.VHOST_USER_MODE_CLIENT)
|
||||
else:
|
||||
vif_type = portbindings.VIF_TYPE_OVS
|
||||
vif_details = self.vif_details[vif_type]
|
||||
|
||||
@@ -1250,6 +1250,28 @@ class TestOVNMechanismDriver(TestOVNMechanismDriverBase):
|
||||
portbindings.VIF_TYPE_OVS,
|
||||
self.mech_driver.vif_details[portbindings.VIF_TYPE_OVS])
|
||||
|
||||
def _test_bind_port_virtio_forwarder(self, fake_segments):
|
||||
fake_port = fakes.FakePort.create_one_port(
|
||||
attrs={'binding:vnic_type': 'virtio-forwarder'}).info()
|
||||
fake_host = 'host'
|
||||
fake_port_context = fakes.FakePortContext(
|
||||
fake_port, fake_host, fake_segments)
|
||||
self.mech_driver.bind_port(fake_port_context)
|
||||
|
||||
vif_details = self.mech_driver.\
|
||||
vif_details[portbindings.VIF_TYPE_AGILIO_OVS]
|
||||
vif_details.update({"vhostuser_socket": ovn_utils.ovn_vhu_sockpath(
|
||||
ovn_conf.get_ovn_vhost_sock_dir(), fake_port['id'])})
|
||||
vif_details.update({"vhostuser_mode": "client"})
|
||||
|
||||
neutron_agent.AgentCache().get_agents.assert_called_once_with(
|
||||
{'host': fake_host,
|
||||
'agent_type': ovn_const.OVN_CONTROLLER_TYPES})
|
||||
fake_port_context.set_binding.assert_called_once_with(
|
||||
fake_segments[0]['id'],
|
||||
portbindings.VIF_TYPE_AGILIO_OVS,
|
||||
vif_details)
|
||||
|
||||
def _test_bind_port_remote_managed(self, fake_segments):
|
||||
fake_serial = 'fake-serial'
|
||||
fake_port = fakes.FakePort.create_one_port(
|
||||
@@ -1329,6 +1351,15 @@ class TestOVNMechanismDriver(TestOVNMechanismDriverBase):
|
||||
[fakes.FakeSegment.create_one_segment(attrs=segment_attrs).info()]
|
||||
self._test_bind_port_remote_managed(fake_segments)
|
||||
|
||||
def test_bind_virtio_forwarder_port_geneve(self):
|
||||
"""Test binding a VIRTIO_FORWARDER port to a geneve segment."""
|
||||
segment_attrs = {'network_type': 'geneve',
|
||||
'physical_network': None,
|
||||
'segmentation_id': 1023}
|
||||
fake_segments = \
|
||||
[fakes.FakeSegment.create_one_segment(attrs=segment_attrs).info()]
|
||||
self._test_bind_port_virtio_forwarder(fake_segments)
|
||||
|
||||
def test_bind_remote_managed_port_vlan(self):
|
||||
"""Test binding a REMOTE_MANAGED port to a geneve segment."""
|
||||
segment_attrs = {'network_type': 'vlan',
|
||||
@@ -1362,6 +1393,15 @@ class TestOVNMechanismDriver(TestOVNMechanismDriverBase):
|
||||
[fakes.FakeSegment.create_one_segment(attrs=segment_attrs).info()]
|
||||
self._test_bind_port(fake_segments)
|
||||
|
||||
def test_bind_virtio_forwarder_port_vxlan(self):
|
||||
"""Test binding a VIRTIO_FORWARDER port to a vxlan segment."""
|
||||
segment_attrs = {'network_type': 'vxlan',
|
||||
'physical_network': None,
|
||||
'segmentation_id': 1024}
|
||||
fake_segments = \
|
||||
[fakes.FakeSegment.create_one_segment(attrs=segment_attrs).info()]
|
||||
self._test_bind_port_virtio_forwarder(fake_segments)
|
||||
|
||||
def test__is_port_provisioning_required(self):
|
||||
fake_port = fakes.FakePort.create_one_port(
|
||||
attrs={'binding:vnic_type': 'normal',
|
||||
@@ -3929,6 +3969,10 @@ class TestOVNMechanismDriverSecurityGroup(MechDriverSetupBase,
|
||||
self._test_create_port_with_vnic_type(
|
||||
portbindings.VNIC_BAREMETAL)
|
||||
|
||||
def test_create_port_with_vnic_virtio_forwarder(self):
|
||||
self._test_create_port_with_vnic_type(
|
||||
portbindings.VNIC_VIRTIO_FORWARDER)
|
||||
|
||||
def test_update_port_with_sgs(self):
|
||||
with self.network() as n, self.subnet(n):
|
||||
sg1 = self._create_empty_sg('sg1')
|
||||
|
||||
Reference in New Issue
Block a user