]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Fix case with no host_id in BigSwitch plugin
authorKevin Benton <kevin.benton@bigswitch.com>
Fri, 28 Jun 2013 21:40:11 +0000 (14:40 -0700)
committerKevin Benton <kevin.benton@bigswitch.com>
Sat, 29 Jun 2013 07:26:29 +0000 (00:26 -0700)
This correctly checks for the case where nova does not
provide the host_id in port creation/updates.

Fixes: bug #1195903
Change-Id: Ic0d714a3977810c6b1144c1e25488f75cc95d0f0

quantum/plugins/bigswitch/db/porttracker_db.py
quantum/tests/unit/bigswitch/test_restproxy_plugin.py

index c286d637ccad654a20c9bba63ed3e76fb9183648..14d141894454e411747ee02ccc5129eeb27d3c99 100644 (file)
@@ -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
index edbb2d5adfd35ce7bcc241e6136e7352c4d11f98..f6c99c0d048a67b6889ac7073b5fdbc4307ffc0e 100644 (file)
@@ -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):