]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
BigSwitch: Don't import portbindings_db until use
authorKevin Benton <blak111@gmail.com>
Thu, 3 Apr 2014 10:00:37 +0000 (10:00 +0000)
committerKevin Benton <blak111@gmail.com>
Fri, 4 Apr 2014 20:12:21 +0000 (13:12 -0700)
The Big Switch ML2 driver re-uses large parts of
code from the Big Switch plugin. However, the plugin
uses the old portbindings_db in its port tracking
code. This db is not created/used by ML2, so it does
not exist when the Big Switch ML2 driver is being used.
This caused a problem when the portbindings_db module
would be imported even though it wasn't being used
since the SQLAlchemy models would create the
relationships during the import.

This patch moves the portbindings_db import down to
the methods that leverage it so it won't be imported
during use by the ML2 driver.

This is a temporary solution which can be back-ported
if disabling auto schema generation is back-ported
to icehouse. An appropriate fix will require some
refactoring to avoid the port tracking code from
being imported for ML2.

Closes-Bug: #1300628
Change-Id: I551abf9d6ec832c423cba0d50bb27715b43c0b1c

neutron/plugins/bigswitch/db/porttracker_db.py

index da5f0c22ff6aac398ac4dc3c0c0c919057d4af58..7966c7c7d8c74e294d29ff7672693921c96a1968 100644 (file)
 #    under the License.
 
 from neutron.api.v2 import attributes
-from neutron.db import portbindings_db
 from neutron.openstack.common import log as logging
 
 LOG = logging.getLogger(__name__)
 
 
 def get_port_hostid(context, port_id):
+    # REVISIT(kevinbenton): this is a workaround to avoid portbindings_db
+    # relational table generation until one of the functions is called.
+    from neutron.db import portbindings_db
     with context.session.begin(subtransactions=True):
         query = context.session.query(portbindings_db.PortBindingPort)
         res = query.filter_by(port_id=port_id).first()
@@ -32,6 +34,9 @@ def get_port_hostid(context, port_id):
 
 
 def put_port_hostid(context, port_id, host):
+    # REVISIT(kevinbenton): this is a workaround to avoid portbindings_db
+    # relational table generation until one of the functions is called.
+    from neutron.db import portbindings_db
     if not attributes.is_attr_set(host):
         LOG.warning(_("No host_id in port request to track port location."))
         return