def setUp(self): super(NetworkGatewayExtensionTestCase, self).setUp() plugin = '%s.%s' % (networkgw.__name__, networkgw.NetworkGatewayPluginBase.__name__) self._resource = networkgw.RESOURCE_NAME.replace('-', '_') # Ensure 'stale' patched copies of the plugin are never returned manager.QuantumManager._instance = None # Ensure existing ExtensionManager is not used extensions.PluginAwareExtensionManager._instance = None # Create the default configurations args = ['--config-file', test_api_v2.etcdir('quantum.conf.test')] config.parse(args=args) # Update the plugin and extensions path cfg.CONF.set_override('core_plugin', 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.QuantumManager.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)
def setup_extensions_middleware(extension_manager=None): extension_manager = extension_manager or PluginAwareExtensionManager(extensions_path, 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)
def setUp(self): super(ExtensionExtendedAttributeTestCase, self).setUp() plugin = ( "quantum.tests.unit.test_extension_extended_attribute." "ExtensionExtendedAttributeTestPlugin" ) # point config file to: quantum/tests/etc/quantum.conf.test args = ['--config-file', test_api_v2.etcdir('quantum.conf.test')] config.parse(args=args) cfg.CONF.set_override('core_plugin', plugin) manager.QuantumManager._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" self.addCleanup(cfg.CONF.reset)
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", NVP_PLUGIN_PATH) plugin = QuantumManager().get_plugin() cluster = plugin.cluster self._assert_required_options(cluster) self._assert_extra_options(cluster)
def setUp(self): plugin = 'quantum.extensions.l3.RouterPluginBase' # Ensure 'stale' patched copies of the plugin are never returned manager.QuantumManager._instance = None # 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_api_v2.etcdir('quantum.conf.test')] config.parse(args=args) # Update the plugin and extensions path cfg.CONF.set_override('core_plugin', plugin) self._plugin_patcher = mock.patch(plugin, autospec=True) self.plugin = self._plugin_patcher.start() # Instantiate mock plugin and enable the 'router' extension manager.QuantumManager.get_plugin().supported_extension_aliases = ([ "router" ]) ext_mgr = L3TestExtensionManager() self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr) self.api = webtest.TestApp(self.ext_mdw)
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)
def setUp(self): plugin = ( "quantum.tests.unit.test_routerserviceinsertion." "RouterServiceInsertionTestPlugin" ) # point config file to: quantum/tests/etc/quantum.conf.test args = ['--config-file', test_api_v2.etcdir('quantum.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', [plugin]) cfg.CONF.set_override('quota_router', -1, group='QUOTAS') # Ensure 'stale' patched copies of the plugin are never returned quantum.manager.QuantumManager._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" res = self._do_request('GET', _get_path('service-types')) self._service_type_id = res['service_types'][0]['id']
def _setUp2(self): db._ENGINE = None db._MAKER = None # Ensure 'stale' patched copies of the plugin are never returned manager.QuantumManager._instance = None # 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('quantum.conf.test')] config.parse(args=args) # Update the plugin and extensions path cfg.CONF.set_override('core_plugin', TARGET_PLUGIN) self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True) self.plugin = self._plugin_patcher.start() ext_mgr = extensions.PluginAwareExtensionManager.get_instance() l2network_db_v2.initialize() app = config.load_paste_app('extensions_test_app') ext_middleware = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr) self.api = webtest.TestApp(ext_middleware)
def setUp(self): plugin = 'quantum.quantum_plugin_base_v2.QuantumPluginBaseV2' # Ensure 'stale' patched copies of the plugin are never returned QuantumManager._instance = None # Ensure existing ExtensionManager is not used 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', etcdir('quantum.conf.test')] config.parse(args=args) # Update the plugin and extensions path cfg.CONF.set_override('core_plugin', plugin) cfg.CONF.set_override('api_extensions_path', EXTDIR) self._plugin_patcher = mock.patch(plugin, autospec=True) self.plugin = self._plugin_patcher.start() # Instantiate mock plugin and enable the V2attributes extension QuantumManager.get_plugin().supported_extension_aliases = ["v2attrs"] api = router.APIRouter() self.api = webtest.TestApp(api)
def setUp(self): super(LoadBalancerExtensionTestCase, self).setUp() plugin = 'quantum.extensions.loadbalancer.LoadBalancerPluginBase' # Ensure 'stale' patched copies of the plugin are never returned manager.QuantumManager._instance = None # Ensure existing ExtensionManager is not used extensions.PluginAwareExtensionManager._instance = None # Create the default configurations args = ['--config-file', test_api_v2.etcdir('quantum.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()
def setUp(self): super(VPNTestCase, self).setUp() plugin = ("quantum.tests.unit.test_vpn.VPNTestPlugin") # point config file to: quantum/tests/etc/quantum.conf.test args = ['--config-file', test_api_v2.etcdir('quantum.conf.test')] config.parse(args=args) #just stubbing core plugin with VPN plugin cfg.CONF.set_override('core_plugin', plugin) cfg.CONF.set_override('service_plugins', [plugin]) self.addCleanup(cfg.CONF.reset) # Ensure 'stale' patched copies of the plugin are never returned quantum.manager.QuantumManager._instance = None # Ensure the database is reset between tests db._ENGINE = None db._MAKER = None db.configure_db() # Ensure existing ExtensionManager is not used ext_mgr = extensions.PluginAwareExtensionManager( extensions_path, {constants.VPN: VPNTestPlugin()} ) 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._subnet_id = "0c798ed8-33ba-11e2-8b28-000c291c4d14"
def _setUp1(self): db._ENGINE = None db._MAKER = None # Ensure 'stale' patched copies of the plugin are never returned manager.QuantumManager._instance = None # 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("quantum.conf.test")] config.parse(args=args) # Update the plugin and extensions path cfg.CONF.set_override("core_plugin", TARGET_PLUGIN) cfg.CONF.set_override("quota_driver", "quantum.extensions._quotav2_driver.DbQuotaDriver", group="QUOTAS") cfg.CONF.set_override("quota_items", ["network", "subnet", "port", "extra1"], group="QUOTAS") self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True) self.plugin = self._plugin_patcher.start() # QUOTAS will regester 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() l2network_db_v2.initialize() app = config.load_paste_app("extensions_test_app") ext_middleware = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr) self.api = webtest.TestApp(ext_middleware)
def setUp(self): plugin = 'quantum.extensions.l3.RouterPluginBase' # Ensure 'stale' patched copies of the plugin are never returned manager.QuantumManager._instance = None # 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_api_v2.etcdir('quantum.conf.test')] config.parse(args=args) # Update the plugin and extensions path cfg.CONF.set_override('core_plugin', plugin) self._plugin_patcher = mock.patch(plugin, autospec=True) self.plugin = self._plugin_patcher.start() # Instantiate mock plugin and enable the 'router' extension manager.QuantumManager.get_plugin().supported_extension_aliases = ( ["router"]) ext_mgr = L3TestExtensionManager() self.ext_mdw = test_extensions.setup_extensions_middleware(ext_mgr) self.api = webtest.TestApp(self.ext_mdw)
def setUp(self): super(QuantumManagerTestCase, self).setUp() args = ['--config-file', etcdir('quantum.conf.test')] # If test_config specifies some config-file, use it, as well config.parse(args=args) self.addCleanup(cfg.CONF.reset) self.useFixture( fixtures.MonkeyPatch('quantum.manager.QuantumManager._instance'))
def setup_extensions_middleware(extension_manager=None): extension_manager = (extension_manager or PluginAwareExtensionManager( extensions_path, 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)
def setup_extensions_middleware(extension_manager=None): extension_manager = (extension_manager or PluginAwareExtensionManager(extensions_path, QuantumEchoPlugin())) 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)
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)
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', NVP_PLUGIN_PATH) plugin = QuantumManager().get_plugin() cluster = plugin.cluster self._assert_required_options(cluster) self._assert_extra_options(cluster)
def setup_extensions_middleware(extension_manager=None): extension_manager = (extension_manager or extensions.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 extensions.ExtensionMiddleware(app, ext_mgr=extension_manager)
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", NVP_PLUGIN_PATH) plugin = QuantumManager().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)
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 (~/.quantum/, ~/, /etc/quantum/, /etc/) and" " the '--config-file' option!") try: quantum_service = service.serve_wsgi(service.QuantumApiService) quantum_service.wait() except RuntimeError, e: sys.exit("ERROR: %s" % e)
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 (~/.quantum/, ~/, /etc/quantum/, /etc/) and" " the '--config-file' option!")) try: quantum_service = service.serve_wsgi(service.QuantumApiService) quantum_service.wait() except RuntimeError as e: sys.exit(_("ERROR: %s") % e)
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', NVP_PLUGIN_PATH) plugin = QuantumManager().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)
def setUp(self): plugin = 'quantum.quantum_plugin_base_v2.QuantumPluginBaseV2' # Create the default configurations args = ['--config-file', etcdir('quantum.conf.test')] config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) self._plugin_patcher = mock.patch(plugin, autospec=True) self.plugin = self._plugin_patcher.start() api = router.APIRouter() self.api = webtest.TestApp(api)
def setUp(self, plugin=None): super(SecurityGroupsTestCase, self).setUp() db._ENGINE = None db._MAKER = None # Make sure at each test a new instance of the plugin is returned QuantumManager._instance = None # Make sure at each test according extensions for the plugin is loaded PluginAwareExtensionManager._instance = None # Save the attributes map in case the plugin will alter it # loading extensions # Note(salvatore-orlando): shallow copy is not good enough in # this case, but copy.deepcopy does not seem to work, since it # causes test failures self._attribute_map_bk = {} for item in attributes.RESOURCE_ATTRIBUTE_MAP: self._attribute_map_bk[item] = ( attributes.RESOURCE_ATTRIBUTE_MAP[item].copy()) json_deserializer = JSONDeserializer() self._deserializers = { 'application/json': json_deserializer, } if not plugin: plugin = test_config.get('plugin_name_v2', DB_PLUGIN_KLASS) # Create the default configurations args = ['--config-file', etcdir('quantum.conf.test')] # If test_config specifies some config-file, use it, as well for config_file in test_config.get('config_files', []): args.extend(['--config-file', config_file]) config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) self.api = APIRouter() def _is_native_bulk_supported(): plugin_obj = QuantumManager.get_plugin() native_bulk_attr_name = ("_%s__native_bulk_support" % plugin_obj.__class__.__name__) return getattr(plugin_obj, native_bulk_attr_name, False) self._skip_native_bulk = not _is_native_bulk_supported() QuantumManager.get_plugin().supported_extension_aliases = ([ "security-groups" ]) ext_mgr = SecurityGroupTestExtensionManager() if ext_mgr: self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
def setUp(self, plugin=None): super(SecurityGroupsTestCase, self).setUp() db._ENGINE = None db._MAKER = None # Make sure at each test a new instance of the plugin is returned QuantumManager._instance = None # Make sure at each test according extensions for the plugin is loaded PluginAwareExtensionManager._instance = None # Save the attributes map in case the plugin will alter it # loading extensions # Note(salvatore-orlando): shallow copy is not good enough in # this case, but copy.deepcopy does not seem to work, since it # causes test failures self._attribute_map_bk = {} for item in attributes.RESOURCE_ATTRIBUTE_MAP: self._attribute_map_bk[item] = (attributes. RESOURCE_ATTRIBUTE_MAP[item]. copy()) json_deserializer = JSONDeserializer() self._deserializers = { 'application/json': json_deserializer, } if not plugin: plugin = test_config.get('plugin_name_v2', DB_PLUGIN_KLASS) # Create the default configurations args = ['--config-file', etcdir('quantum.conf.test')] # If test_config specifies some config-file, use it, as well for config_file in test_config.get('config_files', []): args.extend(['--config-file', config_file]) config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) self.api = APIRouter() def _is_native_bulk_supported(): plugin_obj = QuantumManager.get_plugin() native_bulk_attr_name = ("_%s__native_bulk_support" % plugin_obj.__class__.__name__) return getattr(plugin_obj, native_bulk_attr_name, False) self._skip_native_bulk = not _is_native_bulk_supported() QuantumManager.get_plugin().supported_extension_aliases = ( ["security-groups"]) ext_mgr = SecurityGroupTestExtensionManager() if ext_mgr: self.ext_api = test_extensions.setup_extensions_middleware(ext_mgr)
def setUp(self): plugin = 'quantum.plugins.cisco.network_plugin.PluginV2' # Create the default configurations args = ['--config-file', curdir('quantumv2.conf.cisco.test')] config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) self._plugin_patcher = mock.patch(plugin, autospec=True) self.plugin = self._plugin_patcher.start() api = router.APIRouter() self.api = webtest.TestApp(api) LOG.debug("%s.%s.%s done" % (__name__, self.__class__.__name__, inspect.stack()[0][3]))
def setUp(self): plugin = 'quantum.quantum_plugin_base_v2.QuantumPluginBaseV2' # Ensure 'stale' patched copies of the plugin are never returned QuantumManager._instance = None # Ensure existing ExtensionManager is not used PluginAwareExtensionManager._instance = None # Create the default configurations args = ['--config-file', etcdir('quantum.conf.test')] config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) self._plugin_patcher = mock.patch(plugin, autospec=True) self.plugin = self._plugin_patcher.start() api = router.APIRouter() self.api = webtest.TestApp(api)
def setUp(self): plugin = "quantum.plugins.cisco.network_plugin.PluginV2" # Ensure 'stale' patched copies of the plugin are never returned QuantumManager._instance = None # Ensure existing ExtensionManager is not used PluginAwareExtensionManager._instance = None # Create the default configurations args = ["--config-file", curdir("quantumv2.conf.cisco.test")] config.parse(args=args) # Update the plugin cfg.CONF.set_override("core_plugin", plugin) self._plugin_patcher = mock.patch(plugin, autospec=True) self.plugin = self._plugin_patcher.start() api = router.APIRouter() self.api = webtest.TestApp(api) LOG.debug("%s.%s.%s done" % (__name__, self.__class__.__name__, inspect.stack()[0][3]))
def main(argv): if len(argv) != 2: help(argv[0]) args = ['--config-file'] args.append(argv[1]) config.parse(args) print "------------------------ Database Options ------------------------" print "\tsql_connection: %s" % cfg.CONF.DATABASE.sql_connection print "\treconnect_interval: %d" % cfg.CONF.DATABASE.reconnect_interval print "\tsql_max_retries: %d" % cfg.CONF.DATABASE.sql_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 ("\tenable_metadata_access_network: %s" % cfg.CONF.NVP.enable_metadata_access_network) 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 = QuantumPlugin.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) for svc_type in ["L2GatewayServiceConfig", "L3GatewayServiceConfig"]: for uuid in gateway_services[svc_type]: print "\t\tGateway(%s) uuid: %s" % (svc_type, uuid) transport_zones = get_transport_zones(cluster) print "\tTransport zones: %s" % transport_zones print "Done."
def setUp(self): plugin = 'quantum.plugins.cisco.network_plugin.PluginV2' # Ensure 'stale' patched copies of the plugin are never returned QuantumManager._instance = None # Ensure existing ExtensionManager is not used PluginAwareExtensionManager._instance = None # Create the default configurations args = ['--config-file', curdir('quantumv2.conf.cisco.test')] config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) self._plugin_patcher = mock.patch(plugin, autospec=True) self.plugin = self._plugin_patcher.start() api = router.APIRouter() self.api = webtest.TestApp(api) LOG.debug("%s.%s.%s done" % (__name__, self.__class__.__name__, inspect.stack()[0][3]))
def setUp(self): super(QuotaExtensionTestCase, self).setUp() db._ENGINE = None db._MAKER = None # Ensure 'stale' patched copies of the plugin are never returned manager.QuantumManager._instance = None # 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('quantum.conf.test')] config.parse(args=args) # Update the plugin and extensions path cfg.CONF.set_override('core_plugin', TARGET_PLUGIN) cfg.CONF.set_override( 'quota_driver', 'quantum.db.quota_db.DbQuotaDriver', group='QUOTAS') 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 regester 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() l2network_db_v2.initialize() app = config.load_paste_app('extensions_test_app') ext_middleware = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr) self.api = webtest.TestApp(ext_middleware) super(QuotaExtensionTestCase, self).setUp()
def setUp(self): plugin = 'quantum.tests.unit.test_api_v2.TestSubresourcePlugin' QuantumManager._instance = None PluginAwareExtensionManager._instance = None args = ['--config-file', etcdir('quantum.conf.test')] config.parse(args=args) cfg.CONF.set_override('core_plugin', plugin) self._plugin_patcher = mock.patch(plugin, autospec=True) self.plugin = self._plugin_patcher.start() router.SUB_RESOURCES['dummy'] = { 'collection_name': 'dummies', 'parent': {'collection_name': 'networks', 'member_name': 'network'} } api = router.APIRouter() self.api = webtest.TestApp(api)
def main(argv): if len(argv) != 2: help(argv[0]) args = ['--config-file'] args.append(argv[1]) config.parse(args) print "------------------------ Database Options ------------------------" print "\tsql_connection: %s" % cfg.CONF.DATABASE.sql_connection print "\treconnect_interval: %d" % cfg.CONF.DATABASE.reconnect_interval print "\tsql_max_retries: %d" % cfg.CONF.DATABASE.sql_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("\tenable_metadata_access_network: %s" % cfg.CONF.NVP.enable_metadata_access_network) 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 = QuantumPlugin.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) for svc_type in ["L2GatewayServiceConfig", "L3GatewayServiceConfig"]: for uuid in gateway_services[svc_type]: print "\t\tGateway(%s) uuid: %s" % (svc_type, uuid) transport_zones = get_transport_zones(cluster) print "\tTransport zones: %s" % transport_zones print "Done."
def setUp(self, core_plugin=None, lb_plugin=None): super(LoadBalancerPluginDbTestCase, self).setUp() db._ENGINE = None db._MAKER = None QuantumManager._instance = None PluginAwareExtensionManager._instance = None self._attribute_map_bk = {} self._attribute_map_bk = loadbalancer.RESOURCE_ATTRIBUTE_MAP.copy() self._tenant_id = "test-tenant" self._subnet_id = "0c798ed8-33ba-11e2-8b28-000c291c4d14" json_deserializer = JSONDeserializer() self._deserializers = { 'application/json': json_deserializer, } if not core_plugin: core_plugin = test_config.get('plugin_name_v2', DB_CORE_PLUGIN_KLASS) if not lb_plugin: lb_plugin = test_config.get('lb_plugin_name', DB_LB_PLUGIN_KLASS) # point config file to: quantum/tests/etc/quantum.conf.test args = ['--config-file', etcdir('quantum.conf.test')] config.parse(args=args) # Update the plugin service_plugins = [lb_plugin] cfg.CONF.set_override('core_plugin', core_plugin) cfg.CONF.set_override('service_plugins', service_plugins) cfg.CONF.set_override('base_mac', "12:34:56:78:90:ab") self.api = APIRouter() plugin = loadbalancerPlugin.LoadBalancerPlugin() ext_mgr = PluginAwareExtensionManager( extensions_path, {constants.LOADBALANCER: plugin} ) app = config.load_paste_app('extensions_test_app') self.ext_api = ExtensionMiddleware(app, ext_mgr=ext_mgr)
def setUp(self): db._ENGINE = None db._MAKER = None self._tenant_id = 'test-tenant' json_deserializer = JSONDeserializer() self._deserializers = { 'application/json': json_deserializer, } plugin = 'quantum.plugins.cisco.network_plugin.PluginV2' # Create the default configurations args = ['--config-file', curdir('quantumv2.conf.cisco.test')] config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) cfg.CONF.set_override('base_mac', "12:34:56:78:90:ab") self.api = APIRouter() LOG.debug("%s.%s.%s done" % (__name__, self.__class__.__name__, inspect.stack()[0][3]))
def setUp(self): super(QuantumDbPluginV2TestCase, self).setUp() # NOTE(jkoelker) for a 'pluggable' framework, Quantum sure # doesn't like when the plugin changes ;) db._ENGINE = None db._MAKER = None self._tenant_id = 'test-tenant' json_deserializer = JSONDeserializer() self._deserializers = { 'application/json': json_deserializer, } plugin = 'quantum.db.db_base_plugin_v2.QuantumDbPluginV2' # Create the default configurations args = ['--config-file', etcdir('quantum.conf.test')] config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) self.api = APIRouter()
def setUp(self): super(ExtensionExtendedAttributeTestCase, self).setUp() plugin = ( "quantum.tests.unit.test_extension_extended_attribute." "ExtensionExtendedAttributeTestPlugin" ) # point config file to: quantum/tests/etc/quantum.conf.test args = ['--config-file', test_api_v2.etcdir('quantum.conf.test')] config.parse(args=args) cfg.CONF.set_override('core_plugin', plugin) manager.QuantumManager._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.QuantumManager.get_plugin() self.addCleanup(cfg.CONF.reset) self.addCleanup(self.restore_attribute_map)
def _setUp1(self): db._ENGINE = None db._MAKER = None # Ensure 'stale' patched copies of the plugin are never returned manager.QuantumManager._instance = None # 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('quantum.conf.test')] config.parse(args=args) # Update the plugin and extensions path cfg.CONF.set_override('core_plugin', TARGET_PLUGIN) cfg.CONF.set_override( 'quota_driver', 'quantum.extensions._quotav2_driver.DbQuotaDriver', group='QUOTAS') cfg.CONF.set_override('quota_items', ['network', 'subnet', 'port', 'extra1'], group='QUOTAS') self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True) self.plugin = self._plugin_patcher.start() # QUOTAS will regester 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() l2network_db_v2.initialize() app = config.load_paste_app('extensions_test_app') ext_middleware = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr) self.api = webtest.TestApp(ext_middleware)
def setUp(self): super(RouterServiceInsertionTestCase, self).setUp() plugin = ("quantum.tests.unit.test_routerserviceinsertion." "RouterServiceInsertionTestPlugin") # point config file to: quantum/tests/etc/quantum.conf.test args = ['--config-file', test_api_v2.etcdir('quantum.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 quantum.manager.QuantumManager._instance = None # Ensure the database is reset between tests db._ENGINE = None db._MAKER = 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" res = self._do_request('GET', _get_path('service-types')) self._service_type_id = res['service_types'][0]['id'] self._setup_core_resources()
def setUp(self): super(QuantumDbPluginV2TestCase, self).setUp() # NOTE(jkoelker) for a 'pluggable' framework, Quantum sure # doesn't like when the plugin changes ;) db._ENGINE = None db._MAKER = None self._tenant_id = 'test-tenant' json_deserializer = JSONDeserializer() self._deserializers = { 'application/json': json_deserializer, } plugin = 'quantum.db.db_base_plugin_v2.QuantumDbPluginV2' # Create the default configurations args = ['--config-file', etcdir('quantum.conf.test')] config.parse(args=args) # Update the plugin cfg.CONF.set_override('core_plugin', plugin) cfg.CONF.set_override('base_mac', "12:34:56:78:90:ab") self.api = APIRouter()
def setUp(self): super(RouterServiceInsertionTestCase, self).setUp() plugin = "quantum.tests.unit.test_routerserviceinsertion." "RouterServiceInsertionTestPlugin" # point config file to: quantum/tests/etc/quantum.conf.test args = ["--config-file", test_api_v2.etcdir("quantum.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", [plugin]) cfg.CONF.set_override("quota_router", -1, group="QUOTAS") self.addCleanup(cfg.CONF.reset) # Ensure 'stale' patched copies of the plugin are never returned quantum.manager.QuantumManager._instance = None # Ensure the database is reset between tests db._ENGINE = None db._MAKER = 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" res = self._do_request("GET", _get_path("service-types")) self._service_type_id = res["service_types"][0]["id"] self._setup_core_resources()
def main(argv): if len(argv) != 2: help(argv[0]) args = ['--config-file'] args.append(argv[1]) config.parse(args) print "------------------------ Database Options ------------------------" print "\tsql_connection: %s" % cfg.CONF.DATABASE.sql_connection print "\treconnect_interval: %d" % cfg.CONF.DATABASE.reconnect_interval print "\tsql_max_retries: %d" % cfg.CONF.DATABASE.sql_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("\tenable_metadata_access_network: %s" % cfg.CONF.NVP.enable_metadata_access_network) 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 = QuantumPlugin.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."
def setup_base_app(): config_file = 'quantum.conf.test' args = ['--config-file', etcdir(config_file)] config.parse(args=args) app = config.load_paste_app('extensions_test_app') return app
LOG = logging.getLogger('quantum.plugins.cisco.tests.test_cisco_extensions') EXTENSIONS_PATH = os.path.join(os.path.dirname(__file__), os.pardir, os.pardir, os.pardir, os.pardir, "extensions") ROOTDIR = os.path.dirname(os.path.dirname(__file__)) UNITDIR = os.path.join(ROOTDIR, 'unit') def testsdir(*p): return os.path.join(UNITDIR, *p) config_file = 'quantum.conf.cisco.test' args = ['--config-file', testsdir(config_file)] config.parse(args=args) class ExtensionsTestApp(wsgi.Router): def __init__(self, options=None): options = options or {} mapper = routes.Mapper() controller = StubBaseAppController() mapper.resource("dummy_resource", "/dummy_resources", controller=controller) super(ExtensionsTestApp, self).__init__(mapper) def create_request(self, path, body, content_type, method='GET'): """ Test create request"""
def main(argv): if len(sys.argv) != 2: help() args = ['--config-file'] args.append(sys.argv[1]) config.parse(args) errors = False nvp_opts, clusters_opts = QuantumPlugin.parse_config() print "-----------Database Options--------------------" print "sql_connection: %s" % cfg.CONF.DATABASE.sql_connection print "reconnect_interval: %d" % cfg.CONF.DATABASE.reconnect_interval print "sql_max_retries: %d" % cfg.CONF.DATABASE.sql_max_retries print "-----------NVP Options--------------------" print ("Number of concurrents allow to each controller %d" % nvp_opts.concurrent_connections) print "NVP Generation Timeout %d" % nvp_opts.nvp_gen_timeout print "NVP Default Cluster Name %s" % nvp_opts.default_cluster_name print "-----------Cluster Options--------------------" if not len(clusters_opts): print "No NVP Clusters detected in nvp.ini!" exit(1) clusters, default_cluster = QuantumPlugin.parse_clusters_opts( clusters_opts, nvp_opts.concurrent_connections, nvp_opts.nvp_gen_timeout, nvp_opts.default_cluster_name) for cluster in clusters.itervalues(): num_controllers = cluster.get_num_controllers() print "\n%d controllers found in cluster [CLUSTER:%s]" % ( num_controllers, cluster.name) if num_controllers == 0: print ("Cluster %s has no nvp_controller_connection defined!" % cluster.name) exit(1) for i in range(0, num_controllers): controller = cluster.get_controller(i) if i == 0: gateway_services = get_gateway_services(cluster) transport_zones = get_transport_zones(cluster) controller.update(nvplib.check_cluster_connectivity(cluster)) default_tz_zone = controller.get('default_tz_uuid') print ("\n\tdefault_tz_uuid: %s" % default_tz_zone) if not default_tz_zone: print "\t* ERROR: No default trasport zone specified!" errors = True elif default_tz_zone not in transport_zones: print ("\t* ERROR: did not find default transport %s zone " "on NVP!" % default_tz_zone) errors = True print ("\tapi_redirect_interval: %s" % controller.get('api_redirect_interval')) print "\tcluster uuid: %s" % controller.get('uuid') print "\tapi_mode: %s" % controller.get('api_mode') l2_gateway = controller.get('default_l2_gw_service_uuid') print ("\tdefault_l2_gw_service_uuid: %s" % l2_gateway) if (l2_gateway and l2_gateway not in gateway_services['L2GatewayServiceConfig']): print ("\t* ERROR: Did not find L2 gateway service uuid %s" " in NVP!" % l2_gateway) errors = True l3_gateway = controller.get('default_l3_gw_service_uuid') print ("\tdefault_l3_gw_service_uuid: %s" % l3_gateway) if (l3_gateway and l3_gateway not in gateway_services['L3GatewayServiceConfig']): print ("\t* ERROR did not find L3 gateway service uuid %s" " in NVP!" % l3_gateway) errors = True print ("\n-----controller %d------\n" % (i + 1)) test_controller(cluster, controller) display_controller_info(controller) print "\n" if errors: print ("**There were configuration errors found " "please review output carefully!!**") print "\n"
from quantum.openstack.common import log as logging from quantum.common import config logging.setup('quantum') config.parse(['--config-file', '/etc/quantum/quantum.conf', '--config-file', '/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini']) application = config.load_paste_app("quantum")