From 0e1e93f5c4fcd5b3042d4fb8691e3c30e745d819 Mon Sep 17 00:00:00 2001 From: Armando Migliaccio Date: Tue, 9 Aug 2016 12:36:19 -0700 Subject: [PATCH] Relax bound constraint for trunk parent ports This patch revisits the is_bound() condition for ports that are about to be used as parent in a trunk. The existing logic checked that for a port to be bound it is either an unbound compute port or it is associated to a host. In pratice only the latter suffices. Partially-implements: blueprint vlan-aware-vms Change-Id: I1c2c877b5cc421e05d97c7f528546a6a2c14aa46 --- neutron/services/trunk/rules.py | 6 +----- neutron/tests/unit/services/trunk/test_rules.py | 10 ---------- 2 files changed, 1 insertion(+), 15 deletions(-) diff --git a/neutron/services/trunk/rules.py b/neutron/services/trunk/rules.py index 8454174d213..776c746e6e3 100644 --- a/neutron/services/trunk/rules.py +++ b/neutron/services/trunk/rules.py @@ -14,7 +14,6 @@ from neutron_lib.api import converters from neutron_lib.api import validators -from neutron_lib import constants as n_const from neutron_lib import exceptions as n_exc from neutron._i18n import _ @@ -86,10 +85,7 @@ class TrunkPortValidator(object): # Validate that the given port_id does not have a port binding. core_plugin = manager.NeutronManager.get_plugin() self._port = core_plugin.get_port(context, self.port_id) - device_owner = self._port.get('device_owner', '') - return ( - self._port.get(portbindings.HOST_ID) or - device_owner.startswith(n_const.DEVICE_OWNER_COMPUTE_PREFIX)) + return bool(self._port.get(portbindings.HOST_ID)) def can_be_trunked(self, context): """"Return true if a port can be trunked.""" diff --git a/neutron/tests/unit/services/trunk/test_rules.py b/neutron/tests/unit/services/trunk/test_rules.py index 86ababa70d8..78698cae79a 100644 --- a/neutron/tests/unit/services/trunk/test_rules.py +++ b/neutron/tests/unit/services/trunk/test_rules.py @@ -17,7 +17,6 @@ import mock import testtools -from neutron_lib import constants as n_const from neutron_lib import exceptions as n_exc from oslo_utils import uuidutils @@ -164,15 +163,6 @@ class TrunkPortValidatorTestCase(test_plugin.Ml2PluginV2TestCase): validator = rules.TrunkPortValidator(port['port']['id']) self.assertTrue(validator.is_bound(self.context)) - def test_validate_port_has_device_owner_compute(self): - with self.port() as port: - core_plugin = manager.NeutronManager.get_plugin() - device_owner = n_const.DEVICE_OWNER_COMPUTE_PREFIX + 'test' - port['port']['device_owner'] = device_owner - core_plugin.update_port(self.context, port['port']['id'], port) - validator = rules.TrunkPortValidator(port['port']['id']) - self.assertTrue(validator.is_bound(self.context)) - def test_validate_port_cannot_be_trunked_raises(self): with self.port() as port, \ mock.patch.object(rules.TrunkPortValidator,