]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Ensure API extensions for NVP are loaded by default
authorarmando-migliaccio <amigliaccio@nicira.com>
Wed, 22 May 2013 05:10:13 +0000 (22:10 -0700)
committerarmando-migliaccio <amigliaccio@nicira.com>
Fri, 24 May 2013 01:21:07 +0000 (18:21 -0700)
Fixes bug #1182736

Change-Id: I286f5b69d58a4cd3a0e25a984559fdf37068a75c

quantum/plugins/nicira/QuantumPlugin.py
quantum/tests/unit/nicira/etc/quantum.conf.test [new file with mode: 0644]
quantum/tests/unit/nicira/test_nvpopts.py

index e088597e412b6e5c0ceb93bef0c5678d466792a6..f3b0b8cb7d3d49885f2fc91d0ed4ed23cf999b23 100644 (file)
@@ -22,6 +22,7 @@
 
 import hashlib
 import logging
+import os
 
 from oslo.config import cfg
 from sqlalchemy.orm import exc as sa_exc
@@ -71,6 +72,7 @@ LOG = logging.getLogger("QuantumPlugin")
 NVP_NOSNAT_RULES_ORDER = 10
 NVP_FLOATINGIP_NAT_RULES_ORDER = 224
 NVP_EXTGW_NAT_RULES_ORDER = 255
+NVP_EXT_PATH = os.path.join(os.path.dirname(__file__), 'extensions')
 
 
 # Provider network extension - allowed network types for the NVP Plugin
@@ -177,6 +179,9 @@ class NvpPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
                        'default': self._nvp_delete_port}
         }
 
+        # If no api_extensions_path is provided set the following
+        if not cfg.CONF.api_extensions_path:
+            cfg.CONF.set_override('api_extensions_path', NVP_EXT_PATH)
         self.nvp_opts = cfg.CONF.NVP
         self.cluster = create_nvp_cluster(cfg.CONF,
                                           self.nvp_opts.concurrent_connections,
diff --git a/quantum/tests/unit/nicira/etc/quantum.conf.test b/quantum/tests/unit/nicira/etc/quantum.conf.test
new file mode 100644 (file)
index 0000000..aa71633
--- /dev/null
@@ -0,0 +1,31 @@
+[DEFAULT]
+# Show more verbose log output (sets INFO log level output)
+verbose = True
+
+# Show debugging output in logs (sets DEBUG log level output)
+debug = False
+
+# Address to bind the API server
+bind_host = 0.0.0.0
+
+# Port the bind the API server to
+bind_port = 9696
+
+# MISSING Path to the extensions
+# api_extensions_path =
+
+# Paste configuration file
+api_paste_config = api-paste.ini.test
+
+# The messaging module to use, defaults to kombu.
+rpc_backend = quantum.openstack.common.rpc.impl_fake
+
+lock_path = $state_path/lock
+
+[DATABASE]
+sql_connection = 'sqlite:///:memory:'
+
+[default_servicetype]
+description = "default service type"
+service_definition=dummy:quantum.tests.unit.dummy_plugin.QuantumDummyPlugin
+
index e0b99f3b2b1a26695e5e2d49f18c748c43094c2c..c32aaa4efd53a20027c2cb84dbb3dde2be93753b 100644 (file)
@@ -28,6 +28,8 @@ from quantum.plugins.nicira import nvp_cluster
 
 BASE_CONF_PATH = os.path.join(os.path.dirname(__file__),
                               '../../etc/quantum.conf.test')
+NVP_BASE_CONF_PATH = os.path.join(os.path.dirname(__file__),
+                                  'etc/quantum.conf.test')
 NVP_INI_PATH = os.path.join(os.path.dirname(__file__),
                             'etc/nvp.ini.basic.test')
 NVP_INI_FULL_PATH = os.path.join(os.path.dirname(__file__),
@@ -136,6 +138,14 @@ class ConfigurationTest(testtools.TestCase):
         self.assertIsNone(cfg.CONF.default_l2_gw_service_uuid)
         self.assertEqual('breth0', cfg.CONF.default_interface_name)
 
+    def test_load_api_extensions(self):
+        q_config.parse(['--config-file', NVP_BASE_CONF_PATH,
+                        '--config-file', NVP_INI_FULL_PATH])
+        cfg.CONF.set_override('core_plugin', NVP_PLUGIN_PATH)
+        # Load the configuration, and initialize the plugin
+        QuantumManager().get_plugin()
+        self.assertIn('extensions', cfg.CONF.api_extensions_path)
+
 
 class OldConfigurationTest(testtools.TestCase):