Esempio n. 1
0
 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', PLUGIN_NAME)
     # Load the configuration, and initialize the plugin
     NeutronManager().get_plugin()
     self.assertIn('extensions', cfg.CONF.api_extensions_path)
Esempio n. 2
0
def main():
    eventlet.monkey_patch()

    # the configuration will be read into the cfg.CONF global data structure
    config.parse(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit(
            _("ERROR: Unable to find configuration file via the default"
              " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and"
              " the '--config-file' option!"))
    try:
        pool = eventlet.GreenPool()

        neutron_api = service.serve_wsgi(service.NeutronApiService)
        api_thread = pool.spawn(neutron_api.wait)

        try:
            neutron_rpc = service.serve_rpc()
        except NotImplementedError:
            LOG.info(_("RPC was already started in parent process by plugin."))
        else:
            rpc_thread = pool.spawn(neutron_rpc.wait)

            # api and rpc should die together.  When one dies, kill the other.
            rpc_thread.link(lambda gt: api_thread.kill())
            api_thread.link(lambda gt: rpc_thread.kill())

        pool.waitall()
    except KeyboardInterrupt:
        pass
    except RuntimeError as e:
        sys.exit(_("ERROR: %s") % e)
Esempio n. 3
0
    def setUp(self):
        super(FirewallExtensionTestCase, self).setUp()
        plugin = "neutron.extensions.firewall.FirewallPluginBase"
        # Ensure 'stale' patched copies of the plugin are never returned
        manager.NeutronManager._instance = None

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Create the default configurations
        args = ["--config-file", test_api_v2.etcdir("neutron.conf.test")]
        config.parse(args)

        # Stubbing core plugin with Firewall plugin
        cfg.CONF.set_override("core_plugin", plugin)
        cfg.CONF.set_override("service_plugins", [plugin])

        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()
        instance = self.plugin.return_value
        instance.get_plugin_type.return_value = constants.FIREWALL

        ext_mgr = FirewallTestExtensionManager()
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.api = webtest.TestApp(self.ext_mdw)
        super(FirewallExtensionTestCase, self).setUp()
Esempio n. 4
0
    def setUp(self):
        super(QuotaExtensionTestCase, self).setUp()
        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Save the global RESOURCE_ATTRIBUTE_MAP
        self.saved_attr_map = {}
        for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
            self.saved_attr_map[resource] = attrs.copy()

        # Create the default configurations
        args = ['--config-file', test_extensions.etcdir('neutron.conf.test')]
        config.parse(args=args)

        # Update the plugin and extensions path
        self.setup_coreplugin(TARGET_PLUGIN)
        cfg.CONF.set_override('quota_items',
                              ['network', 'subnet', 'port', 'extra1'],
                              group='QUOTAS')
        quota.QUOTAS = quota.QuotaEngine()
        quota.register_resources_from_config()
        self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True)
        self.plugin = self._plugin_patcher.start()
        self.plugin.return_value.supported_extension_aliases = ['quotas']
        # QUOTAS will register the items in conf when starting
        # extra1 here is added later, so have to do it manually
        quota.QUOTAS.register_resource_by_name('extra1')
        ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
        db.configure_db()
        app = config.load_paste_app('extensions_test_app')
        ext_middleware = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr)
        self.api = webtest.TestApp(ext_middleware)
Esempio n. 5
0
    def setUp(self):
        super(NetworkGatewayExtensionTestCase, self).setUp()
        plugin = '%s.%s' % (networkgw.__name__,
                            networkgw.NetworkGatewayPluginBase.__name__)
        self._resource = networkgw.RESOURCE_NAME.replace('-', '_')

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Create the default configurations
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args=args)

        # Update the plugin and extensions path
        self.setup_coreplugin(plugin)
        self.addCleanup(cfg.CONF.reset)

        _plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = _plugin_patcher.start()
        self.addCleanup(_plugin_patcher.stop)

        # Instantiate mock plugin and enable extensions
        manager.NeutronManager.get_plugin().supported_extension_aliases = (
            [networkgw.EXT_ALIAS])
        ext_mgr = TestExtensionManager()
        PluginAwareExtensionManager._instance = ext_mgr
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.api = webtest.TestApp(self.ext_mdw)

        quota.QUOTAS._driver = None
        cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
                              group='QUOTAS')
    def setUp(self):
        super(RouterServiceInsertionTestCase, self).setUp()
        plugin = (
            "neutron.tests.unit.test_routerserviceinsertion."
            "RouterServiceInsertionTestPlugin"
        )

        # point config file to: neutron/tests/etc/neutron.conf.test
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args=args)

        #just stubbing core plugin with LoadBalancer plugin
        self.setup_coreplugin(plugin)
        cfg.CONF.set_override('service_plugins', [])
        cfg.CONF.set_override('quota_router', -1, group='QUOTAS')
        self.addCleanup(cfg.CONF.reset)

        # Ensure existing ExtensionManager is not used

        ext_mgr = extensions.PluginAwareExtensionManager(
            extensions_path,
            {constants.LOADBALANCER: RouterServiceInsertionTestPlugin()}
        )
        extensions.PluginAwareExtensionManager._instance = ext_mgr
        router.APIRouter()

        app = config.load_paste_app('extensions_test_app')
        self._api = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr)

        self._tenant_id = "8c70909f-b081-452d-872b-df48e6c355d1"

        self._service_type_id = _uuid()

        self._setup_core_resources()
    def setUp(self):
        super(ExtensionExtendedAttributeTestCase, self).setUp()
        plugin = "neutron.tests.unit.test_extension_extended_attribute." "ExtensionExtendedAttributeTestPlugin"

        # point config file to: neutron/tests/etc/neutron.conf.test
        args = ["--config-file", test_api_v2.etcdir("neutron.conf.test")]
        config.parse(args=args)

        self.setup_coreplugin(plugin)

        ext_mgr = extensions.PluginAwareExtensionManager(
            extensions_path, {constants.CORE: ExtensionExtendedAttributeTestPlugin}
        )
        ext_mgr.extend_resources("2.0", {})
        extensions.PluginAwareExtensionManager._instance = ext_mgr

        app = config.load_paste_app("extensions_test_app")
        self._api = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr)

        self._tenant_id = "8c70909f-b081-452d-872b-df48e6c355d1"
        # Save the global RESOURCE_ATTRIBUTE_MAP
        self.saved_attr_map = {}
        for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
            self.saved_attr_map[resource] = attrs.copy()
        # Add the resources to the global attribute map
        # This is done here as the setup process won't
        # initialize the main API router which extends
        # the global attribute map
        attributes.RESOURCE_ATTRIBUTE_MAP.update(extattr.EXTENDED_ATTRIBUTES_2_0)
        self.agentscheduler_dbMinxin = manager.NeutronManager.get_plugin()
        self.addCleanup(cfg.CONF.reset)
        self.addCleanup(self.restore_attribute_map)

        quota.QUOTAS._driver = None
        cfg.CONF.set_override("quota_driver", "neutron.quota.ConfDriver", group="QUOTAS")
Esempio n. 8
0
def main():
    eventlet.monkey_patch()

    # the configuration will be read into the cfg.CONF global data structure
    config.parse(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit(
            _(
                "ERROR: Unable to find configuration file via the default"
                " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and"
                " the '--config-file' option!"
            )
        )
    try:
        pool = eventlet.GreenPool()

        neutron_api = service.serve_wsgi(service.NeutronApiService)
        api_thread = pool.spawn(neutron_api.wait)

        try:
            neutron_rpc = service.serve_rpc()
        except NotImplementedError:
            LOG.info(_("RPC was already started in parent process by plugin."))
        else:
            rpc_thread = pool.spawn(neutron_rpc.wait)

            # api and rpc should die together.  When one dies, kill the other.
            rpc_thread.link(lambda gt: api_thread.kill())
            api_thread.link(lambda gt: rpc_thread.kill())

        pool.waitall()
    except KeyboardInterrupt:
        pass
    except RuntimeError as e:
        sys.exit(_("ERROR: %s") % e)
Esempio n. 9
0
    def setUp(self):
        super(VpnaasExtensionTestCase, self).setUp()
        plugin = 'neutron.extensions.vpnaas.VPNPluginBase'

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Create the default configurations
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args)

        #just stubbing core plugin with LoadBalancer plugin
        self.setup_coreplugin(plugin)
        cfg.CONF.set_override('service_plugins', [plugin])

        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()
        instance = self.plugin.return_value
        instance.get_plugin_type.return_value = constants.VPN

        ext_mgr = VpnaasTestExtensionManager()
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.api = webtest.TestApp(self.ext_mdw)
        super(VpnaasExtensionTestCase, self).setUp()

        quota.QUOTAS._driver = None
        cfg.CONF.set_override('quota_driver', 'neutron.quota.ConfDriver',
                              group='QUOTAS')
    def setUp(self):
        super(LoadBalancerExtensionTestCase, self).setUp()
        plugin = 'neutron.extensions.loadbalancer.LoadBalancerPluginBase'
        # Ensure 'stale' patched copies of the plugin are never returned
        manager.NeutronManager._instance = None

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Create the default configurations
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args)

        #just stubbing core plugin with LoadBalancer plugin
        cfg.CONF.set_override('core_plugin', plugin)
        cfg.CONF.set_override('service_plugins', [plugin])

        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()
        instance = self.plugin.return_value
        instance.get_plugin_type.return_value = constants.LOADBALANCER

        ext_mgr = LoadBalancerTestExtensionManager()
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.api = webtest.TestApp(self.ext_mdw)
        super(LoadBalancerExtensionTestCase, self).setUp()
Esempio n. 11
0
 def test_load_api_extensions(self):
     q_config.parse(['--config-file', BASE_CONF_PATH,
                     '--config-file', NSX_INI_FULL_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     # Load the configuration, and initialize the plugin
     NeutronManager().get_plugin()
     self.assertIn('extensions', cfg.CONF.api_extensions_path)
Esempio n. 12
0
    def setUp(self):
        super(VpnaasExtensionTestCase, self).setUp()
        plugin = 'neutron.extensions.vpnaas.VPNPluginBase'
        # Ensure 'stale' patched copies of the plugin are never returned
        manager.NeutronManager._instance = None

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Create the default configurations
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args)

        #just stubbing core plugin with LoadBalancer plugin
        cfg.CONF.set_override('core_plugin', plugin)
        cfg.CONF.set_override('service_plugins', [plugin])

        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()
        instance = self.plugin.return_value
        instance.get_plugin_type.return_value = constants.VPN

        ext_mgr = VpnaasTestExtensionManager()
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.api = webtest.TestApp(self.ext_mdw)
        super(VpnaasExtensionTestCase, self).setUp()
Esempio n. 13
0
 def test_load_plugin_with_full_options(self):
     q_config.parse(["--config-file", BASE_CONF_PATH, "--config-file", NVP_INI_FULL_PATH])
     cfg.CONF.set_override("core_plugin", PLUGIN_NAME)
     plugin = NeutronManager().get_plugin()
     cluster = plugin.cluster
     self._assert_required_options(cluster)
     self._assert_extra_options(cluster)
Esempio n. 14
0
    def setUp(self):
        super(NetworkGatewayExtensionTestCase, self).setUp()
        plugin = '%s.%s' % (networkgw.__name__,
                            networkgw.NetworkGatewayPluginBase.__name__)
        self._resource = networkgw.RESOURCE_NAME.replace('-', '_')

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Create the default configurations
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args=args)

        # Update the plugin and extensions path
        self.setup_coreplugin(plugin)
        self.addCleanup(cfg.CONF.reset)

        _plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = _plugin_patcher.start()
        self.addCleanup(_plugin_patcher.stop)

        # Instantiate mock plugin and enable extensions
        manager.NeutronManager.get_plugin().supported_extension_aliases = ([
            networkgw.EXT_ALIAS
        ])
        ext_mgr = TestExtensionManager()
        PluginAwareExtensionManager._instance = ext_mgr
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.api = webtest.TestApp(self.ext_mdw)

        quota.QUOTAS._driver = None
        cfg.CONF.set_override('quota_driver',
                              'neutron.quota.ConfDriver',
                              group='QUOTAS')
Esempio n. 15
0
 def test_agent_extensions(self):
     q_config.parse(["--config-file", NVP_BASE_CONF_PATH, "--config-file", NVP_INI_FULL_PATH])
     cfg.CONF.set_override("core_plugin", PLUGIN_NAME)
     self.assertEqual(config.AgentModes.AGENT, cfg.CONF.NVP.agent_mode)
     plugin = NeutronManager().get_plugin()
     self.assertIn("agent", plugin.supported_extension_aliases)
     self.assertIn("dhcp_agent_scheduler", plugin.supported_extension_aliases)
    def setUp(self):
        super(RouterServiceInsertionTestCase, self).setUp()
        plugin = ("neutron.tests.unit.test_routerserviceinsertion."
                  "RouterServiceInsertionTestPlugin")

        # point config file to: neutron/tests/etc/neutron.conf.test
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args=args)

        #just stubbing core plugin with LoadBalancer plugin
        cfg.CONF.set_override('core_plugin', plugin)
        cfg.CONF.set_override('service_plugins', [])
        cfg.CONF.set_override('quota_router', -1, group='QUOTAS')
        self.addCleanup(cfg.CONF.reset)

        # Ensure 'stale' patched copies of the plugin are never returned
        neutron.manager.NeutronManager._instance = None

        # Ensure existing ExtensionManager is not used

        ext_mgr = extensions.PluginAwareExtensionManager(
            extensions_path,
            {constants.LOADBALANCER: RouterServiceInsertionTestPlugin()})
        extensions.PluginAwareExtensionManager._instance = ext_mgr
        router.APIRouter()

        app = config.load_paste_app('extensions_test_app')
        self._api = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr)

        self._tenant_id = "8c70909f-b081-452d-872b-df48e6c355d1"

        self._service_type_id = _uuid()

        self._setup_core_resources()
Esempio n. 17
0
    def setUp(self):
        super(LoadBalancerExtensionTestCase, self).setUp()
        plugin = 'neutron.extensions.loadbalancer.LoadBalancerPluginBase'

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Create the default configurations
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args)

        #just stubbing core plugin with LoadBalancer plugin
        self.setup_coreplugin(plugin)
        cfg.CONF.set_override('service_plugins', [plugin])

        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()
        instance = self.plugin.return_value
        instance.get_plugin_type.return_value = constants.LOADBALANCER

        ext_mgr = LoadBalancerTestExtensionManager()
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.api = webtest.TestApp(self.ext_mdw)

        quota.QUOTAS._driver = None
        cfg.CONF.set_override('quota_driver',
                              quota.QUOTA_CONF_DRIVER,
                              group='QUOTAS')

        super(LoadBalancerExtensionTestCase, self).setUp()
Esempio n. 18
0
    def setUp(self):
        super(QuotaExtensionTestCase, self).setUp()
        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Save the global RESOURCE_ATTRIBUTE_MAP
        self.saved_attr_map = {}
        for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
            self.saved_attr_map[resource] = attrs.copy()

        # Create the default configurations
        args = ['--config-file', test_extensions.etcdir('neutron.conf.test')]
        config.parse(args=args)

        # Update the plugin and extensions path
        self.setup_coreplugin(TARGET_PLUGIN)
        cfg.CONF.set_override(
            'quota_items',
            ['network', 'subnet', 'port', 'extra1'],
            group='QUOTAS')
        quota.QUOTAS = quota.QuotaEngine()
        quota.register_resources_from_config()
        self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True)
        self.plugin = self._plugin_patcher.start()
        self.plugin.return_value.supported_extension_aliases = ['quotas']
        # QUOTAS will register the items in conf when starting
        # extra1 here is added later, so have to do it manually
        quota.QUOTAS.register_resource_by_name('extra1')
        ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
        db.configure_db()
        app = config.load_paste_app('extensions_test_app')
        ext_middleware = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr)
        self.api = webtest.TestApp(ext_middleware)
Esempio n. 19
0
 def setUp(self):
     super(NeutronManagerTestCase, self).setUp()
     args = ["--config-file", etcdir("neutron.conf.test")]
     # If test_config specifies some config-file, use it, as well
     config.parse(args=args)
     NeutronManager._instance = None
     self.addCleanup(cfg.CONF.reset)
     self.useFixture(fixtures.MonkeyPatch("neutron.manager.NeutronManager._instance"))
Esempio n. 20
0
 def test_load_plugin_with_full_options(self):
     q_config.parse(['--config-file', BASE_CONF_PATH,
                     '--config-file', NSX_INI_FULL_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     plugin = NeutronManager().get_plugin()
     cluster = plugin.cluster
     self._assert_required_options(cluster)
     self._assert_extra_options(cluster)
Esempio n. 21
0
    def setUp(self):
        # Point config file to: neutron/tests/etc/neutron.conf.test
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args=args)

        super(TestCiscoPluginModel, self).setUp()

        self.addCleanup(cisco_config.CONF.reset)
Esempio n. 22
0
 def setUp(self):
     super(NeutronManagerTestCase, self).setUp()
     args = ['--config-file', etcdir('neutron.conf.test')]
     # If test_config specifies some config-file, use it, as well
     config.parse(args=args)
     self.setup_coreplugin()
     self.useFixture(
         fixtures.MonkeyPatch('neutron.manager.NeutronManager._instance'))
Esempio n. 23
0
 def test_agentless_extensions(self):
     self.skipTest("Enable once agentless support is added")
     q_config.parse(["--config-file", NVP_BASE_CONF_PATH, "--config-file", NVP_INI_AGENTLESS_PATH])
     cfg.CONF.set_override("core_plugin", PLUGIN_NAME)
     self.assertEqual(config.AgentModes.AGENTLESS, cfg.CONF.NVP.agent_mode)
     plugin = NeutronManager().get_plugin()
     self.assertNotIn("agent", plugin.supported_extension_aliases)
     self.assertNotIn("dhcp_agent_scheduler", plugin.supported_extension_aliases)
Esempio n. 24
0
    def setUp(self):
        # Point config file to: neutron/tests/etc/neutron.conf.test
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args=args)

        super(TestCiscoPluginModel, self).setUp()

        self.addCleanup(cisco_config.CONF.reset)
Esempio n. 25
0
 def setUp(self):
     super(NeutronManagerTestCase, self).setUp()
     args = ['--config-file', etcdir('neutron.conf.test')]
     # If test_config specifies some config-file, use it, as well
     config.parse(args=args)
     NeutronManager._instance = None
     self.addCleanup(cfg.CONF.reset)
     self.useFixture(
         fixtures.MonkeyPatch('neutron.manager.NeutronManager._instance'))
Esempio n. 26
0
 def config_parse(conf=None, args=None):
     """Create the default configurations."""
     # neutron.conf.test includes rpc_backend which needs to be cleaned up
     if args is None:
         args = ['--config-file', etcdir('neutron.conf.test')]
     if conf is None:
         config.parse(args=args)
     else:
         conf(args)
Esempio n. 27
0
 def config_parse(conf=None, args=None):
     """Create the default configurations."""
     # neutron.conf.test includes rpc_backend which needs to be cleaned up
     if args is None:
         args = ['--config-file', etcdir('neutron.conf.test')]
     if conf is None:
         config.parse(args=args)
     else:
         conf(args)
Esempio n. 28
0
def setup_extensions_middleware(extension_manager=None):
    extension_manager = (extension_manager or
                         extensions.PluginAwareExtensionManager(
                             extensions_path,
                             {constants.CORE: FakePluginWithExtension()}))
    config_file = 'neutron.conf.test'
    args = ['--config-file', etcdir(config_file)]
    config.parse(args=args)
    app = config.load_paste_app('extensions_test_app')
    return extensions.ExtensionMiddleware(app, ext_mgr=extension_manager)
Esempio n. 29
0
 def test_agent_extensions(self):
     q_config.parse([
         '--config-file', BASE_CONF_PATH, '--config-file', NSX_INI_FULL_PATH
     ])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     self.assertEqual(config.AgentModes.AGENT, cfg.CONF.NSX.agent_mode)
     plugin = NeutronManager().get_plugin()
     self.assertIn('agent', plugin.supported_extension_aliases)
     self.assertIn('dhcp_agent_scheduler',
                   plugin.supported_extension_aliases)
Esempio n. 30
0
def setup_extensions_middleware(extension_manager=None):
    extension_manager = (extension_manager or
                         extensions.PluginAwareExtensionManager(
                             extensions_path,
                             {constants.CORE: FakePluginWithExtension()}))
    config_file = 'neutron.conf.test'
    args = ['--config-file', etcdir(config_file)]
    config.parse(args=args)
    app = config.load_paste_app('extensions_test_app')
    return extensions.ExtensionMiddleware(app, ext_mgr=extension_manager)
Esempio n. 31
0
def main():
    cfg.CONF.register_cli_opts(OPTS)
    cfg.CONF.set_override('use_stderr', True)
    config.setup_logging(cfg.CONF)
    config.parse(sys.argv[1:], default_config_files=[])

    if cfg.CONF.config_file:
        enable_tests_from_config()

    return 0 if all_tests_passed() else 1
Esempio n. 32
0
def main():
    cfg.CONF.register_cli_opts(OPTS)
    cfg.CONF.set_override('use_stderr', True)
    config.setup_logging(cfg.CONF)
    config.parse(sys.argv[1:], default_config_files=[])

    if cfg.CONF.config_file:
        enable_tests_from_config()

    return 0 if all_tests_passed() else 1
Esempio n. 33
0
 def test_agentless_extensions_version_fail(self):
     q_config.parse(['--config-file', BASE_CONF_PATH,
                     '--config-file', NSX_INI_AGENTLESS_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     self.assertEqual(config.AgentModes.AGENTLESS,
                      cfg.CONF.NSX.agent_mode)
     with mock.patch.object(client.NsxApiClient,
                            'get_version',
                            return_value=version.Version("3.2")):
         self.assertRaises(exceptions.NsxPluginException, NeutronManager)
Esempio n. 34
0
 def test_agentless_extensions_version_fail(self):
     q_config.parse(['--config-file', BASE_CONF_PATH,
                     '--config-file', NSX_INI_AGENTLESS_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     self.assertEqual(config.AgentModes.AGENTLESS,
                      cfg.CONF.NSX.agent_mode)
     with mock.patch.object(client.NsxApiClient,
                            'get_version',
                            return_value=version.Version("3.2")):
         self.assertRaises(exceptions.NsxPluginException, NeutronManager)
Esempio n. 35
0
 def test_agent_extensions(self):
     q_config.parse(['--config-file', BASE_CONF_PATH,
                     '--config-file', NSX_INI_FULL_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     self.assertEqual(config.AgentModes.AGENT,
                      cfg.CONF.NSX.agent_mode)
     plugin = NeutronManager().get_plugin()
     self.assertIn('agent',
                   plugin.supported_extension_aliases)
     self.assertIn('dhcp_agent_scheduler',
                   plugin.supported_extension_aliases)
Esempio n. 36
0
 def test_load_plugin_with_deprecated_options(self):
     q_config.parse(["--config-file", BASE_CONF_PATH, "--config-file", NVP_INI_DEPR_PATH])
     cfg.CONF.set_override("core_plugin", PLUGIN_NAME)
     plugin = NeutronManager().get_plugin()
     cluster = plugin.cluster
     self._assert_required_options(cluster)
     # Verify nvp_controller_connection has been fully parsed
     self.assertEqual(4, cluster.req_timeout)
     self.assertEqual(3, cluster.http_timeout)
     self.assertEqual(2, cluster.retries)
     self.assertEqual(1, cluster.redirects)
Esempio n. 37
0
 def test_agentless_extensions(self):
     self.skipTest('Enable once agentless support is added')
     q_config.parse([
         '--config-file', NVP_BASE_CONF_PATH, '--config-file',
         NVP_INI_AGENTLESS_PATH
     ])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     self.assertEqual(config.AgentModes.AGENTLESS, cfg.CONF.NVP.agent_mode)
     plugin = NeutronManager().get_plugin()
     self.assertNotIn('agent', plugin.supported_extension_aliases)
     self.assertNotIn('dhcp_agent_scheduler',
                      plugin.supported_extension_aliases)
Esempio n. 38
0
 def test_load_plugin_with_deprecated_options(self):
     q_config.parse(['--config-file', BASE_CONF_PATH,
                     '--config-file', NVP_INI_DEPR_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     plugin = NeutronManager().get_plugin()
     cluster = plugin.cluster
     # Verify old nvp_* params have been fully parsed
     self._assert_required_options(cluster)
     self.assertEqual(4, cluster.req_timeout)
     self.assertEqual(3, cluster.http_timeout)
     self.assertEqual(2, cluster.retries)
     self.assertEqual(2, cluster.redirects)
Esempio n. 39
0
 def test_load_plugin_with_deprecated_options(self):
     q_config.parse(['--config-file', BASE_CONF_PATH,
                     '--config-file', NVP_INI_DEPR_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     plugin = NeutronManager().get_plugin()
     cluster = plugin.cluster
     # Verify old nvp_* params have been fully parsed
     self._assert_required_options(cluster)
     self.assertEqual(4, cluster.req_timeout)
     self.assertEqual(3, cluster.http_timeout)
     self.assertEqual(2, cluster.retries)
     self.assertEqual(2, cluster.redirects)
Esempio n. 40
0
    def setUp(self):
        # mock nvp api client
        self.fc = fake_nvpapiclient.FakeClient(STUBS_PATH)
        mock_nvpapi = mock.patch(NVPAPI_NAME, autospec=True)
        # Avoid runs of the synchronizer looping call
        # These unit tests will excplicitly invoke synchronization
        patch_sync = mock.patch.object(sync, '_start_loopingcall')
        self.mock_nvpapi = mock_nvpapi.start()
        patch_sync.start()
        self.mock_nvpapi.return_value.login.return_value = "the_cookie"
        # Emulate tests against NVP 3.x
        self.mock_nvpapi.return_value.get_nvp_version.return_value = (
            NvpApiClient.NVPVersion("3.1"))

        def _fake_request(*args, **kwargs):
            return self.fc.fake_request(*args, **kwargs)

        self.mock_nvpapi.return_value.request.side_effect = _fake_request
        self.fake_cluster = nsx_cluster.NSXCluster(
            name='fake-cluster',
            nsx_controllers=['1.1.1.1:999'],
            default_tz_uuid=_uuid(),
            nsx_user='******',
            nsx_password='******')
        self.fake_cluster.api_client = NvpApiClient.NVPApiHelper(
            ('1.1.1.1', '999', True), self.fake_cluster.nsx_user,
            self.fake_cluster.nsx_password, self.fake_cluster.req_timeout,
            self.fake_cluster.http_timeout, self.fake_cluster.retries,
            self.fake_cluster.redirects)
        # Instantiate Neutron plugin
        # and setup needed config variables
        args = [
            '--config-file',
            get_fake_conf('neutron.conf.test'), '--config-file',
            get_fake_conf('nsx.ini.test')
        ]
        config.parse(args=args)
        cfg.CONF.set_override('allow_overlapping_ips', True)
        self._plugin = NeutronPlugin.NvpPluginV2()
        # Mock neutron manager plugin load functions to speed up tests
        mock_nm_get_plugin = mock.patch('neutron.manager.NeutronManager.'
                                        'get_plugin')
        mock_nm_get_service_plugins = mock.patch(
            'neutron.manager.NeutronManager.get_service_plugins')
        self.mock_nm_get_plugin = mock_nm_get_plugin.start()
        self.mock_nm_get_plugin.return_value = self._plugin
        mock_nm_get_service_plugins.start()
        super(NvpSyncTestCase, self).setUp()
        self.addCleanup(self.fc.reset_all)
        self.addCleanup(patch_sync.stop)
        self.addCleanup(mock_nvpapi.stop)
        self.addCleanup(mock_nm_get_plugin.stop)
        self.addCleanup(mock_nm_get_service_plugins.stop)
Esempio n. 41
0
def main():
    # the configuration will be read into the cfg.CONF global data structure
    config.parse(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit(_("ERROR: Unable to find configuration file via the default"
                   " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and"
                   " the '--config-file' option!"))
    try:
        neutron_service = service.serve_wsgi(service.NeutronApiService)
        neutron_service.wait()
    except RuntimeError as e:
        sys.exit(_("ERROR: %s") % e)
Esempio n. 42
0
    def setUp(self):

        n_config.parse(['--config-file', VCNS_CONFIG_FILE])
        # mock vcns
        self.fc2 = fake_vcns.FakeVcns(unique_router_name=False)
        self.mock_vcns = mock.patch(VCNS_NAME, autospec=True)
        self.vcns_loadbalancer_patch()

        self.driver = vcns_driver.VcnsDriver(mock.Mock())

        super(VcnsDriverTestCase, self).setUp()
        self.addCleanup(self.fc2.reset_all)
        self.addCleanup(self.mock_vcns.stop)
Esempio n. 43
0
    def setUp(self):

        n_config.parse(['--config-file', VCNS_CONFIG_FILE])
        # mock vcns
        self.fc2 = fake_vcns.FakeVcns(unique_router_name=False)
        self.mock_vcns = mock.patch(VCNS_NAME, autospec=True)
        self.vcns_loadbalancer_patch()

        self.driver = vcns_driver.VcnsDriver(mock.Mock())

        super(VcnsDriverTestCase, self).setUp()
        self.addCleanup(self.fc2.reset_all)
        self.addCleanup(self.mock_vcns.stop)
Esempio n. 44
0
    def setUp(self):
        # mock nvp api client
        self.fc = fake_nvpapiclient.FakeClient(STUBS_PATH)
        mock_nvpapi = mock.patch(NVPAPI_NAME, autospec=True)
        # Avoid runs of the synchronizer looping call
        # These unit tests will excplicitly invoke synchronization
        patch_sync = mock.patch.object(sync, "_start_loopingcall")
        self.mock_nvpapi = mock_nvpapi.start()
        patch_sync.start()
        self.mock_nvpapi.return_value.login.return_value = "the_cookie"
        # Emulate tests against NVP 3.x
        self.mock_nvpapi.return_value.get_nvp_version.return_value = NvpApiClient.NVPVersion("3.1")

        def _fake_request(*args, **kwargs):
            return self.fc.fake_request(*args, **kwargs)

        self.mock_nvpapi.return_value.request.side_effect = _fake_request
        self.fake_cluster = nvp_cluster.NVPCluster(
            name="fake-cluster",
            nvp_controllers=["1.1.1.1:999"],
            default_tz_uuid=_uuid(),
            nvp_user="******",
            nvp_password="******",
        )
        self.fake_cluster.api_client = NvpApiClient.NVPApiHelper(
            ("1.1.1.1", "999", True),
            self.fake_cluster.nvp_user,
            self.fake_cluster.nvp_password,
            self.fake_cluster.req_timeout,
            self.fake_cluster.http_timeout,
            self.fake_cluster.retries,
            self.fake_cluster.redirects,
        )
        # Instantiate Neutron plugin
        # and setup needed config variables
        args = ["--config-file", get_fake_conf("neutron.conf.test"), "--config-file", get_fake_conf("nvp.ini.test")]
        config.parse(args=args)
        cfg.CONF.set_override("allow_overlapping_ips", True)
        self._plugin = NeutronPlugin.NvpPluginV2()
        # Mock neutron manager plugin load functions to speed up tests
        mock_nm_get_plugin = mock.patch("neutron.manager.NeutronManager." "get_plugin")
        mock_nm_get_service_plugins = mock.patch("neutron.manager.NeutronManager.get_service_plugins")
        self.mock_nm_get_plugin = mock_nm_get_plugin.start()
        self.mock_nm_get_plugin.return_value = self._plugin
        mock_nm_get_service_plugins.start()
        super(NvpSyncTestCase, self).setUp()
        self.addCleanup(self.fc.reset_all)
        self.addCleanup(patch_sync.stop)
        self.addCleanup(mock_nvpapi.stop)
        self.addCleanup(mock_nm_get_plugin.stop)
        self.addCleanup(mock_nm_get_service_plugins.stop)
Esempio n. 45
0
def main():
    eventlet.monkey_patch()

    # the configuration will be read into the cfg.CONF global data structure
    config.parse(sys.argv[1:])
    if not cfg.CONF.config_file:
        sys.exit(_("ERROR: Unable to find configuration file via the default"
                   " search paths (~/.neutron/, ~/, /etc/neutron/, /etc/) and"
                   " the '--config-file' option!"))
    try:
        neutron_service = service.serve_wsgi(service.NeutronApiService)
        neutron_service.wait()
    except RuntimeError as e:
        sys.exit(_("ERROR: %s") % e)
Esempio n. 46
0
 def test_agentless_extensions_unmet_deps_fail(self):
     q_config.parse(['--config-file', NVP_BASE_CONF_PATH,
                     '--config-file', NVP_INI_AGENTLESS_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     self.assertEqual(config.AgentModes.AGENTLESS,
                      cfg.CONF.NVP.agent_mode)
     with mock.patch.object(nvp_client.NVPApiHelper,
                            'get_nvp_version',
                            return_value=nvp_client.NVPVersion("3.2")):
         with mock.patch.object(lsnlib,
                                'service_cluster_exists',
                                return_value=False):
             self.assertRaises(exceptions.NvpPluginException,
                               NeutronManager)
Esempio n. 47
0
    def setUp(self):
        super(VcnsDriverTestCase, self).setUp()

        n_config.parse(['--config-file', VCNS_CONFIG_FILE])

        self.fc = fake_vcns.FakeVcns()
        self.mock_vcns = mock.patch(VCNS_NAME, autospec=True)
        self.vcns_patch()

        self.addCleanup(self.fc.reset_all)

        self.vcns_driver = vcns_driver.VcnsDriver(self)

        self.edge_id = None
        self.result = None
Esempio n. 48
0
    def setUp(self):
        super(VcnsDriverTestCase, self).setUp()

        n_config.parse(['--config-file', VCNS_CONFIG_FILE])

        self.fc = fake_vcns.FakeVcns()
        self.mock_vcns = mock.patch(VCNS_NAME, autospec=True)
        self.vcns_patch()

        self.addCleanup(self.fc.reset_all)

        self.vcns_driver = vcns_driver.VcnsDriver(self)

        self.edge_id = None
        self.result = None
Esempio n. 49
0
    def setUp(self):

        n_config.parse(['--config-file', VCNS_CONFIG_FILE])
        # mock vcns
        self.fc2 = fake_vcns.FakeVcns(unique_router_name=False)
        self.mock_vcns = mock.patch(VCNS_NAME, autospec=True)
        self.vcns_firewall_patch()

        self.nvp_service_plugin_callback = mock.Mock()
        self.driver = vcns_driver.VcnsDriver(self.nvp_service_plugin_callback)

        super(VcnsDriverTestCase, self).setUp()
        self.addCleanup(self.fc2.reset_all)
        self.addCleanup(self.mock_vcns.stop)

        self.tenant_id = _uuid()
        self.subnet_id = _uuid()
Esempio n. 50
0
    def setUp(self):
        # mock api client
        self.fc = fake.FakeClient(STUBS_PATH)
        mock_api = mock.patch(NSXAPI_NAME, autospec=True)
        # Avoid runs of the synchronizer looping call
        # These unit tests will excplicitly invoke synchronization
        patch_sync = mock.patch.object(sync, '_start_loopingcall')
        self.mock_api = mock_api.start()
        patch_sync.start()
        self.mock_api.return_value.login.return_value = "the_cookie"
        # Emulate tests against NSX 3.x
        self.mock_api.return_value.get_version.return_value = (
            version.Version("3.1"))

        self.mock_api.return_value.request.side_effect = self.fc.fake_request
        self.fake_cluster = cluster.NSXCluster(
            name='fake-cluster', nsx_controllers=['1.1.1.1:999'],
            default_tz_uuid=_uuid(), nsx_user='******', nsx_password='******')
        self.fake_cluster.api_client = client.NsxApiClient(
            ('1.1.1.1', '999', True),
            self.fake_cluster.nsx_user, self.fake_cluster.nsx_password,
            request_timeout=self.fake_cluster.req_timeout,
            http_timeout=self.fake_cluster.http_timeout,
            retries=self.fake_cluster.retries,
            redirects=self.fake_cluster.redirects)
        # Instantiate Neutron plugin
        # and setup needed config variables
        args = ['--config-file', get_fake_conf('neutron.conf.test'),
                '--config-file', get_fake_conf('nsx.ini.test')]
        config.parse(args=args)
        cfg.CONF.set_override('allow_overlapping_ips', True)
        self._plugin = plugin.NsxPlugin()
        # Mock neutron manager plugin load functions to speed up tests
        mock_nm_get_plugin = mock.patch('neutron.manager.NeutronManager.'
                                        'get_plugin')
        mock_nm_get_service_plugins = mock.patch(
            'neutron.manager.NeutronManager.get_service_plugins')
        self.mock_nm_get_plugin = mock_nm_get_plugin.start()
        self.mock_nm_get_plugin.return_value = self._plugin
        mock_nm_get_service_plugins.start()
        super(SyncTestCase, self).setUp()
        self.addCleanup(self.fc.reset_all)
        self.addCleanup(patch_sync.stop)
        self.addCleanup(mock_api.stop)
        self.addCleanup(mock_nm_get_plugin.stop)
        self.addCleanup(mock_nm_get_service_plugins.stop)
Esempio n. 51
0
    def setUp(self):

        n_config.parse(['--config-file', VCNS_CONFIG_FILE])
        # mock vcns
        self.fc2 = fake_vcns.FakeVcns(unique_router_name=False)
        self.mock_vcns = mock.patch(VCNS_NAME, autospec=True)
        self.vcns_firewall_patch()

        self.nvp_service_plugin_callback = mock.Mock()
        self.driver = vcns_driver.VcnsDriver(self.nvp_service_plugin_callback)

        super(VcnsDriverTestCase, self).setUp()
        self.addCleanup(self.fc2.reset_all)
        self.addCleanup(self.mock_vcns.stop)

        self.tenant_id = _uuid()
        self.subnet_id = _uuid()
Esempio n. 52
0
 def test_agentless_extensions(self):
     q_config.parse(['--config-file', BASE_CONF_PATH,
                     '--config-file', NSX_INI_AGENTLESS_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     self.assertEqual(config.AgentModes.AGENTLESS,
                      cfg.CONF.NSX.agent_mode)
     # The version returned from NSX does not really matter here
     with mock.patch.object(client.NsxApiClient,
                            'get_version',
                            return_value=version.Version("9.9")):
         with mock.patch.object(lsnlib,
                                'service_cluster_exists',
                                return_value=True):
             plugin = NeutronManager().get_plugin()
             self.assertNotIn('agent',
                              plugin.supported_extension_aliases)
             self.assertNotIn('dhcp_agent_scheduler',
                              plugin.supported_extension_aliases)
Esempio n. 53
0
 def test_agentless_extensions(self):
     q_config.parse(['--config-file', BASE_CONF_PATH,
                     '--config-file', NSX_INI_AGENTLESS_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     self.assertEqual(config.AgentModes.AGENTLESS,
                      cfg.CONF.NSX.agent_mode)
     # The version returned from NSX does not really matter here
     with mock.patch.object(client.NsxApiClient,
                            'get_version',
                            return_value=version.Version("9.9")):
         with mock.patch.object(lsnlib,
                                'service_cluster_exists',
                                return_value=True):
             plugin = NeutronManager().get_plugin()
             self.assertNotIn('agent',
                              plugin.supported_extension_aliases)
             self.assertNotIn('dhcp_agent_scheduler',
                              plugin.supported_extension_aliases)
Esempio n. 54
0
 def test_combined_extensions(self):
     q_config.parse(['--config-file', BASE_CONF_PATH,
                     '--config-file', NSX_INI_COMBINED_PATH])
     cfg.CONF.set_override('core_plugin', PLUGIN_NAME)
     self.assertEqual(config.AgentModes.COMBINED,
                      cfg.CONF.NSX.agent_mode)
     with mock.patch.object(client.NsxApiClient,
                            'get_version',
                            return_value=version.Version("4.2")):
         with mock.patch.object(lsnlib,
                                'service_cluster_exists',
                                return_value=True):
             plugin = NeutronManager().get_plugin()
             self.assertIn('agent',
                           plugin.supported_extension_aliases)
             self.assertIn('dhcp_agent_scheduler',
                           plugin.supported_extension_aliases)
             self.assertIn('lsn',
                           plugin.supported_extension_aliases)
Esempio n. 55
0
    def set_up_mocks(self):
        # Mock the configuration file
        args = ['--config-file', base.etcdir('neutron.conf.test')]
        neutron_config.parse(args=args)

        # Configure the ML2 mechanism drivers and network types
        ml2_opts = {
            'mechanism_drivers': ['apic'],
            'tenant_network_types': ['vlan'],
        }
        for opt, val in ml2_opts.items():
            ml2_config.cfg.CONF.set_override(opt, val, 'ml2')

        # Configure the Cisco APIC mechanism driver
        apic_test_config = {
            'apic_host': APIC_HOST,
            'apic_username': APIC_USR,
            'apic_password': APIC_PWD,
            'apic_port': APIC_PORT,
            'apic_vmm_domain': APIC_DOMAIN,
            'apic_vlan_ns_name': APIC_VLAN_NAME,
            'apic_vlan_range': '%d:%d' % (APIC_VLANID_FROM, APIC_VLANID_TO),
            'apic_node_profile': APIC_NODE_PROF,
            'apic_entity_profile': APIC_ATT_ENT_PROF,
            'apic_function_profile': APIC_FUNC_PROF,
        }
        for opt, val in apic_test_config.items():
            cfg.CONF.set_override(opt, val, 'ml2_cisco_apic')

        apic_switch_cfg = {
            'apic_switch:east01': {
                'ubuntu1,ubuntu2': ['3/11']
            },
            'apic_switch:east02': {
                'rhel01,rhel02': ['4/21'],
                'rhel03': ['4/22']
            },
        }
        self.mocked_parser = mock.patch.object(cfg,
                                               'MultiConfigParser').start()
        self.mocked_parser.return_value.read.return_value = [apic_switch_cfg]
        self.mocked_parser.return_value.parsed = [apic_switch_cfg]
    def setUp(self):
        super(ExtensionExtendedAttributeTestCase, self).setUp()
        plugin = ("neutron.tests.unit.test_extension_extended_attribute."
                  "ExtensionExtendedAttributeTestPlugin")

        # point config file to: neutron/tests/etc/neutron.conf.test
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args=args)

        cfg.CONF.set_override('core_plugin', plugin)

        manager.NeutronManager._instance = None

        ext_mgr = extensions.PluginAwareExtensionManager(
            extensions_path,
            {constants.CORE: ExtensionExtendedAttributeTestPlugin})
        ext_mgr.extend_resources("2.0", {})
        extensions.PluginAwareExtensionManager._instance = ext_mgr

        app = config.load_paste_app('extensions_test_app')
        self._api = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr)

        self._tenant_id = "8c70909f-b081-452d-872b-df48e6c355d1"
        # Save the global RESOURCE_ATTRIBUTE_MAP
        self.saved_attr_map = {}
        for resource, attrs in attributes.RESOURCE_ATTRIBUTE_MAP.iteritems():
            self.saved_attr_map[resource] = attrs.copy()
        # Add the resources to the global attribute map
        # This is done here as the setup process won't
        # initialize the main API router which extends
        # the global attribute map
        attributes.RESOURCE_ATTRIBUTE_MAP.update(
            extattr.EXTENDED_ATTRIBUTES_2_0)
        self.agentscheduler_dbMinxin = manager.NeutronManager.get_plugin()
        self.addCleanup(cfg.CONF.reset)
        self.addCleanup(self.restore_attribute_map)

        quota.QUOTAS._driver = None
        cfg.CONF.set_override('quota_driver',
                              'neutron.quota.ConfDriver',
                              group='QUOTAS')
Esempio n. 57
0
    def setUp(self):
        super(FirewallExtensionTestCase, self).setUp()
        plugin = 'neutron.extensions.firewall.FirewallPluginBase'

        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        # Create the default configurations
        args = ['--config-file', test_api_v2.etcdir('neutron.conf.test')]
        config.parse(args)

        # Stubbing core plugin with Firewall plugin
        self.setup_coreplugin(plugin)
        cfg.CONF.set_override('service_plugins', [plugin])

        self._plugin_patcher = mock.patch(plugin, autospec=True)
        self.plugin = self._plugin_patcher.start()
        instance = self.plugin.return_value
        instance.get_plugin_type.return_value = constants.FIREWALL

        ext_mgr = FirewallTestExtensionManager()
        self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr)
        self.api = webtest.TestApp(self.ext_mdw)
        super(FirewallExtensionTestCase, self).setUp()
Esempio n. 58
0
def main():
    if len(sys.argv) != 2:
        help(sys.argv[0])
    args = ['--config-file']
    args.append(sys.argv[1])
    config.parse(args)
    print("----------------------- Database Options -----------------------")
    print("\tconnection: %s" % cfg.CONF.database.connection)
    print("\tretry_interval: %d" % cfg.CONF.database.retry_interval)
    print("\tmax_retries: %d" % cfg.CONF.database.max_retries)
    print("-----------------------    NVP Options   -----------------------")
    print("\tNVP Generation Timeout %d" % cfg.CONF.NVP.nvp_gen_timeout)
    print("\tNumber of concurrent connections to each controller %d" %
          cfg.CONF.NVP.concurrent_connections)
    print("\tmax_lp_per_bridged_ls: %s" % cfg.CONF.NVP.max_lp_per_bridged_ls)
    print("\tmax_lp_per_overlay_ls: %s" % cfg.CONF.NVP.max_lp_per_overlay_ls)
    print("-----------------------  Cluster Options -----------------------")
    print("\trequested_timeout: %s" % cfg.CONF.req_timeout)
    print("\tretries: %s" % cfg.CONF.retries)
    print("\tredirects: %s" % cfg.CONF.redirects)
    print("\thttp_timeout: %s" % cfg.CONF.http_timeout)
    cluster = NeutronPlugin.create_nvp_cluster(
        cfg.CONF, cfg.CONF.NVP.concurrent_connections,
        cfg.CONF.NVP.nvp_gen_timeout)
    num_controllers = len(cluster.nvp_controllers)
    print("Number of controllers found: %s" % num_controllers)
    if num_controllers == 0:
        print("You must specify at least one controller!")
        sys.exit(1)

    for controller in cluster.nvp_controllers:
        print("\tController endpoint: %s" % controller)
        nvplib.check_cluster_connectivity(cluster)
        gateway_services = get_gateway_services(cluster)
        default_gateways = {
            "L2GatewayServiceConfig": cfg.CONF.default_l2_gw_service_uuid,
            "L3GatewayServiceConfig": cfg.CONF.default_l3_gw_service_uuid
        }
        errors = 0
        for svc_type in default_gateways.keys():
            for uuid in gateway_services[svc_type]:
                print("\t\tGateway(%s) uuid: %s" % (svc_type, uuid))
            if (default_gateways[svc_type]
                    and default_gateways[svc_type] not in gateway_services):
                print("\t\t\tError: specified default %s gateway (%s) is "
                      "missing from NVP Gateway Services!" %
                      (svc_type, default_gateways[svc_type]))
                errors += 1
        transport_zones = get_transport_zones(cluster)
        print("\tTransport zones: %s" % transport_zones)
        if cfg.CONF.default_tz_uuid not in transport_zones:
            print("\t\tError: specified default transport zone "
                  "(%s) is missing from NVP transport zones!" %
                  cfg.CONF.default_tz_uuid)
            errors += 1

    if errors:
        print("\nThere are %d errors with your configuration. "
              " Please, revise!" % errors)
        sys.exit(1)
    else:
        print("Done.")