diff --git a/vif_plug_ovs/ovs.py b/vif_plug_ovs/ovs.py index 7372afec..92473eec 100644 --- a/vif_plug_ovs/ovs.py +++ b/vif_plug_ovs/ovs.py @@ -202,8 +202,12 @@ class OvsPlugin(plugin.PluginBase): # bound the interface in the vif binding details so isolation # can be enabled automatically in the future. bridge = kwargs.pop('bridge', vif.network.bridge) - if self._isolate_vif(vif_name, bridge): + # See bug #2069543. + if (self._isolate_vif(vif_name, bridge) and + not self._is_trunk_bridge(bridge)): kwargs['tag'] = constants.DEAD_VLAN + kwargs['vlan_mode'] = 'trunk' + kwargs['trunks'] = constants.DEAD_VLAN qos_type = self._get_qos_type(vif) if qos_type is not None: # NOTE(sean-k-mooney): If the port is not already created diff --git a/vif_plug_ovs/ovsdb/ovsdb_lib.py b/vif_plug_ovs/ovsdb/ovsdb_lib.py index 9c509d63..b3a15420 100644 --- a/vif_plug_ovs/ovsdb/ovsdb_lib.py +++ b/vif_plug_ovs/ovsdb/ovsdb_lib.py @@ -139,7 +139,7 @@ class BaseOVS(object): self, bridge, dev, iface_id, mac, instance_id, mtu=None, interface_type=None, vhost_server_path=None, tag=None, pf_pci=None, vf_num=None, set_ids=True, datapath_type=None, - qos_type=None + qos_type=None, vlan_mode=None, trunks=None ): """Create OVS port @@ -204,6 +204,11 @@ class BaseOVS(object): txn.add(self.ovsdb.add_port(bridge, dev)) if tag: txn.add(self.ovsdb.db_set('Port', dev, ('tag', tag))) + if vlan_mode: + txn.add(self.ovsdb.db_set('Port', dev, + ('vlan_mode', vlan_mode))) + if trunks: + txn.add(self.ovsdb.db_set('Port', dev, ('trunks', trunks))) if qid: txn.add(self.ovsdb.db_set('Port', dev, ('qos', qid))) if col_values: diff --git a/vif_plug_ovs/tests/functional/test_plugin.py b/vif_plug_ovs/tests/functional/test_plugin.py index e40ae49a..e0b2d1e6 100644 --- a/vif_plug_ovs/tests/functional/test_plugin.py +++ b/vif_plug_ovs/tests/functional/test_plugin.py @@ -12,6 +12,7 @@ import testscenarios import time +from unittest import mock from oslo_concurrency import processutils from oslo_config import cfg @@ -183,3 +184,37 @@ class TestOVSPlugin(testscenarios.WithScenarios, self._check_parameter( 'QoS', str(qos_uuid), 'type', None ) + + def test_plug_br_int_isolate_vif_dead_vlan(self): + with mock.patch.object(self.plugin.config, 'isolate_vif', True): + network = objects.network.Network( + id='5449523c-3a08-11ef-86d6-17149687aa4d', + bridge='br-5449523c', + subnets=self.subnets, + vlan=99) + vif = objects.vif.VIFOpenVSwitch( + id='85cb9bc6-3a08-11ef-b2d4-9b7c38edd677', + address='ca:fe:de:ad:be:ef', + network=network, + port_profile=self.profile_ovs_system, + vif_name="port-85cb9bc6") + self.plugin.plug(vif, self.instance) + self.addCleanup(self._del_bridge, 'br-5449523c') + self._check_parameter('Port', vif.vif_name, 'tag', 4095) + + def test_plug_trunk_bridge_ignores_isolate_vif(self): + with mock.patch.object(self.plugin.config, 'isolate_vif', True): + network = objects.network.Network( + id='ef98b384-3a0f-11ef-9009-47345fca266f', + bridge='tbr-ef98b384', + subnets=self.subnets, + vlan=99) + vif = objects.vif.VIFOpenVSwitch( + id='631f52bc-3a07-11ef-a006-1319ef9d6edd', + address='ca:fe:de:ad:be:ef', + network=network, + port_profile=self.profile_ovs_system, + vif_name='port-631f52bc') + self.plugin.plug(vif, self.instance) + self.addCleanup(self._del_bridge, 'tbr-ef98b384') + self._check_parameter('Port', vif.vif_name, 'tag', []) diff --git a/vif_plug_ovs/tests/unit/test_plugin.py b/vif_plug_ovs/tests/unit/test_plugin.py index de157de5..ce1502e8 100644 --- a/vif_plug_ovs/tests/unit/test_plugin.py +++ b/vif_plug_ovs/tests/unit/test_plugin.py @@ -219,7 +219,10 @@ class PluginTest(testtools.TestCase): self.vif_ovs.address, self.instance.uuid, mtu=plugin.config.network_device_mtu, interface_type=constants.OVS_VHOSTUSER_INTERFACE_TYPE, - tag=constants.DEAD_VLAN) + tag=constants.DEAD_VLAN, + vlan_mode='trunk', + trunks=constants.DEAD_VLAN + ) @mock.patch.object(ovsdb_lib.BaseOVS, 'create_ovs_vif_port') @mock.patch.object(ovsdb_lib.BaseOVS, 'port_exists')