Esempio n. 1
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. 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 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)
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(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. 6
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()
Esempio n. 8
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)
    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")
    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 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')
Esempio n. 12
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. 13
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. 14
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. 15
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. 16
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. 17
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. 18
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. 19
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. 20
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. 21
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. 22
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. 23
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. 24
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. 25
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. 26
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. 27
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. 28
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. 29
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. 30
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)