def setUp(self): super(ConfFixture, self).setUp() self.conf.set_default("api_paste_config", paths.state_path_def("etc/nova/api-paste.ini")) self.conf.set_default("host", "fake-mini") self.conf.set_default("compute_driver", "nova.virt.fake.SmallFakeDriver") self.conf.set_default("fake_network", True) self.conf.set_default("flat_network_bridge", "br100") self.conf.set_default("floating_ip_dns_manager", "nova.tests.unit.utils.dns_manager") self.conf.set_default("instance_dns_manager", "nova.tests.unit.utils.dns_manager") self.conf.set_default("network_size", 8) self.conf.set_default("num_networks", 2) self.conf.set_default("use_ipv6", True) self.conf.set_default("vlan_interface", "eth0") self.conf.set_default("auth_strategy", "noauth2") config.parse_args([], default_config_files=[], configure_db=False) self.conf.set_default("connection", "sqlite://", group="database") self.conf.set_default("connection", "sqlite://", group="api_database") self.conf.set_default("sqlite_synchronous", False, group="database") self.conf.set_default("sqlite_synchronous", False, group="api_database") self.conf.set_default("fatal_exception_format_errors", True) self.conf.set_default("enabled", True, "osapi_v21") self.conf.set_default("force_dhcp_release", False) self.conf.set_default("periodic_enable", False) policy_opts.set_defaults(self.conf) self.addCleanup(utils.cleanup_dns_managers) self.addCleanup(ipv6.api.reset_backend)
def parse_args(): """Parse configuration arguments. Note: This method ensures that configuration will be loaded only once within single python interpreter. """ global _CONF_LOADED if _CONF_LOADED: LOG.debug('Configuration has been already loaded') return log.set_defaults() log.register_options(CONF) CONF(args=[], prog='events-api', project='monasca', version=version.version_str, description='RESTful API to collect events from cloud') log.setup(CONF, product_name='monasca-events-api', version=version.version_str) conf.register_opts(CONF) policy_opts.set_defaults(CONF) _CONF_LOADED = True
def prepare_service(args=None, conf=None, default_config_files=None): if conf is None: conf = cfg.ConfigOpts() # FIXME(jd) Use the pkg_entry info to register the options of these libs log.register_options(conf) db_options.set_defaults(conf) policy_opts.set_defaults(conf) # Register our own Gnocchi options for group, options in opts.list_opts(): conf.register_opts(list(options), group=None if group == "DEFAULT" else group) # HACK(jd) I'm not happy about that, fix AP class to handle a conf object? archive_policy.ArchivePolicy.DEFAULT_AGGREGATION_METHODS = ( conf.archive_policy.default_aggregation_methods ) try: default_workers = multiprocessing.cpu_count() or 1 except NotImplementedError: default_workers = 1 conf.set_default("workers", default_workers, group="api") conf.set_default("workers", default_workers, group="metricd") conf(args, project='gnocchi', validate_default_values=True, default_config_files=default_config_files) log.setup(conf, 'gnocchi') conf.log_opt_values(LOG, logging.DEBUG) return conf
def test_auth_middleware_factory(self): """Make sure that configuration settings make their way to the keystone middleware correctly. """ config = cfg.ConfigOpts() conf_fixture = self.useFixture(config_fixture.Config(config)) conf.register_opts(conf_fixture.conf) # NOTE(cdent): There appears to be no simple way to get the list of # options used by the auth_token middleware. So we pull from an # existing data structure. auth_token_opts = auth_token.AUTH_TOKEN_OPTS[0][1] conf_fixture.register_opts(auth_token_opts, group='keystone_authtoken') www_authenticate_uri = 'http://example.com/identity' conf_fixture.config(www_authenticate_uri=www_authenticate_uri, group='keystone_authtoken') # ensure that the auth_token middleware is chosen conf_fixture.config(auth_strategy='keystone', group='api') # register and default policy opts (referenced by deploy) policy_opts.set_defaults(conf_fixture.conf) app = deploy.deploy(conf_fixture.conf) req = webob.Request.blank('/resource_providers', method="GET") response = req.get_response(app) auth_header = response.headers['www-authenticate'] self.assertIn(www_authenticate_uri, auth_header) self.assertIn('keystone uri=', auth_header.lower())
def setUp(self): super(Policy, self).setUp() opts.set_defaults(self._config_fixture.conf) self._config_fixture.config(group='oslo_policy', policy_file=self._policy_file) policy._ENFORCER.suppress_deprecation_warnings = True self.addCleanup(policy.reset)
def setUp(self): super(PlacementFixture, self).setUp() if not self.conf_fixture: config = cfg.ConfigOpts() self.conf_fixture = self.useFixture(config_fixture.Config(config)) if self.register_opts: conf.register_opts(self.conf_fixture.conf) if self.db: self.useFixture( db_fixture.Database(self.conf_fixture, set_config=True)) policy_opts.set_defaults(self.conf_fixture.conf) self.conf_fixture.config(group='api', auth_strategy='noauth2') self.conf_fixture.conf([], default_config_files=[]) self.useFixture(policy_fixture.PolicyFixture(self.conf_fixture)) if self.use_intercept: loader = deploy.loadapp(self.conf_fixture.conf) def app(): return loader self.endpoint = 'http://%s/placement' % uuidutils.generate_uuid() intercept = interceptor.RequestsInterceptor(app, url=self.endpoint) intercept.install_intercept() self.addCleanup(intercept.uninstall_intercept)
def prepare_service(argv=None, config_files=None, conf=None): if argv is None: argv = sys.argv # FIXME(sileht): Use ConfigOpts() instead if conf is None: conf = cfg.CONF oslo_i18n.enable_lazy() log.register_options(conf) log_levels = (conf.default_log_levels + ['futurist=INFO', 'neutronclient=INFO', 'keystoneclient=INFO']) log.set_defaults(default_log_levels=log_levels) defaults.set_cors_middleware_defaults() policy_opts.set_defaults(conf) conf(argv[1:], project='ceilometer', validate_default_values=True, version=version.version_info.version_string(), default_config_files=config_files) ka_loading.load_auth_from_conf_options(conf, "service_credentials") log.setup(conf, 'ceilometer') # NOTE(liusheng): guru cannot run with service under apache daemon, so when # ceilometer-api running with mod_wsgi, the argv is [], we don't start # guru. if argv: gmr.TextGuruMeditation.setup_autorun(version) messaging.setup() return conf
def start_fixture(self): self.conf = None conf = conf_fixture.Config().conf policy_opts.set_defaults(conf) msg_conf = conffixture.ConfFixture(conf) msg_conf.transport_driver = 'fake' conf.import_group('api', 'cloudkitty.api.app') conf.set_override('auth_strategy', 'noauth', enforce_type=True) conf.set_override('connection', 'sqlite:///', 'database', enforce_type=True) conf.set_override('policy_file', os.path.abspath('etc/cloudkitty/policy.json'), group='oslo_policy', enforce_type=True) conf.set_override('api_paste_config', os.path.abspath( 'cloudkitty/tests/gabbi/gabbi_paste.ini') ) conf.import_group('storage', 'cloudkitty.storage') conf.set_override('backend', 'sqlalchemy', 'storage', enforce_type=True) self.conf = conf self.conn = ck_db_api.get_instance() migration = self.conn.get_migration() migration.upgrade('head')
def prepare_service(args=None, conf=None, config_files=None): set_defaults() if conf is None: conf = cfg.ConfigOpts() log.register_options(conf) policy_opts.set_defaults(conf) osprofiler_opts.set_defaults(conf) db_options.set_defaults(conf) for group, options in opts.list_opts(): conf.register_opts(list(options), group=None if group == 'DEFAULT' else group) conf(args, project='vitrage', validate_default_values=True, default_config_files=config_files) if conf.profiler.enabled: osprofiler_initializer.init_from_conf(conf=conf, context=None, project="vitrage", service="api", host=conf.api.host) for datasource in conf.datasources.types: register_opts(conf, datasource, conf.datasources.path) keystone_client.register_keystoneauth_opts(conf) log.setup(conf, 'vitrage') conf.log_opt_values(LOG, log.DEBUG) messaging.setup() return conf
def setUp(self): super(ConfFixture, self).setUp() self.conf.set_default('api_paste_config', paths.state_path_def('etc/nova/api-paste.ini')) self.conf.set_default('host', 'fake-mini') self.conf.set_default('compute_driver', 'nova.virt.fake.SmallFakeDriver') self.conf.set_default('fake_network', True) self.conf.set_default('flat_network_bridge', 'br100') self.conf.set_default('floating_ip_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('instance_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('network_size', 8) self.conf.set_default('num_networks', 2) self.conf.set_default('use_ipv6', True) self.conf.set_default('vlan_interface', 'eth0') self.conf.set_default('auth_strategy', 'noauth2') config.parse_args([], default_config_files=[], configure_db=False) self.conf.set_default('connection', "sqlite://", group='database') self.conf.set_default('connection', "sqlite://", group='api_database') self.conf.set_default('sqlite_synchronous', False, group='database') self.conf.set_default('sqlite_synchronous', False, group='api_database') self.conf.set_default('fatal_exception_format_errors', True) self.conf.set_default('enabled', True, 'osapi_v21') self.conf.set_default('force_dhcp_release', False) self.conf.set_default('periodic_enable', False) policy_opts.set_defaults(self.conf) self.addCleanup(utils.cleanup_dns_managers) self.addCleanup(ipv6.api.reset_backend)
def _get_conf(self): conf = cfg.CONF opts.set_defaults(conf, policy_file=self._policy_file) if self._policy_file: LOG.info('Using policy config file: %s', self._policy_file) conf(args=['--config-dir', os.path.dirname(self._policy_file)]) return conf
def set_external_opts_defaults(): """Update default configuration options for oslo.middleware.""" cors.set_defaults(allow_headers=[ 'X-Auth-Token', 'X-Openstack-Request-Id', 'X-Subject-Token', 'X-Project-Id', 'X-Project-Name', 'X-Project-Domain-Id', 'X-Project-Domain-Name', 'X-Domain-Id', 'X-Domain-Name', 'Openstack-Auth-Receipt' ], expose_headers=[ 'X-Auth-Token', 'X-Openstack-Request-Id', 'X-Subject-Token', 'Openstack-Auth-Receipt' ], allow_methods=['GET', 'PUT', 'POST', 'DELETE', 'PATCH']) # configure OSprofiler options profiler.set_defaults(CONF, enabled=False, trace_sqlalchemy=False) # TODO(gmann): Remove setting the default value of config policy_file # once oslo_policy change the default value to 'policy.yaml'. # https://github.com/openstack/oslo.policy/blob/a626ad12fe5a3abd49d70e3e5b95589d279ab578/oslo_policy/opts.py#L49 DEFAULT_POLICY_FILE = 'policy.yaml' policy_opts.set_defaults(cfg.CONF, DEFAULT_POLICY_FILE) # Oslo.cache is always enabled by default for request-local caching # TODO(morganfainberg): Fix this to not use internal interface when # oslo.cache has proper interface to set defaults added. This is # just a bad way to do this. opts = cache._opts.list_opts() for opt_list in opts: if opt_list[0] == 'cache': for o in opt_list[1]: if o.name == 'enabled': o.default = True
def setUp(self): super(ConfFixture, self).setUp() # default group self.conf.set_default('compute_driver', 'fake.SmallFakeDriver') self.conf.set_default('fake_network', True) self.conf.set_default('flat_network_bridge', 'br100') self.conf.set_default('floating_ip_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('force_dhcp_release', False) self.conf.set_default('host', 'fake-mini') self.conf.set_default('instance_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('network_size', 8) self.conf.set_default('num_networks', 2) self.conf.set_default('periodic_enable', False) # TODO(sdague): this makes our project_id match 'fake' as well. # We should fix the tests to use real # UUIDs then drop this work around. self.conf.set_default('project_id_regex', '[0-9a-fk\-]+', 'osapi_v21') self.conf.set_default('use_ipv6', True) self.conf.set_default('vlan_interface', 'eth0') # api group self.conf.set_default('auth_strategy', 'noauth2', group='api') # api_database group self.conf.set_default('connection', "sqlite://", group='api_database') self.conf.set_default('sqlite_synchronous', False, group='api_database') # database group self.conf.set_default('connection', "sqlite://", group='database') self.conf.set_default('sqlite_synchronous', False, group='database') # key_manager group self.conf.set_default('backend', 'nova.keymgr.conf_key_mgr.ConfKeyManager', group='key_manager') # wsgi group self.conf.set_default('api_paste_config', paths.state_path_def('etc/nova/api-paste.ini'), group='wsgi') # The functional tests run wsgi API services using fixtures and # eventlet and we want one connection per request so things don't # leak between requests from separate services in concurrently running # tests. self.conf.set_default('keep_alive', False, group="wsgi") # placement group self.conf.set_default('os_region_name', 'RegionOne', group='placement') config.parse_args([], default_config_files=[], configure_db=False, init_rpc=False) policy_opts.set_defaults(self.conf) self.addCleanup(utils.cleanup_dns_managers) self.addCleanup(ipv6.api.reset_backend)
def set_config_defaults(): """This method updates all configuration default values.""" set_cors_middleware_defaults() # TODO(gmann): Remove setting the default value of config policy_file # once oslo_policy change the default value to 'policy.yaml'. # https://github.com/openstack/oslo.policy/blob/a626ad12fe5a3abd49d70e3e5b95589d279ab578/oslo_policy/opts.py#L49 opts.set_defaults(CONF, 'policy.yaml')
def setUp(self): super(Policy, self).setUp() opts.set_defaults(self._config_fixture.conf) self._config_fixture.config(group='oslo_policy', policy_file=self._policy_file) rules.init() self.addCleanup(rules.reset)
def set_defaults(conf): _safe_set_of_opts(conf, 'verbose', True) _safe_set_of_opts( conf, 'state_path', os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..'))) _safe_set_of_opts(conf, 'connection', "sqlite://", group='database') _safe_set_of_opts(conf, 'sqlite_synchronous', False) _POLICY_PATH = os.path.abspath( os.path.join(CONF.state_path, 'manila/tests/policy.json')) opts.set_defaults(conf, policy_file=_POLICY_PATH) _safe_set_of_opts(conf, 'share_export_ip', '0.0.0.0') _safe_set_of_opts(conf, 'service_instance_user', 'fake_user') _API_PASTE_PATH = os.path.abspath( os.path.join(CONF.state_path, 'etc/manila/api-paste.ini')) wsgi.register_opts(conf) _safe_set_of_opts(conf, 'api_paste_config', _API_PASTE_PATH) _safe_set_of_opts(conf, 'share_driver', 'manila.tests.fake_driver.FakeShareDriver') _safe_set_of_opts(conf, 'auth_strategy', 'noauth') _safe_set_of_opts(conf, 'zfs_share_export_ip', '1.1.1.1') _safe_set_of_opts(conf, 'zfs_service_ip', '2.2.2.2') _safe_set_of_opts(conf, 'zfs_zpool_list', ['foo', 'bar']) _safe_set_of_opts(conf, 'zfs_share_helpers', 'NFS=foo.bar.Helper') _safe_set_of_opts(conf, 'zfs_replica_snapshot_prefix', 'foo_prefix_') _safe_set_of_opts(conf, 'hitachi_hsp_host', '172.24.47.190') _safe_set_of_opts(conf, 'hitachi_hsp_username', 'hsp_user') _safe_set_of_opts(conf, 'hitachi_hsp_password', 'hsp_password') _safe_set_of_opts(conf, 'qnap_management_url', 'http://1.2.3.4:8080') _safe_set_of_opts(conf, 'qnap_share_ip', '1.2.3.4') _safe_set_of_opts(conf, 'qnap_nas_login', 'admin') _safe_set_of_opts(conf, 'qnap_nas_password', 'qnapadmin') _safe_set_of_opts(conf, 'qnap_poolname', 'Storage Pool 1')
def prepare_service(args=None, conf=None, config_files=None): if conf is None: conf = cfg.ConfigOpts() log.register_options(conf) policy_opts.set_defaults(conf) for group, options in opts.list_opts(): conf.register_opts(list(options), group=None if group == 'DEFAULT' else group) conf(args, project='vitrage', validate_default_values=True, default_config_files=config_files) for datasource in conf.datasources.types: register_opts(conf, datasource, conf.datasources.path) keystone_client.register_keystoneauth_opts(conf) keystone_client.setup_keystoneauth(conf) log.setup(conf, 'vitrage') conf.log_opt_values(LOG, logging.DEBUG) messaging.setup() return conf
def set_defaults(conf): _safe_set_of_opts(conf, 'verbose', True) _safe_set_of_opts(conf, 'state_path', os.path.abspath( os.path.join(os.path.dirname(__file__), '..', '..'))) _safe_set_of_opts(conf, 'connection', "sqlite://", group='database') _safe_set_of_opts(conf, 'sqlite_synchronous', False) _POLICY_PATH = os.path.abspath(os.path.join(CONF.state_path, 'manila/tests/policy.json')) opts.set_defaults(conf, policy_file=_POLICY_PATH) _safe_set_of_opts(conf, 'share_export_ip', '0.0.0.0') _safe_set_of_opts(conf, 'service_instance_user', 'fake_user') _API_PASTE_PATH = os.path.abspath(os.path.join(CONF.state_path, 'etc/manila/api-paste.ini')) _safe_set_of_opts(conf, 'api_paste_config', _API_PASTE_PATH) _safe_set_of_opts(conf, 'share_driver', 'manila.tests.fake_driver.FakeShareDriver') _safe_set_of_opts(conf, 'auth_strategy', 'noauth') _safe_set_of_opts(conf, 'zfs_share_export_ip', '1.1.1.1') _safe_set_of_opts(conf, 'zfs_service_ip', '2.2.2.2') _safe_set_of_opts(conf, 'zfs_zpool_list', ['foo', 'bar']) _safe_set_of_opts(conf, 'zfs_share_helpers', 'NFS=foo.bar.Helper') _safe_set_of_opts(conf, 'zfs_replica_snapshot_prefix', 'foo_prefix_')
def prepare_service(argv=None, config_files=None): conf = cfg.ConfigOpts() oslo_i18n.enable_lazy() log.register_options(conf) log_levels = (conf.default_log_levels + ['stevedore=INFO', 'keystoneclient=INFO']) log.set_defaults(default_log_levels=log_levels) defaults.set_cors_middleware_defaults() db_options.set_defaults(conf) policy_opts.set_defaults(conf) from aodh import opts # Register our own Aodh options for group, options in opts.list_opts(): conf.register_opts(list(options), group=None if group == "DEFAULT" else group) keystone_client.register_keystoneauth_opts(conf) conf(argv, project='aodh', validate_default_values=True, default_config_files=config_files) keystone_client.setup_keystoneauth(conf) log.setup(conf, 'aodh') messaging.setup() return conf
def parse_config(args, default_config_files=None): set_defaults() log.register_options(CONF) policy_opts.set_defaults(CONF) osprofiler_opts.set_defaults(CONF) db_options.set_defaults(CONF) for group, options in opts.list_opts(): CONF.register_opts(list(options), group=None if group == 'DEFAULT' else group) CONF(args[1:], project='vitrage', validate_default_values=True, default_config_files=default_config_files) if CONF.profiler.enabled: osprofiler_initializer.init_from_conf(conf=CONF, context=None, project='vitrage', service='api', host=CONF.api.host) for datasource in CONF.datasources.types: opts.register_opts(datasource, CONF.datasources.path) keystone_client.register_keystoneauth_opts() log.setup(CONF, 'vitrage') CONF.log_opt_values(LOG, log.DEBUG) messaging.setup()
def test_set_defaults_policy_file(self): opts._register(self.conf) self.assertNotEqual('new-value.json', self.conf.oslo_policy.policy_file) opts.set_defaults(self.conf, policy_file='new-value.json') self.assertEqual('new-value.json', self.conf.oslo_policy.policy_file)
def start_fixture(self): """Set up config.""" self.conf = None # Determine the database connection. db_url = None for engine in ENGINES: try: db_url = os.environ['AODH_TEST_%s_URL' % engine] except KeyError: pass if db_url is None: raise case.SkipTest('No database connection configured') service.prepare_service([]) conf = fixture_config.Config().conf self.conf = conf opts.set_defaults(self.conf) conf.set_override('policy_file', os.path.abspath('etc/aodh/policy.json'), group='oslo_policy') database_name = '%s-%s' % (db_url, str(uuid.uuid4())) conf.set_override('alarm_connection', database_name, group='database') conf.set_override('pecan_debug', True, group='api')
def get_enforcer(): # This method is used by oslopolicy CLI scripts in order to generate policy # files from overrides on disk and defaults in code. We can just pass an # empty list and let oslo do the config lifting for us. cfg.CONF([], project='placement') policy_opts.set_defaults(cfg.CONF) return _get_enforcer(cfg.CONF)
def setUp(self): super(ConfFixture, self).setUp() # default group self.conf.set_default('compute_driver', 'fake.SmallFakeDriver') self.conf.set_default('fake_network', True) self.conf.set_default('flat_network_bridge', 'br100') self.conf.set_default('floating_ip_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('force_dhcp_release', False) self.conf.set_default('host', 'fake-mini') self.conf.set_default('instance_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('network_size', 8) self.conf.set_default('num_networks', 2) self.conf.set_default('periodic_enable', False) self.conf.set_default('use_ipv6', True) self.conf.set_default('vlan_interface', 'eth0') # api group self.conf.set_default('auth_strategy', 'noauth2', group='api') # api_database group self.conf.set_default('connection', "sqlite://", group='api_database') self.conf.set_default('sqlite_synchronous', False, group='api_database') # database group self.conf.set_default('connection', "sqlite://", group='database') self.conf.set_default('sqlite_synchronous', False, group='database') # key_manager group self.conf.set_default('backend', 'nova.keymgr.conf_key_mgr.ConfKeyManager', group='key_manager') # wsgi group self.conf.set_default('api_paste_config', paths.state_path_def('etc/nova/api-paste.ini'), group='wsgi') # The functional tests run wsgi API services using fixtures and # eventlet and we want one connection per request so things don't # leak between requests from separate services in concurrently running # tests. self.conf.set_default('keep_alive', False, group="wsgi") # many tests synchronizes on the reception of versioned notifications self.conf.set_default('notification_format', "both", group="notifications") config.parse_args([], default_config_files=[], configure_db=False, init_rpc=False) policy_opts.set_defaults(self.conf) neutron.register_dynamic_opts(self.conf) self.addCleanup(utils.cleanup_dns_managers) self.addCleanup(ipv6.api.reset_backend)
def setUp(self): super(ConfFixture, self).setUp() # default group self.conf.set_default('compute_driver', 'fake.SmallFakeDriver') self.conf.set_default('fake_network', True) self.conf.set_default('flat_network_bridge', 'br100') self.conf.set_default('floating_ip_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('force_dhcp_release', False) self.conf.set_default('host', 'fake-mini') self.conf.set_default('instance_dns_manager', 'nova.tests.unit.utils.dns_manager') self.conf.set_default('network_size', 8) self.conf.set_default('num_networks', 2) self.conf.set_default('periodic_enable', False) # TODO(sdague): this makes our project_id match 'fake' as well. # We should fix the tests to use real # UUIDs then drop this work around. self.conf.set_default('project_id_regex', '[0-9a-fk\-]+', 'osapi_v21') self.conf.set_default('use_ipv6', True) self.conf.set_default('vlan_interface', 'eth0') # api group self.conf.set_default('auth_strategy', 'noauth2', group='api') # api_database group self.conf.set_default('connection', "sqlite://", group='api_database') self.conf.set_default('sqlite_synchronous', False, group='api_database') # database group self.conf.set_default('connection', "sqlite://", group='database') self.conf.set_default('sqlite_synchronous', False, group='database') # key_manager group self.conf.set_default('api_class', 'nova.keymgr.conf_key_mgr.ConfKeyManager', group='key_manager') # wsgi group self.conf.set_default('api_paste_config', paths.state_path_def('etc/nova/api-paste.ini'), group='wsgi') # The functional tests run wsgi API services using fixtures and # eventlet and we want one connection per request so things don't # leak between requests from separate services in concurrently running # tests. self.conf.set_default('keep_alive', False, group="wsgi") # placement group self.conf.set_default('os_region_name', 'RegionOne', group='placement') config.parse_args([], default_config_files=[], configure_db=False, init_rpc=False) policy_opts.set_defaults(self.conf) self.addCleanup(utils.cleanup_dns_managers) self.addCleanup(ipv6.api.reset_backend)
def setUp(self): super(RequestContextMiddlewareTest, self).setUp() self.fixture = self.useFixture(fixture.Config()) self.fixture.conf(args=['--config-dir', policy_path]) policy_opts.set_defaults(cfg.CONF) cfg.CONF.set_override('policy_file', 'check_admin.json', group='oslo_policy', enforce_type=True)
def prepare_service(argv=None, config_files=None): conf = cfg.ConfigOpts() oslo_i18n.enable_lazy() log.register_options(conf) log_levels = (conf.default_log_levels + ['futurist=INFO', 'keystoneclient=INFO']) log.set_defaults(default_log_levels=log_levels) defaults.set_cors_middleware_defaults() db_options.set_defaults(conf) policy_opts.set_defaults(conf, policy_file=os.path.abspath( os.path.join(os.path.dirname(__file__), "api", "policy.json"))) from aodh import opts # Register our own Aodh options for group, options in opts.list_opts(): conf.register_opts(list(options), group=None if group == "DEFAULT" else group) keystone_client.register_keystoneauth_opts(conf) conf(argv, project='aodh', validate_default_values=True, default_config_files=config_files) ka_loading.load_auth_from_conf_options(conf, "service_credentials") log.setup(conf, 'aodh') messaging.setup() return conf
def parse_args(argv=None): global _CONF_LOADED if _CONF_LOADED: LOG.debug('Configuration has been already loaded') return log.set_defaults() log.register_options(CONF) argv = (argv if argv is not None else sys.argv[1:]) args = ([] if _is_running_under_gunicorn() else argv or []) CONF(args=args, prog='log-api', project='monasca', version=version.version_str, description='RESTful API to collect log files') log.setup(CONF, product_name='monasca-log-api', version=version.version_str) conf.register_opts() policy_opts.set_defaults(CONF) _CONF_LOADED = True
def parse_args(argv=None): """Loads application configuration. Loads entire application configuration just once. """ global _CONF_LOADED if _CONF_LOADED: LOG.debug('Configuration has been already loaded') return log.set_defaults() log.register_options(CONF) argv = (argv if argv is not None else sys.argv[1:]) args = ([] if _is_running_under_gunicorn() else argv or []) CONF(args=args, prog=sys.argv[1:], project='monasca', version=version.version_str, default_config_files=get_config_files(), description='RESTful API for alarming in the cloud') log.setup(CONF, product_name='monasca-api', version=version.version_str) conf.register_opts() policy_opts.set_defaults(CONF) _CONF_LOADED = True
def prepare_service(argv=None, config_files=None, conf=None): if argv is None: argv = sys.argv # FIXME(sileht): Use ConfigOpts() instead if conf is None: conf = cfg.CONF oslo_i18n.enable_lazy() log.register_options(conf) log_levels = ( conf.default_log_levels + ['futurist=INFO', 'neutronclient=INFO', 'keystoneclient=INFO']) log.set_defaults(default_log_levels=log_levels) defaults.set_cors_middleware_defaults() policy_opts.set_defaults(conf) conf(argv[1:], project='ceilometer', validate_default_values=True, version=version.version_info.version_string(), default_config_files=config_files) ka_loading.load_auth_from_conf_options(conf, "service_credentials") log.setup(conf, 'ceilometer') sample.setup(conf) # NOTE(liusheng): guru cannot run with service under apache daemon, so when # ceilometer-api running with mod_wsgi, the argv is [], we don't start # guru. if argv: gmr.TextGuruMeditation.setup_autorun(version) messaging.setup() return conf
def start_fixture(self): global CONF # Set up stderr and stdout captures by directly driving the # existing nova fixtures that do that. This captures the # output that happens outside individual tests (for # example database migrations). self.standard_logging_fixture = capture.Logging() self.standard_logging_fixture.setUp() self.output_stream_fixture = output.CaptureOutput() self.output_stream_fixture.setUp() self.logging_error_fixture = ( logging_error.get_logging_handle_error_fixture()) self.logging_error_fixture.setUp() # Filter ignorable warnings during test runs. self.warnings_fixture = capture.WarningsFixture() self.warnings_fixture.setUp() # Do not use global CONF self.conf_fixture = config_fixture.Config(cfg.ConfigOpts()) self.conf_fixture.setUp() conf.register_opts(self.conf_fixture.conf) self.conf_fixture.config(group='api', auth_strategy='noauth2') self.placement_db_fixture = fixtures.Database(self.conf_fixture, set_config=True) self.placement_db_fixture.setUp() self.context = context.RequestContext() # Register CORS opts, but do not set config. This has the # effect of exercising the "don't use cors" path in # deploy.py. Without setting some config the group will not # be present. self.conf_fixture.register_opts(cors.CORS_OPTS, 'cors') # Set default policy opts, otherwise the deploy module can # NoSuchOptError. policy_opts.set_defaults(self.conf_fixture.conf) # Make sure default_config_files is an empty list, not None. # If None /etc/placement/placement.conf is read and confuses results. self.conf_fixture.conf([], default_config_files=[]) # Turn on a policy fixture. self.policy_fixture = policy_fixture.PolicyFixture(self.conf_fixture) self.policy_fixture.setUp() os.environ['RP_UUID'] = uuidutils.generate_uuid() os.environ['RP_NAME'] = uuidutils.generate_uuid() os.environ['CUSTOM_RES_CLASS'] = 'CUSTOM_IRON_NFV' os.environ['PROJECT_ID'] = uuidutils.generate_uuid() os.environ['USER_ID'] = uuidutils.generate_uuid() os.environ['PROJECT_ID_ALT'] = uuidutils.generate_uuid() os.environ['USER_ID_ALT'] = uuidutils.generate_uuid() os.environ['INSTANCE_UUID'] = uuidutils.generate_uuid() os.environ['MIGRATION_UUID'] = uuidutils.generate_uuid() os.environ['CONSUMER_UUID'] = uuidutils.generate_uuid() os.environ['PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid() os.environ['ALT_PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid() CONF = self.conf_fixture.conf
def start_fixture(self): global CONF # Set up stderr and stdout captures by directly driving the # existing nova fixtures that do that. This captures the # output that happens outside individual tests (for # example database migrations). self.standard_logging_fixture = capture.Logging() self.standard_logging_fixture.setUp() self.output_stream_fixture = output.CaptureOutput() self.output_stream_fixture.setUp() self.logging_error_fixture = ( logging_error.get_logging_handle_error_fixture()) self.logging_error_fixture.setUp() # Filter ignorable warnings during test runs. self.warnings_fixture = capture.WarningsFixture() self.warnings_fixture.setUp() # Do not use global CONF self.conf_fixture = config_fixture.Config(cfg.ConfigOpts()) self.conf_fixture.setUp() conf.register_opts(self.conf_fixture.conf) self.conf_fixture.config(group='api', auth_strategy='noauth2') self.placement_db_fixture = fixtures.Database(self.conf_fixture, set_config=True) self.placement_db_fixture.setUp() self.context = context.RequestContext() # Some database interaction methods require access to the oslo config # via the context. Within the WSGI application this is taken care of # but here in the fixtures we use some of those methods to create # entities. self.context.config = self.conf_fixture.conf # Set default policy opts, otherwise the deploy module can # NoSuchOptError. policy_opts.set_defaults(self.conf_fixture.conf) # Make sure default_config_files is an empty list, not None. # If None /etc/placement/placement.conf is read and confuses results. self.conf_fixture.conf([], default_config_files=[]) # Turn on a policy fixture. self.policy_fixture = policy_fixture.PolicyFixture(self.conf_fixture) self.policy_fixture.setUp() os.environ['RP_UUID'] = uuidutils.generate_uuid() os.environ['RP_NAME'] = uuidutils.generate_uuid() os.environ['CUSTOM_RES_CLASS'] = 'CUSTOM_IRON_NFV' os.environ['PROJECT_ID'] = uuidutils.generate_uuid() os.environ['USER_ID'] = uuidutils.generate_uuid() os.environ['PROJECT_ID_ALT'] = uuidutils.generate_uuid() os.environ['USER_ID_ALT'] = uuidutils.generate_uuid() os.environ['INSTANCE_UUID'] = uuidutils.generate_uuid() os.environ['MIGRATION_UUID'] = uuidutils.generate_uuid() os.environ['CONSUMER_UUID'] = uuidutils.generate_uuid() os.environ['PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid() os.environ['ALT_PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid() CONF = self.conf_fixture.conf
def start_fixture(self): # Set up stderr and stdout captures by directly driving the # existing nova fixtures that do that. This captures the # output that happens outside individual tests (for # example database migrations). self.standard_logging_fixture = capture.Logging() self.standard_logging_fixture.setUp() self.output_stream_fixture = output.CaptureOutput() self.output_stream_fixture.setUp() # Filter ignorable warnings during test runs. self.warnings_fixture = capture.WarningsFixture() self.warnings_fixture.setUp() self.conf_fixture = config_fixture.Config(CONF) self.conf_fixture.setUp() # The Database fixture will get confused if only one of the databases # is configured. for group in ('placement_database', 'api_database', 'database'): self.conf_fixture.config( group=group, connection='sqlite://', sqlite_synchronous=False) self.conf_fixture.config( group='api', auth_strategy='noauth2') self.context = context.RequestContext() # Register CORS opts, but do not set config. This has the # effect of exercising the "don't use cors" path in # deploy.py. Without setting some config the group will not # be present. CONF.register_opts(cors.CORS_OPTS, 'cors') # Set default policy opts, otherwise the deploy module can # NoSuchOptError. policy_opts.set_defaults(CONF) # Make sure default_config_files is an empty list, not None. # If None /etc/nova/nova.conf is read and confuses results. CONF([], default_config_files=[]) self._reset_db_flags() self.placement_db_fixture = fixtures.Database('placement') self.placement_db_fixture.setUp() # Do this now instead of waiting for the WSGI app to start so that # fixtures can have traits. deploy.update_database() os.environ['RP_UUID'] = uuidutils.generate_uuid() os.environ['RP_NAME'] = uuidutils.generate_uuid() os.environ['CUSTOM_RES_CLASS'] = 'CUSTOM_IRON_NFV' os.environ['PROJECT_ID'] = uuidutils.generate_uuid() os.environ['USER_ID'] = uuidutils.generate_uuid() os.environ['PROJECT_ID_ALT'] = uuidutils.generate_uuid() os.environ['USER_ID_ALT'] = uuidutils.generate_uuid() os.environ['INSTANCE_UUID'] = uuidutils.generate_uuid() os.environ['MIGRATION_UUID'] = uuidutils.generate_uuid() os.environ['CONSUMER_UUID'] = uuidutils.generate_uuid() os.environ['PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid() os.environ['ALT_PARENT_PROVIDER_UUID'] = uuidutils.generate_uuid()
def setUp(self): super(FunctionalTest, self).setUp() self.CONF = service.prepare_service([], []) opts.set_defaults(self.CONF) self.CONF.set_override('api_paste_config', self.path_get('etc/panko/api_paste.ini')) self.app = self._make_app(self.CONF)
def set_config_defaults(): """This method updates all configuration default values.""" set_cors_middleware_defaults() # TODO(gmann): Remove setting the default value of config policy_file # once oslo_policy change the default value to 'policy.yaml'. # https://opendev.org/openstack/oslo.policy/src/commit/d8534850d9238e85ae0ea55bf2ac8583681fdb2b/oslo_policy/opts.py#L49 opts.set_defaults(config.CONF, 'policy.yaml')
def setUp(self): super(ConfigFixture, self).setUp() CONF(args=[], prog='common', project='monasca', version=0, description='Testing monasca-common') policy_opts.set_defaults(CONF)
def setUp(self): super(RequestContextMiddlewareTest, self).setUp() self.fixture = self.useFixture(fixture.Config()) self.fixture.conf(args=['--config-dir', policy_path]) policy_opts.set_defaults(cfg.CONF) cfg.CONF.set_override('policy_file', 'check_admin.json', group='oslo_policy')
def prepare_service(args=None, conf=None, default_config_files=None): if conf is None: conf = cfg.ConfigOpts() opts.set_defaults() # FIXME(jd) Use the pkg_entry info to register the options of these libs log.register_options(conf) db_options.set_defaults(conf) policy_opts.set_defaults(conf) # Register our own Gnocchi options for group, options in opts.list_opts(): conf.register_opts(list(options), group=None if group == "DEFAULT" else group) conf.set_default("workers", utils.get_default_workers(), group="metricd") conf(args, project='gnocchi', validate_default_values=True, default_config_files=default_config_files, version=pbr.version.VersionInfo('gnocchi').version_string()) # HACK(jd) I'm not happy about that, fix AP class to handle a conf object? archive_policy.ArchivePolicy.DEFAULT_AGGREGATION_METHODS = ( conf.archive_policy.default_aggregation_methods) # If no coordination URL is provided, default to using the indexer as # coordinator if conf.storage.coordination_url is None: if conf.storage.driver == "redis": conf.set_default("coordination_url", conf.storage.redis_url, "storage") elif conf.incoming.driver == "redis": conf.set_default("coordination_url", conf.incoming.redis_url, "storage") else: parsed = urlparse.urlparse(conf.indexer.url) proto, _, _ = parsed.scheme.partition("+") parsed = list(parsed) # Set proto without the + part parsed[0] = proto conf.set_default("coordination_url", urlparse.urlunparse(parsed), "storage") cfg_path = conf.oslo_policy.policy_file if not os.path.isabs(cfg_path): cfg_path = conf.find_file(cfg_path) if cfg_path is None or not os.path.exists(cfg_path): cfg_path = os.path.abspath( os.path.join(os.path.dirname(__file__), 'rest', 'policy.json')) conf.set_default('policy_file', cfg_path, group='oslo_policy') log.set_defaults(default_log_levels=log.get_default_log_levels() + ["passlib.utils.compat=INFO"]) log.setup(conf, 'gnocchi') conf.log_opt_values(LOG, log.DEBUG) return conf
def setUp(self): super(RequestContextMiddlewareTest, self).setUp() opts = [ cfg.StrOpt('config_dir', default=policy_path), cfg.StrOpt('config_file', default='foo'), cfg.StrOpt('project', default='heat'), ] cfg.CONF.register_opts(opts) policy_opts.set_defaults(cfg.CONF, 'check_admin.json')
def start_fixture(self): """Set up config.""" self.conf = None self.conn = None # Determine the database connection. db_url = os.environ.get( 'AODH_TEST_STORAGE_URL', "").replace( "mysql://", "mysql+pymysql://") if not db_url: self.fail('No database connection configured') conf = service.prepare_service([], config_files=[]) # NOTE(jd): prepare_service() is called twice: first by load_app() for # Pecan, then Pecan calls pastedeploy, which starts the app, which has # no way to pass the conf object so that Paste apps calls again # prepare_service. In real life, that's not a problem, but here we want # to be sure that the second time the same conf object is returned # since we tweaked it. To that, once we called prepare_service() we # mock it so it returns the same conf object. self.prepare_service = service.prepare_service service.prepare_service = mock.Mock() service.prepare_service.return_value = conf conf = fixture_config.Config(conf).conf self.conf = conf opts.set_defaults(self.conf) conf.set_override('policy_file', os.path.abspath( 'aodh/tests/open-policy.json'), group='oslo_policy', enforce_type=True) conf.set_override( 'paste_config', os.path.abspath('aodh/tests/functional/gabbi/gabbi_paste.ini'), group='api', ) conf.set_override('pecan_debug', True, group='api', enforce_type=True) parsed_url = urlparse.urlparse(db_url) if parsed_url.scheme != 'sqlite': parsed_url = list(parsed_url) parsed_url[2] += '-%s' % str(uuid.uuid4()).replace('-', '') db_url = urlparse.urlunparse(parsed_url) conf.set_override('connection', db_url, group='database', enforce_type=True) if (parsed_url[0].startswith("mysql") or parsed_url[0].startswith("postgresql")): sqlalchemy_utils.create_database(conf.database.connection) self.conn = storage.get_connection_from_config(self.conf) self.conn.upgrade()
def _setUp(self): self.policy_dir = self.useFixture(fixtures.TempDir()) self.policy_file_name = os.path.join(self.policy_dir.path, 'policy.json') with open(self.policy_file_name, 'w') as policy_file: policy_file.write(fake_policy.policy_data) policy_opts.set_defaults(CONF) CONF.set_override('policy_file', self.policy_file_name, 'oslo_policy') watcher_policy._ENFORCER = None self.addCleanup(watcher_policy.init().clear)
def setUp(self): super(PolicyFixture, self).setUp() policy_opts.set_defaults(cfg.CONF) acl._ENFORCER = oslo_policy.Enforcer(cfg.CONF) acl._ENFORCER.register_defaults(policies.list_rules()) acl._ENFORCER.load_rules() self.addCleanup(acl._ENFORCER.clear)
def start_fixture(self): """Set up config.""" global LOAD_APP_KWARGS self.conf = None # Determine the database connection. db_url = os.environ.get('PIFPAF_URL', "sqlite://").replace( "mysql://", "mysql+pymysql://") if not db_url: raise case.SkipTest('No database connection configured') engine = urlparse.urlparse(db_url).scheme if engine not in ENGINES: raise case.SkipTest('Database engine not supported') conf = fixture_config.Config().conf self.conf = conf self.conf([], project='ceilometer', validate_default_values=True) opts.set_defaults(self.conf) conf.import_group('api', 'ceilometer.api.controllers.v2.root') content = ('{"default": ""}') if six.PY3: content = content.encode('utf-8') self.tempfile = fileutils.write_to_tempfile(content=content, prefix='policy', suffix='.json') conf.set_override("policy_file", self.tempfile, group='oslo_policy') conf.set_override( 'api_paste_config', os.path.abspath( 'ceilometer/tests/functional/gabbi/gabbi_paste.ini') ) # A special pipeline is required to use the direct publisher. conf.import_opt('pipeline_cfg_file', 'ceilometer.pipeline') conf.set_override('pipeline_cfg_file', 'ceilometer/tests/functional/gabbi_pipeline.yaml') database_name = '%s-%s' % (db_url, str(uuid.uuid4())) conf.set_override('connection', database_name, group='database') conf.set_override('metering_connection', '', group='database') conf.set_override('event_connection', '', group='database') conf.set_override('gnocchi_is_enabled', False, group='api') conf.set_override('aodh_is_enabled', False, group='api') conf.set_override('panko_is_enabled', False, group='api') LOAD_APP_KWARGS = { 'conf': conf, }
def setUp(self): super(PolicyFixture, self).setUp() self.policy_dir = self.useFixture(fixtures.TempDir()) self.policy_file_name = os.path.join(self.policy_dir.path, 'policy.json') with open(self.policy_file_name, 'w') as policy_file: policy_file.write(fake_policy.get_policy_data(self.compat)) policy_opts.set_defaults(CONF) CONF.set_override('policy_file', self.policy_file_name, 'oslo_policy') magnum_policy._ENFORCER = None self.addCleanup(magnum_policy.init().clear)
def setUp(self): super(RequestContextMiddlewareTest, self).setUp() opts = [ cfg.StrOpt('config_dir', default=policy_path), cfg.StrOpt('config_file', default='foo'), cfg.StrOpt('project', default='senlin'), ] cfg.CONF.register_opts(opts) policy_opts.set_defaults(cfg.CONF) cfg.CONF.set_override('policy_file', 'check_admin.json', group='oslo_policy')
def setUp(self): super(ConfFixture, self).setUp() self.conf.set_default('api_paste_config', paths.state_path_def('etc/masakari/api-paste.ini' ), group='wsgi') config.parse_args([], default_config_files=[], configure_db=False, init_rpc=False) self.conf.set_default('connection', "sqlite://", group='database') policy_opts.set_defaults(self.conf)
def setUp(self): super(PolicyFixture, self).setUp() self.policy_dir = self.useFixture(fixtures.TempDir()) self.policy_file_name = os.path.join(self.policy_dir.path, 'policy.json') with open(self.policy_file_name, 'w') as policy_file: policy_file.write(policy_data) policy_opts.set_defaults(CONF) CONF.set_override('policy_file', self.policy_file_name, 'oslo_policy') inspector_policy._ENFORCER = None self.addCleanup(inspector_policy.get_enforcer().clear)
def _get_policy_conf(): conf = cfg.ConfigOpts() # Passing [] is required. Otherwise oslo.config looks up sys.argv. conf([]) policy_opts.set_defaults(conf) # Policy Enforcer has been updated to take in a policy directory # as a config option. However, the default value in is set to # ['policy.d'] which causes the code to break. Set the default # value to empty list for now. conf.set_default('policy_dirs', [], 'oslo_policy') return conf
def setUp(self): super(FunctionalTest, self).setUp() self.CONF = self.useFixture(fixture_config.Config()).conf self.setup_messaging(self.CONF) opts.set_defaults(self.CONF) self.CONF.set_override("auth_version", "v2.0", group=OPT_GROUP_NAME) self.CONF.set_override("policy_file", self.path_get('etc/ceilometer/policy.json'), group='oslo_policy') self.app = self._make_app()
def start_fixture(self): """Set up config.""" self.conf = None # Determine the database connection. db_url = os.environ.get( 'AODH_TEST_STORAGE_URL', os.environ.get( "OVERTEST_URL", 'sqlite://').replace( "mysql://", "mysql+pymysql://")) if not db_url: raise case.SkipTest('No database connection configured') engine = urlparse.urlparse(db_url).scheme if engine not in ENGINES: raise case.SkipTest('Database engine not supported') conf = service.prepare_service([], config_files=[]) # NOTE(jd): prepare_service() is called twice: first by load_app() for # Pecan, then Pecan calls pastedeploy, which starts the app, which has # no way to pass the conf object so that Paste apps calls again # prepare_service. In real life, that's not a problem, but here we want # to be sure that the second time the same conf object is returned # since we tweaked it. To that, once we called prepare_service() we # mock it so it returns the same conf object. self.prepare_service = service.prepare_service service.prepare_service = mock.Mock() service.prepare_service.return_value = conf conf = fixture_config.Config(conf).conf self.conf = conf opts.set_defaults(self.conf) conf.set_override('policy_file', os.path.abspath( 'aodh/tests/open-policy.json'), group='oslo_policy', enforce_type=True) conf.set_override( 'paste_config', os.path.abspath('aodh/tests/functional/gabbi/gabbi_paste.ini'), group='api', ) database_name = '%s-%s' % (db_url, str(uuid.uuid4())) conf.set_override('connection', database_name, group='database', enforce_type=True) conf.set_override('pecan_debug', True, group='api', enforce_type=True)
def setUp(self): super(FunctionalTest, self).setUp() self.CONF = self.useFixture(fixture_config.Config()).conf self.setup_messaging(self.CONF) opts.set_defaults(self.CONF) self.CONF.set_override("policy_file", self.path_get('etc/ceilometer/policy.json'), group='oslo_policy') self.CONF.set_override('gnocchi_is_enabled', False, group='api') self.CONF.set_override('aodh_is_enabled', False, group='api') self.app = self._make_app()
def _parse_args(argv, default_config_files): logging.register_options(conf.CONF) if profiler: profiler.set_defaults(conf.CONF) _set_middleware_defaults() # This is needed so we can check [oslo_policy]/enforce_scope in the # deploy module. policy_opts.set_defaults(conf.CONF) conf.CONF(argv[1:], project='nova', version=version_info.version_string(), default_config_files=default_config_files)
def prepare_service(args=None, conf=None, default_config_files=None): if conf is None: conf = cfg.ConfigOpts() opts.set_defaults() # FIXME(jd) Use the pkg_entry info to register the options of these libs log.register_options(conf) db_options.set_defaults(conf) policy_opts.set_defaults(conf) # Register our own Gnocchi options for group, options in opts.list_opts(): conf.register_opts(list(options), group=None if group == "DEFAULT" else group) # HACK(jd) I'm not happy about that, fix AP class to handle a conf object? archive_policy.ArchivePolicy.DEFAULT_AGGREGATION_METHODS = ( conf.archive_policy.default_aggregation_methods ) try: default_workers = multiprocessing.cpu_count() or 1 except NotImplementedError: default_workers = 1 conf.set_default("workers", default_workers, group="metricd") conf(args, project='gnocchi', validate_default_values=True, default_config_files=default_config_files, version=pbr.version.VersionInfo('gnocchi').version_string()) # If no coordination URL is provided, default to using the indexer as # coordinator if conf.storage.coordination_url is None: parsed = urlparse.urlparse(conf.indexer.url) proto, _, _ = parsed.scheme.partition("+") parsed = list(parsed) # Set proto without the + part parsed[0] = proto conf.set_default("coordination_url", urlparse.urlunparse(parsed), "storage") log.set_defaults(default_log_levels=log.get_default_log_levels() + ["passlib.utils.compat=INFO"]) log.setup(conf, 'gnocchi') conf.log_opt_values(LOG, log.DEBUG) return conf
def setUp(self): super(TestApi, self).setUp() self.PATH_PREFIX = '/v2' self.CONF = self.useFixture(fixture_config.Config()).conf self.CONF([], project='ceilometer', validate_default_values=True) self.setup_messaging(self.CONF) opts.set_defaults(self.CONF) self.CONF.set_override("auth_version", "v2.0", group=OPT_GROUP_NAME) self.CONF.set_override("policy_file", self.path_get('etc/ceilometer/policy.json'), group='oslo_policy') self.CONF.import_opt('pipeline_cfg_file', 'ceilometer.pipeline') self.CONF.set_override( 'pipeline_cfg_file', self.path_get('etc/ceilometer/pipeline.yaml') ) self.CONF.import_opt('monasca_mappings', 'ceilometer.publisher.monasca_data_filter', group='monasca') self.CONF.set_override( 'monasca_mappings', self.path_get('etc/ceilometer/monasca_field_definitions.yaml'), group='monasca' ) with mock.patch("ceilometer.monasca_client.Client") as mock_client,\ mock.patch('ceilometer.storage.get_connection') as \ get_storage_conn, \ mock.patch('ceilometer.publisher.get_publisher') as get_pub: get_storage_conn.side_effect = ( self.get_connection_with_mock_driver_manager) get_pub.side_effect = self.get_publisher_with_mock_driver_manager self.mock_mon_client = mock_client self.conn = storage.get_connection('monasca://127.0.0.1:8080', 'ceilometer.metering.storage') self.useFixture(mockpatch.Patch( 'ceilometer.storage.get_connection', return_value=self.conn)) self.app = self._make_app()