Skip to content

Commit

Permalink
Load all the necessary database tables when running cisco plugin
Browse files Browse the repository at this point in the history
In Cisco plugin, Remove redundant/unnecessary calls to configure_db().
Make sure that all the database models are loaded before calling
configure_db()

fixes bug #1155121

Change-Id: I27d5dda512140f0553b311b35678c82f729fa854
  • Loading branch information
Baodong (Robert) Li committed Mar 19, 2013
1 parent 5acb6ba commit 4bd651a
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 23 deletions.
5 changes: 0 additions & 5 deletions quantum/plugins/cisco/db/network_db_v2.py
Expand Up @@ -31,11 +31,6 @@
LOG = logging.getLogger(__name__)


def initialize():
"""Establish database connection and load models"""
db.configure_db()


def create_vlanids():
"""Prepopulates the vlan_bindings table"""
LOG.debug(_("create_vlanids() called"))
Expand Down
5 changes: 0 additions & 5 deletions quantum/plugins/cisco/db/nexus_db_v2.py
Expand Up @@ -29,11 +29,6 @@
LOG = logging.getLogger(__name__)


def initialize():
"""Establish database connection and load models"""
db.configure_db()


def get_all_nexusport_bindings():
"""Lists all the nexusport bindings"""
LOG.debug(_("get_all_nexusport_bindings() called"))
Expand Down
16 changes: 12 additions & 4 deletions quantum/plugins/cisco/models/virt_phy_sw_v2.py
Expand Up @@ -35,6 +35,7 @@
from quantum.plugins.cisco import l2network_plugin_configuration as conf
from quantum.plugins.openvswitch import ovs_db_v2 as odb
from quantum import quantum_plugin_base_v2
from quantum.db import api as db_api


LOG = logging.getLogger(__name__)
Expand Down Expand Up @@ -64,8 +65,6 @@ def __init__(self):
configured, and load the inventories those device plugins for which the
inventory is configured
"""
cdb.initialize()
cred.Store.initialize()
for key in conf.PLUGINS[const.PLUGINS].keys():
plugin_obj = conf.PLUGINS[const.PLUGINS][key]
self._plugins[key] = importutils.import_object(plugin_obj)
Expand All @@ -77,12 +76,21 @@ def __init__(self):
LOG.debug(_("Loaded device inventory %s\n"),
conf.PLUGINS[const.INVENTORY][key])

if hasattr(self._plugins[const.VSWITCH_PLUGIN],
"supported_extension_aliases"):
if ((const.VSWITCH_PLUGIN in self._plugins) and
hasattr(self._plugins[const.VSWITCH_PLUGIN],
"supported_extension_aliases")):
self.supported_extension_aliases.extend(
self._plugins[const.VSWITCH_PLUGIN].
supported_extension_aliases)

# At this point, all the database models should have been loaded. It's
# possible that configure_db() may have been called by one of the
# plugins loaded in above. Otherwise, this call is to make sure that
# the database is initialized
db_api.configure_db()

# Initialize credential store after database initialization
cred.Store.initialize()
LOG.debug(_("%(module)s.%(name)s init done"),
{'module': __name__,
'name': self.__class__.__name__})
Expand Down
1 change: 0 additions & 1 deletion quantum/plugins/cisco/network_plugin.py
Expand Up @@ -66,7 +66,6 @@ def __init__(self):
self.supported_extension_aliases.extend(
self._model.supported_extension_aliases)

super(PluginV2, self).__init__()
LOG.debug(_("Plugin initialization complete"))

def __getattribute__(self, name):
Expand Down
2 changes: 0 additions & 2 deletions quantum/plugins/cisco/nexus/cisco_nexus_plugin_v2.py
Expand Up @@ -50,8 +50,6 @@ def __init__(self):
"""
Extracts the configuration parameters from the configuration file
"""
# Initialize the nxos db
nxos_db.initialize()
self._client = importutils.import_object(conf.NEXUS_DRIVER)
LOG.debug(_("Loaded driver %s"), conf.NEXUS_DRIVER)
self._nexus_switches = conf.NEXUS_DETAILS
Expand Down
7 changes: 1 addition & 6 deletions quantum/tests/unit/cisco/test_network_plugin.py
Expand Up @@ -32,12 +32,7 @@ class CiscoNetworkPluginV2TestCase(test_db_plugin.QuantumDbPluginV2TestCase):
_plugin_name = 'quantum.plugins.cisco.network_plugin.PluginV2'

def setUp(self):
def new_init():
db.configure_db()

with mock.patch.object(network_db_v2,
'initialize', new=new_init):
super(CiscoNetworkPluginV2TestCase, self).setUp(self._plugin_name)
super(CiscoNetworkPluginV2TestCase, self).setUp(self._plugin_name)
self.port_create_status = 'DOWN'

def _get_plugin_ref(self):
Expand Down

0 comments on commit 4bd651a

Please sign in to comment.