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
This commit is contained in:
Armando Migliaccio 2016-08-09 12:36:19 -07:00
parent ca0d752d81
commit 0e1e93f5c4
2 changed files with 1 additions and 15 deletions

View File

@ -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."""

View File

@ -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,