From: Kevin Benton Date: Fri, 28 Jun 2013 21:40:11 +0000 (-0700) Subject: Fix case with no host_id in BigSwitch plugin X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a87a7c2ad0909c28f3d9d62a13cec59ee4d2e0e6;p=openstack-build%2Fneutron-build.git Fix case with no host_id in BigSwitch plugin This correctly checks for the case where nova does not provide the host_id in port creation/updates. Fixes: bug #1195903 Change-Id: Ic0d714a3977810c6b1144c1e25488f75cc95d0f0 --- diff --git a/quantum/plugins/bigswitch/db/porttracker_db.py b/quantum/plugins/bigswitch/db/porttracker_db.py index c286d637c..14d141894 100644 --- a/quantum/plugins/bigswitch/db/porttracker_db.py +++ b/quantum/plugins/bigswitch/db/porttracker_db.py @@ -17,6 +17,7 @@ import sqlalchemy as sa +from quantum.api.v2 import attributes from quantum.db import model_base from quantum.openstack.common import log as logging @@ -38,6 +39,9 @@ def get_port_hostid(context, port_id): def put_port_hostid(context, port_id, host_id): + if not attributes.is_attr_set(host_id): + LOG.warning(_("No host_id in port request to track port location.")) + return if port_id == '': LOG.warning(_("Received an empty port ID for host '%s'"), host_id) return diff --git a/quantum/tests/unit/bigswitch/test_restproxy_plugin.py b/quantum/tests/unit/bigswitch/test_restproxy_plugin.py index edbb2d5ad..f6c99c0d0 100644 --- a/quantum/tests/unit/bigswitch/test_restproxy_plugin.py +++ b/quantum/tests/unit/bigswitch/test_restproxy_plugin.py @@ -107,6 +107,23 @@ class TestBigSwitchProxyPortsV2IVS(test_plugin.TestPortsV2, cfg.CONF.set_override('vif_type', 'ivs', 'NOVA') +class TestNoHostIDVIFOverride(test_plugin.TestPortsV2, + BigSwitchProxyPluginV2TestCase, + test_bindings.PortBindingsTestCase): + VIF_TYPE = portbindings.VIF_TYPE_OVS + HAS_PORT_FILTER = False + + def setUp(self): + super(TestNoHostIDVIFOverride, self).setUp() + cfg.CONF.set_override('vif_type', 'ovs', 'NOVA') + + def test_port_vif_details(self): + kwargs = {'name': 'name', 'device_id': 'override_dev'} + with self.port(**kwargs) as port: + self.assertEqual(port['port']['binding:vif_type'], + portbindings.VIF_TYPE_OVS) + + class TestBigSwitchVIFOverride(test_plugin.TestPortsV2, BigSwitchProxyPluginV2TestCase, test_bindings.PortBindingsTestCase):