예제 #1
0
def setup_extensions_middleware(extension_manager=None):
    extension_manager = (extension_manager or
                         PluginAwareExtensionManager(
                             extensions_path,
                             {constants.CORE: FakePluginWithExtension()}))
    config_file = 'quantum.conf.test'
    args = ['--config-file', etcdir(config_file)]
    config.parse(args=args)
    app = config.load_paste_app('extensions_test_app')
    return ExtensionMiddleware(app, ext_mgr=extension_manager)
예제 #2
0
    def test_extension_loaded_for_non_core_plugin(self):
        class NonCorePluginExtenstion(StubExtension):
            def get_plugin_interface(self):
                return None

        stub_plugin = StubPlugin(supported_extensions=["e1"])
        ext_mgr = PluginAwareExtensionManager('', {constants.DUMMY:
                                                   stub_plugin})
        ext_mgr.add_extension(NonCorePluginExtenstion("e1"))

        self.assertTrue("e1" in ext_mgr.extensions)
예제 #3
0
    def test_unsupported_extensions_are_not_loaded(self):
        stub_plugin = StubPlugin(supported_extensions=["e1", "e3"])
        ext_mgr = PluginAwareExtensionManager('',
                                              {constants.CORE: stub_plugin})

        ext_mgr.add_extension(StubExtension("e1"))
        ext_mgr.add_extension(StubExtension("e2"))
        ext_mgr.add_extension(StubExtension("e3"))

        self.assertTrue("e1" in ext_mgr.extensions)
        self.assertFalse("e2" in ext_mgr.extensions)
        self.assertTrue("e3" in ext_mgr.extensions)
예제 #4
0
    def setUp(self, core_plugin=None, lb_plugin=None):
        service_plugins = {'lb_plugin_name': DB_LB_PLUGIN_KLASS}

        super(LoadBalancerPluginDbTestCase,
              self).setUp(service_plugins=service_plugins)

        self._subnet_id = "0c798ed8-33ba-11e2-8b28-000c291c4d14"

        self.plugin = loadbalancer_plugin.LoadBalancerPlugin()
        ext_mgr = PluginAwareExtensionManager(
            extensions_path, {constants.LOADBALANCER: self.plugin})
        app = config.load_paste_app('extensions_test_app')
        self.ext_api = ExtensionMiddleware(app, ext_mgr=ext_mgr)
예제 #5
0
    def test_extensions_expecting_quantum_plugin_interface_are_loaded(self):
        class ExtensionForQuamtumPluginInterface(StubExtension):
            """
            This Extension does not implement get_plugin_interface method.
            This will work with any plugin implementing QuantumPluginBase
            """
            pass
        stub_plugin = StubPlugin(supported_extensions=["e1"])
        ext_mgr = PluginAwareExtensionManager('', {constants.CORE:
                                                   stub_plugin})
        ext_mgr.add_extension(ExtensionForQuamtumPluginInterface("e1"))

        self.assertTrue("e1" in ext_mgr.extensions)
예제 #6
0
    def test_extensions_are_not_loaded_for_plugins_unaware_of_extensions(self):
        class ExtensionUnawarePlugin(object):
            """
            This plugin does not implement supports_extension method.
            Extensions will not be loaded when this plugin is used.
            """
            pass

        ext_mgr = PluginAwareExtensionManager('',
                                              {constants.CORE:
                                               ExtensionUnawarePlugin()})
        ext_mgr.add_extension(StubExtension("e1"))

        self.assertFalse("e1" in ext_mgr.extensions)
예제 #7
0
    def test_extensions_without_need_for__plugin_interface_are_loaded(self):
        class ExtensionWithNoNeedForPluginInterface(StubExtension):
            """
            This Extension does not need any plugin interface.
            This will work with any plugin implementing QuantumPluginBase
            """
            def get_plugin_interface(self):
                return None

        stub_plugin = StubPlugin(supported_extensions=["e1"])
        ext_mgr = PluginAwareExtensionManager('', {constants.CORE:
                                                   stub_plugin})
        ext_mgr.add_extension(ExtensionWithNoNeedForPluginInterface("e1"))

        self.assertTrue("e1" in ext_mgr.extensions)
예제 #8
0
    def test_extensions_not_loaded_for_plugin_without_expected_interface(self):

        class PluginWithoutExpectedIface(object):
            """
            Plugin does not implement get_foo method as expected by extension
            """
            supported_extension_aliases = ["supported_extension"]

        ext_mgr = PluginAwareExtensionManager('',
                                              {constants.CORE:
                                               PluginWithoutExpectedIface()})
        ext_mgr.add_extension(
            ExtensionExpectingPluginInterface("supported_extension"))

        self.assertFalse("e1" in ext_mgr.extensions)
예제 #9
0
    def test_extensions_are_loaded_for_plugin_with_expected_interface(self):

        class PluginWithExpectedInterface(object):
            """
            This Plugin implements get_foo method as expected by extension
            """
            supported_extension_aliases = ["supported_extension"]

            def get_foo(self, bar=None):
                pass
        ext_mgr = PluginAwareExtensionManager('',
                                              {constants.CORE:
                                               PluginWithExpectedInterface()})
        ext_mgr.add_extension(
            ExtensionExpectingPluginInterface("supported_extension"))

        self.assertTrue("supported_extension" in ext_mgr.extensions)
예제 #10
0
def setup_extensions_middleware(extension_manager=None):
    extension_manager = (extension_manager or PluginAwareExtensionManager(
        EXTENSIONS_PATH, L2Network()))
    app = config.load_paste_app('extensions_test_app')
    return ExtensionMiddleware(app, ext_mgr=extension_manager)