Python oslo_config.cfg.IntOpt() Examples
The following are 30
code examples of oslo_config.cfg.IntOpt().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
oslo_config.cfg
, or try the search function
.
Example #1
Source File: test_db_manage.py From watcher with Apache License 2.0 | 6 votes |
def test_run_db_purge_negative_max_number(self, m_purge_cls, m_exit): m_purge = mock.Mock() m_purge_cls.return_value = m_purge m_purge_cls.get_goal_uuid.return_value = 'Some UUID' cfg.CONF.register_opt(cfg.IntOpt("age_in_days"), group="command") cfg.CONF.register_opt(cfg.IntOpt("max_number"), group="command") cfg.CONF.register_opt(cfg.StrOpt("goal"), group="command") cfg.CONF.register_opt(cfg.BoolOpt("exclude_orphans"), group="command") cfg.CONF.register_opt(cfg.BoolOpt("dry_run"), group="command") cfg.CONF.set_default("age_in_days", None, group="command") cfg.CONF.set_default("max_number", -1, group="command") cfg.CONF.set_default("goal", None, group="command") cfg.CONF.set_default("exclude_orphans", True, group="command") cfg.CONF.set_default("dry_run", False, group="command") dbmanage.DBCommand.purge() self.assertEqual(0, m_purge_cls.call_count) self.assertEqual(0, m_purge.execute.call_count) self.assertEqual(0, m_purge.do_delete.call_count) self.assertEqual(1, m_exit.call_count)
Example #2
Source File: test_ovsdb_lib.py From os-vif with Apache License 2.0 | 6 votes |
def setUp(self): super(BaseOVSTest, self).setUp() test_vif_plug_ovs_group = cfg.OptGroup('test_vif_plug_ovs') CONF.register_group(test_vif_plug_ovs_group) CONF.register_opt(cfg.IntOpt('ovs_vsctl_timeout', default=1500), test_vif_plug_ovs_group) CONF.register_opt(cfg.StrOpt('ovsdb_interface', default='vsctl'), test_vif_plug_ovs_group) CONF.register_opt(cfg.StrOpt('ovsdb_connection', default=None), test_vif_plug_ovs_group) self.br = ovsdb_lib.BaseOVS(cfg.CONF.test_vif_plug_ovs) self.mock_db_set = mock.patch.object(self.br.ovsdb, 'db_set').start() self.mock_del_port = mock.patch.object(self.br.ovsdb, 'del_port').start() self.mock_add_port = mock.patch.object(self.br.ovsdb, 'add_port').start() self.mock_add_br = mock.patch.object(self.br.ovsdb, 'add_br').start() self.mock_transaction = mock.patch.object(self.br.ovsdb, 'transaction').start()
Example #3
Source File: config.py From st2 with Apache License 2.0 | 6 votes |
def _register_ssh_runner_opts(): ssh_runner_opts = [ cfg.BoolOpt( 'use_ssh_config', default=False, help='Use the .ssh/config file. Useful to override ports etc.'), cfg.StrOpt( 'remote_dir', default='/tmp', help='Location of the script on the remote filesystem.'), cfg.BoolOpt( 'allow_partial_failure', default=False, help='How partial success of actions run on multiple nodes should be treated.'), cfg.IntOpt( 'max_parallel_actions', default=50, help='Max number of parallel remote SSH actions that should be run. ' 'Works only with Paramiko SSH runner.'), ] _register_opts(ssh_runner_opts, group='ssh_runner')
Example #4
Source File: config.py From st2 with Apache License 2.0 | 6 votes |
def _register_action_sensor_opts(): action_sensor_opts = [ cfg.BoolOpt( 'enable', default=True, help='Whether to enable or disable the ability to post a trigger on action.'), cfg.StrOpt( 'triggers_base_url', default='http://127.0.0.1:9101/v1/triggertypes/', help='URL for action sensor to post TriggerType.'), cfg.IntOpt( 'request_timeout', default=1, help='Timeout value of all httprequests made by action sensor.'), cfg.IntOpt( 'max_attempts', default=10, help='No. of times to retry registration.'), cfg.IntOpt( 'retry_wait', default=1, help='Amount of time to wait prior to retrying a request.') ] _register_opts(action_sensor_opts, group='action_sensor')
Example #5
Source File: config.py From st2 with Apache License 2.0 | 6 votes |
def _register_app_opts(): # Note "allow_origin", "mask_secrets", "heartbeat" options are registered as part of st2common # config since they are also used outside st2stream api_opts = [ cfg.StrOpt( 'host', default='127.0.0.1', help='StackStorm stream API server host'), cfg.IntOpt( 'port', default=9102, help='StackStorm API stream, server port'), cfg.BoolOpt( 'debug', default=False, help='Specify to enable debug mode.'), cfg.StrOpt( 'logging', default='/etc/st2/logging.stream.conf', help='location of the logging.conf file') ] CONF.register_opts(api_opts, group='stream')
Example #6
Source File: test_db_manage.py From watcher with Apache License 2.0 | 6 votes |
def test_run_db_purge_dry_run(self, m_purge_cls, m_exit): m_purge = mock.Mock() m_purge_cls.return_value = m_purge m_purge_cls.get_goal_uuid.return_value = 'Some UUID' cfg.CONF.register_opt(cfg.IntOpt("age_in_days"), group="command") cfg.CONF.register_opt(cfg.IntOpt("max_number"), group="command") cfg.CONF.register_opt(cfg.StrOpt("goal"), group="command") cfg.CONF.register_opt(cfg.BoolOpt("exclude_orphans"), group="command") cfg.CONF.register_opt(cfg.BoolOpt("dry_run"), group="command") cfg.CONF.set_default("age_in_days", None, group="command") cfg.CONF.set_default("max_number", None, group="command") cfg.CONF.set_default("goal", None, group="command") cfg.CONF.set_default("exclude_orphans", True, group="command") cfg.CONF.set_default("dry_run", True, group="command") dbmanage.DBCommand.purge() m_purge_cls.assert_called_once_with( None, None, 'Some UUID', True, True) self.assertEqual(1, m_purge.execute.call_count) self.assertEqual(0, m_purge.do_delete.call_count) self.assertEqual(0, m_exit.call_count)
Example #7
Source File: test_db_manage.py From watcher with Apache License 2.0 | 6 votes |
def test_run_db_purge(self, m_purge_cls): m_purge = mock.Mock() m_purge_cls.return_value = m_purge m_purge_cls.get_goal_uuid.return_value = 'Some UUID' cfg.CONF.register_opt(cfg.IntOpt("age_in_days"), group="command") cfg.CONF.register_opt(cfg.IntOpt("max_number"), group="command") cfg.CONF.register_opt(cfg.StrOpt("goal"), group="command") cfg.CONF.register_opt(cfg.BoolOpt("exclude_orphans"), group="command") cfg.CONF.register_opt(cfg.BoolOpt("dry_run"), group="command") cfg.CONF.set_default("age_in_days", None, group="command") cfg.CONF.set_default("max_number", None, group="command") cfg.CONF.set_default("goal", None, group="command") cfg.CONF.set_default("exclude_orphans", True, group="command") cfg.CONF.set_default("dry_run", False, group="command") dbmanage.DBCommand.purge() m_purge_cls.assert_called_once_with( None, None, 'Some UUID', True, False) m_purge.execute.assert_called_once_with()
Example #8
Source File: default.py From watcher with Apache License 2.0 | 6 votes |
def get_config_opts(cls): return [ cfg.IntOpt( 'max_workers', default=processutils.get_worker_count(), min=1, required=True, help='Number of workers for taskflow engine ' 'to execute actions.'), cfg.DictOpt( 'action_execution_rule', default={}, help='The execution rule for linked actions,' 'the key is strategy name and ' 'value ALWAYS means all actions will be executed,' 'value ANY means if previous action executes ' 'success, the next action will be ignored.' 'None means ALWAYS.') ]
Example #9
Source File: test_static_driver.py From vitrage with Apache License 2.0 | 6 votes |
def _set_conf(self, sub_dir=None): default_dir = utils.get_resources_dir() + \ '/static_datasources' + (sub_dir if sub_dir else '') opts = [ cfg.StrOpt(DSOpts.TRANSFORMER, default='vitrage.datasources.static.transformer.' 'StaticTransformer'), cfg.StrOpt(DSOpts.DRIVER, default='vitrage.datasources.static.driver.' 'StaticDriver'), cfg.IntOpt(DSOpts.CHANGES_INTERVAL, default=30, min=30, help='interval between checking changes in the static ' 'datasources'), cfg.StrOpt('directory', default=default_dir), ] self.conf_reregister_opts(opts, group=STATIC_DATASOURCE)
Example #10
Source File: config.py From syntribos with Apache License 2.0 | 6 votes |
def list_test_opts(): return [ cfg.FloatOpt("length_diff_percent", default=1000.0, help=_( "Percentage difference between initial request " "and test request body length to trigger a signal")), cfg.FloatOpt("time_diff_percent", default=1000.0, help=_( "Percentage difference between initial response " "time and test response time to trigger a signal")), cfg.IntOpt("max_time", default=10, help=_( "Maximum absolute time (in seconds) to wait for a " "response before triggering a timeout signal")), cfg.IntOpt("max_length", default=500, help=_( "Maximum length (in characters) of the response text")), cfg.ListOpt("failure_keys", default="[`syntax error`]", help=_( "Comma seperated list of keys for which the test " "would fail.")) ]
Example #11
Source File: injector.py From gnocchi with Apache License 2.0 | 6 votes |
def injector(): conf = cfg.ConfigOpts() conf.register_cli_opts([ cfg.IntOpt("--measures", help="Measures per metric."), cfg.IntOpt("--metrics", help="Number of metrics to create."), cfg.IntOpt("--archive-policy-name", help="Name of archive policy to use.", default="low"), cfg.IntOpt("--interval", help="Interval to sleep between metrics sending."), cfg.BoolOpt("--process", default=False, help="Process the ingested measures."), ]) return _inject(service.prepare_service(conf=conf, log_to_std=True), metrics=conf.metrics, measures=conf.measures, archive_policy_name=conf.archive_policy_name, process=conf.process, interval=conf.interval)
Example #12
Source File: cloudstack.py From cloudbase-init with Apache License 2.0 | 6 votes |
def __init__(self, config): super(CloudStackOptions, self).__init__(config, group="cloudstack") self._options = [ cfg.StrOpt( "metadata_base_url", default="http://10.1.1.1/", help="The base URL where the service looks for metadata", deprecated_name="cloudstack_metadata_ip", deprecated_group="DEFAULT"), cfg.IntOpt( "password_server_port", default=8080, help="The port number used by the Password Server." ), cfg.BoolOpt( "https_allow_insecure", default=False, help="Whether to disable the validation of HTTPS " "certificates."), cfg.StrOpt( "https_ca_bundle", default=None, help="The path to a CA_BUNDLE file or directory with " "certificates of trusted CAs."), cfg.BoolOpt( "add_metadata_private_ip_route", default=False, help="Add a route for the metadata ip address to the gateway"), ]
Example #13
Source File: config.py From st2 with Apache License 2.0 | 5 votes |
def _register_auth_opts(): auth_opts = [ cfg.StrOpt('host', default='127.0.0.1'), cfg.IntOpt('port', default=9100), cfg.BoolOpt('use_ssl', default=False), cfg.StrOpt('mode', default='proxy'), cfg.StrOpt('backend', default='flat_file'), cfg.StrOpt('backend_kwargs', default=None), cfg.StrOpt('logging', default='conf/logging.conf'), cfg.IntOpt('token_ttl', default=86400, help='Access token ttl in seconds.'), cfg.BoolOpt('debug', default=True) ] _register_opts(auth_opts, group='auth')
Example #14
Source File: config.py From st2 with Apache License 2.0 | 5 votes |
def _register_app_opts(): available_backends = get_available_backends() auth_opts = [ cfg.StrOpt( 'host', default='127.0.0.1', help='Host on which the service should listen on.'), cfg.IntOpt( 'port', default=9100, help='Port on which the service should listen on.'), cfg.BoolOpt( 'use_ssl', default=False, help='Specify to enable SSL / TLS mode'), cfg.StrOpt( 'cert', default='/etc/apache2/ssl/mycert.crt', help='Path to the SSL certificate file. Only used when "use_ssl" is specified.'), cfg.StrOpt( 'key', default='/etc/apache2/ssl/mycert.key', help='Path to the SSL private key file. Only used when "use_ssl" is specified.'), cfg.StrOpt( 'logging', default='/etc/st2/logging.auth.conf', help='Path to the logging config.'), cfg.BoolOpt( 'debug', default=False, help='Specify to enable debug mode.'), cfg.StrOpt( 'mode', default=DEFAULT_MODE, help='Authentication mode (%s)' % (','.join(VALID_MODES))), cfg.StrOpt( 'backend', default=DEFAULT_BACKEND, help='Authentication backend to use in a standalone mode. Available ' 'backends: %s.' % (', '.join(available_backends))), cfg.StrOpt( 'backend_kwargs', default=None, help='JSON serialized arguments which are passed to the authentication ' 'backend in a standalone mode.') ] cfg.CONF.register_cli_opts(auth_opts, group='auth')
Example #15
Source File: config.py From st2 with Apache License 2.0 | 5 votes |
def _register_service_opts(): scheduler_opts = [ cfg.StrOpt( 'logging', default='/etc/st2/logging.scheduler.conf', help='Location of the logging configuration file.' ), cfg.FloatOpt( 'execution_scheduling_timeout_threshold_min', default=1, help='How long GC to search back in minutes for orphaned scheduled actions'), cfg.IntOpt( 'pool_size', default=10, help='The size of the pool used by the scheduler for scheduling executions.'), cfg.FloatOpt( 'sleep_interval', default=0.10, help='How long (in seconds) to sleep between each action scheduler main loop run ' 'interval.'), cfg.FloatOpt( 'gc_interval', default=10, help='How often (in seconds) to look for zombie execution requests before rescheduling ' 'them.'), cfg.IntOpt( 'retry_max_attempt', default=10, help='The maximum number of attempts that the scheduler retries on error.'), cfg.IntOpt( 'retry_wait_msec', default=3000, help='The number of milliseconds to wait in between retries.') ] cfg.CONF.register_opts(scheduler_opts, group='scheduler')
Example #16
Source File: config.py From st2 with Apache License 2.0 | 5 votes |
def _register_garbage_collector_opts(): common_opts = [ cfg.IntOpt( 'collection_interval', default=DEFAULT_COLLECTION_INTERVAL, help='How often to check database for old data and perform garbage collection.'), cfg.FloatOpt( 'sleep_delay', default=DEFAULT_SLEEP_DELAY, help='How long to wait / sleep (in seconds) between ' 'collection of different object types.') ] _register_opts(common_opts, group='garbagecollector') ttl_opts = [ cfg.IntOpt( 'action_executions_ttl', default=None, help='Action executions and related objects (live actions, action output ' 'objects) older than this value (days) will be automatically deleted.'), cfg.IntOpt( 'action_executions_output_ttl', default=7, help='Action execution output objects (ones generated by action output ' 'streaming) older than this value (days) will be automatically deleted.'), cfg.IntOpt( 'trigger_instances_ttl', default=None, help='Trigger instances older than this value (days) will be automatically deleted.') ] _register_opts(ttl_opts, group='garbagecollector') inquiry_opts = [ cfg.BoolOpt( 'purge_inquiries', default=False, help='Set to True to perform garbage collection on Inquiries (based on ' 'the TTL value per Inquiry)') ] _register_opts(inquiry_opts, group='garbagecollector')
Example #17
Source File: measures_injector.py From gnocchi with Apache License 2.0 | 5 votes |
def injector(): conf = cfg.ConfigOpts() conf.register_cli_opts([ cfg.IntOpt("metrics", default=1, min=1), cfg.StrOpt("archive-policy-name", default="low"), cfg.StrOpt("creator", default="admin"), cfg.IntOpt("batch-of-measures", default=1000), cfg.IntOpt("measures-per-batch", default=10), ]) conf = service.prepare_service(conf=conf) index = indexer.get_driver(conf) instore = incoming.get_driver(conf) def todo(): metric = index.create_metric( uuid.uuid4(), creator=conf.creator, archive_policy_name=conf.archive_policy_name) for _ in six.moves.range(conf.batch_of_measures): measures = [ incoming.Measure( utils.dt_in_unix_ns(utils.utcnow()), random.random()) for __ in six.moves.range(conf.measures_per_batch)] instore.add_measures(metric, measures) with futures.ThreadPoolExecutor(max_workers=conf.metrics) as executor: for m in six.moves.range(conf.metrics): executor.submit(todo)
Example #18
Source File: __init__.py From designate with Apache License 2.0 | 5 votes |
def get_cfg_opts(cls): group = cfg.OptGroup( name='backend:ipa', title="Configuration for IPA Backend" ) opts = [ cfg.StrOpt('ipa-host', default='localhost.localdomain', help='IPA RPC listener host - must be FQDN'), cfg.IntOpt('ipa-port', default=IPA_DEFAULT_PORT, help='IPA RPC listener port'), cfg.StrOpt('ipa-client-keytab', help='Kerberos client keytab file'), cfg.StrOpt('ipa-auth-driver-class', default='designate.backend.impl_ipa.auth.IPAAuth', help='Class that implements the authentication ' 'driver for IPA'), cfg.StrOpt('ipa-ca-cert', help='CA certificate for use with https to IPA'), cfg.StrOpt('ipa-base-url', default='/ipa', help='Base URL for IPA RPC, relative to host[:port]'), cfg.StrOpt('ipa-json-url', default='/json', help='URL for IPA JSON RPC, relative to IPA base URL'), cfg.IntOpt('ipa-connect-retries', default=1, help='How many times Designate will attempt to retry ' 'the connection to IPA before giving up'), cfg.BoolOpt('ipa-force-ns-use', default=False, help='IPA requires that a specified ' 'name server or SOA MNAME is resolvable - if this ' 'option is set, Designate will force IPA to use a ' 'given name server even if it is not resolvable'), cfg.StrOpt('ipa-version', default='2.65', help='IPA RPC JSON version') ] return [(group, opts)]
Example #19
Source File: config.py From syntribos with Apache License 2.0 | 5 votes |
def list_user_opts(): return [ cfg.StrOpt("version", default="v2.0", help=_("keystone version"), choices=["v2.0", "v3"]), cfg.StrOpt("username", default="", help=_("keystone username")), cfg.StrOpt("password", default="", help=_("keystone user password"), secret=True), cfg.StrOpt("user_id", default="", help=_("Keystone user ID"), secret=True), cfg.StrOpt("token", default="", help=_("keystone auth token"), secret=True), cfg.StrOpt("endpoint", default="", help=_("keystone endpoint URI")), cfg.StrOpt("domain_name", default="", help=_("keystone domain name")), cfg.StrOpt("project_id", default="", help=_("keystone project id")), cfg.StrOpt("project_name", default="", help=_("keystone project name")), cfg.StrOpt("domain_id", default="", help=_("keystone domain id")), cfg.StrOpt("tenant_name", default="", help=_("keystone tenant name")), cfg.StrOpt("tenant_id", default="", help=_("keystone tenant id")), cfg.StrOpt("serialize_format", default="json", help=_("Type of request body")), cfg.StrOpt("deserialize_format", default="json", help=_("Type of response body")), cfg.IntOpt("token_ttl", default=1800, help=_("Time to live for token in seconds")) ]
Example #20
Source File: config.py From st2 with Apache License 2.0 | 5 votes |
def _register_stream_opts(): stream_opts = [ cfg.IntOpt( 'heartbeat', default=25, help='Send empty message every N seconds to keep connection open'), cfg.BoolOpt( 'debug', default=False, help='Specify to enable debug mode.'), ] _register_opts(stream_opts, group='stream')
Example #21
Source File: base.py From watcher with Apache License 2.0 | 5 votes |
def get_config_opts(cls): return [ cfg.IntOpt( 'period', default=3600, help='The time interval (in seconds) between each ' 'synchronization of the model'), ]
Example #22
Source File: multi_backend.py From glance_store with Apache License 2.0 | 5 votes |
def register_store_opts(conf, reserved_stores=None): LOG.debug("Registering options for group %s", _STORE_CFG_GROUP) conf.register_opts(_STORE_OPTS, group=_STORE_CFG_GROUP) configured_backends = copy.deepcopy(conf.enabled_backends) if reserved_stores: conf.enabled_backends.update(reserved_stores) for key in reserved_stores.keys(): fs_conf_template = [ cfg.StrOpt('filesystem_store_datadir', default='/var/lib/glance/{}'.format(key), help=FS_CONF_DATADIR_HELP.format(key)), cfg.MultiStrOpt('filesystem_store_datadirs', help="""Not used"""), cfg.StrOpt('filesystem_store_metadata_file', help="""Not used"""), cfg.IntOpt('filesystem_store_file_perm', default=0, help="""Not used"""), cfg.IntOpt('filesystem_store_chunk_size', default=64 * units.Ki, min=1, help=FS_CONF_CHUNKSIZE_HELP.format(key))] LOG.debug("Registering options for reserved store: {}".format(key)) conf.register_opts(fs_conf_template, group=key) driver_opts = _list_driver_opts() for backend in configured_backends: for opt_list in driver_opts: if configured_backends[backend] not in opt_list: continue LOG.debug("Registering options for group %s", backend) conf.register_opts(driver_opts[opt_list], group=backend)
Example #23
Source File: metricd.py From gnocchi with Apache License 2.0 | 5 votes |
def metricd(): conf = cfg.ConfigOpts() conf.register_cli_opts([ cfg.IntOpt("stop-after-processing-metrics", default=0, min=0, help="Number of metrics to process without workers, " "for testing purpose"), ]) conf = service.prepare_service(conf=conf) if conf.stop_after_processing_metrics: metricd_tester(conf) else: MetricdServiceManager(conf).run()
Example #24
Source File: test_conf.py From manila with Apache License 2.0 | 5 votes |
def test_long_vs_short_flags(self): CONF.clear() CONF.register_cli_opt(cfg.StrOpt('duplicate_answer_long', default='val', help='desc')) CONF.register_cli_opt(cfg.IntOpt('duplicate_answer', default=50, help='desc')) argv = ['--duplicate_answer=60'] CONF(argv, default_config_files=[]) self.assertEqual(60, CONF.duplicate_answer) self.assertEqual('val', CONF.duplicate_answer_long)
Example #25
Source File: test_cache_basics.py From oslo.cache with Apache License 2.0 | 5 votes |
def _add_dummy_config_group(self): self.config_fixture.register_opt( cfg.IntOpt('cache_time'), group=TEST_GROUP) self.config_fixture.register_opt( cfg.IntOpt('cache_time'), group=TEST_GROUP2)
Example #26
Source File: config.py From kolla with Apache License 2.0 | 5 votes |
def get_user_opts(uid, gid): return [ cfg.IntOpt('uid', default=uid, help='The user id'), cfg.IntOpt('gid', default=gid, help='The group id'), ]
Example #27
Source File: config.py From syntribos with Apache License 2.0 | 4 votes |
def list_syntribos_opts(): def wrap_try_except(func): def wrap(*args): try: func(*args) except IOError: msg = _( "\nCan't open a file or directory specified in the " "config file under the section `[syntribos]`; verify " "if the path exists.\nFor more information please refer " "the debug logs.") print(msg) exit(1) return wrap return [ cfg.StrOpt("endpoint", default="", sample_default="http://localhost/app", help=_("The target host to be tested")), cfg.IntOpt("threads", default=16, sample_default="16", help=_("Maximum number of threads syntribos spawns " "(experimental)")), cfg.Opt("templates", type=ContentType("r"), default="", sample_default="~/.syntribos/templates", help=_("A directory of template files, or a single " "template file, to test on the target API")), cfg.StrOpt("payloads", default="", sample_default="~/.syntribos/data", help=_( "The location where we can find syntribos'" "payloads")), cfg.MultiStrOpt("exclude_results", default=[""], sample_default=["500_errors", "length_diff"], help=_( "Defect types to exclude from the " "results output")), cfg.Opt("custom_root", type=wrap_try_except(ExistingDirType()), short="c", sample_default="/your/custom/root", help=_( "The root directory where the subfolders that make up" " syntribos' environment (logs, templates, payloads, " "configuration files, etc.)"), deprecated_for_removal=True), cfg.StrOpt("meta_vars", sample_default="/path/to/meta.json", help=_( "The path to a meta variable definitions file, which " "will be used when parsing your templates")), ]
Example #28
Source File: config.py From st2 with Apache License 2.0 | 4 votes |
def _register_garbage_collector_opts(): logging_opts = [ cfg.StrOpt( 'logging', default='/etc/st2/logging.garbagecollector.conf', help='Location of the logging configuration file.') ] CONF.register_opts(logging_opts, group='garbagecollector') common_opts = [ cfg.IntOpt( 'collection_interval', default=DEFAULT_COLLECTION_INTERVAL, help='How often to check database for old data and perform garbage collection.'), cfg.FloatOpt( 'sleep_delay', default=DEFAULT_SLEEP_DELAY, help='How long to wait / sleep (in seconds) between ' 'collection of different object types.') ] CONF.register_opts(common_opts, group='garbagecollector') ttl_opts = [ cfg.IntOpt( 'action_executions_ttl', default=None, help='Action executions and related objects (live actions, action output ' 'objects) older than this value (days) will be automatically deleted.'), cfg.IntOpt( 'action_executions_output_ttl', default=7, help='Action execution output objects (ones generated by action output ' 'streaming) older than this value (days) will be automatically deleted.'), cfg.IntOpt( 'trigger_instances_ttl', default=None, help='Trigger instances older than this value (days) will be automatically deleted.') ] CONF.register_opts(ttl_opts, group='garbagecollector') inquiry_opts = [ cfg.BoolOpt( 'purge_inquiries', default=False, help='Set to True to perform garbage collection on Inquiries (based on ' 'the TTL value per Inquiry)') ] CONF.register_opts(inquiry_opts, group='garbagecollector')
Example #29
Source File: st2-inject-trigger-instances.py From st2 with Apache License 2.0 | 4 votes |
def main(): monkey_patch() cli_opts = [ cfg.IntOpt('rate', default=100, help='Rate of trigger injection measured in instances in per sec.' + ' Assumes a default exponential distribution in time so arrival is poisson.'), cfg.ListOpt('triggers', required=False, help='List of triggers for which instances should be fired.' + ' Uniform distribution will be followed if there is more than one' + 'trigger.'), cfg.StrOpt('schema_file', default=None, help='Path to schema file defining trigger and payload.'), cfg.IntOpt('duration', default=60, help='Duration of stress test in seconds.'), cfg.BoolOpt('max-throughput', default=False, help='If True, "rate" argument will be ignored and this script will try to ' 'saturize the CPU and achieve max utilization.') ] do_register_cli_opts(cli_opts) config.parse_args() # Get config values triggers = cfg.CONF.triggers trigger_payload_schema = {} if not triggers: if (cfg.CONF.schema_file is None or cfg.CONF.schema_file == '' or not os.path.exists(cfg.CONF.schema_file)): print('Either "triggers" need to be provided or a schema file containing' + ' triggers should be provided.') return with open(cfg.CONF.schema_file) as fd: trigger_payload_schema = yaml.safe_load(fd) triggers = list(trigger_payload_schema.keys()) print('Triggers=%s' % triggers) rate = cfg.CONF.rate rate_per_trigger = int(rate / len(triggers)) duration = cfg.CONF.duration max_throughput = cfg.CONF.max_throughput if max_throughput: rate = 0 rate_per_trigger = 0 dispatcher_pool = eventlet.GreenPool(len(triggers)) for trigger in triggers: payload = trigger_payload_schema.get(trigger, {}) dispatcher_pool.spawn(_inject_instances, trigger, rate_per_trigger, duration, payload=payload, max_throughput=max_throughput) eventlet.sleep(random.uniform(0, 1)) dispatcher_pool.waitall()
Example #30
Source File: config.py From python-barbicanclient with Apache License 2.0 | 4 votes |
def setup_config(config_file=''): global TEST_CONF TEST_CONF = cfg.ConfigOpts() identity_group = cfg.OptGroup(name='identity') identity_options = [ cfg.StrOpt('uri', default='http://localhost/identity'), cfg.StrOpt('auth_version', default='v3'), cfg.StrOpt('username', default='admin'), cfg.StrOpt('password', default='secretadmin'), cfg.StrOpt('tenant_name', default='admin'), cfg.StrOpt('domain_name', default='Default'), cfg.StrOpt('admin_username', default='admin'), cfg.StrOpt('admin_password', default='secretadmin'), cfg.StrOpt('admin_tenant_name', default='admin'), cfg.StrOpt('admin_domain_name', default='Default') ] TEST_CONF.register_group(identity_group) TEST_CONF.register_opts(identity_options, group=identity_group) keymanager_group = cfg.OptGroup(name='keymanager') keymanager_options = [ cfg.StrOpt('url', default='http://localhost/key-manager'), cfg.StrOpt('username', default='admin'), cfg.StrOpt('password', default='secretadmin'), cfg.StrOpt('project_name', default='admin'), cfg.StrOpt('project_id', default='admin'), cfg.StrOpt('project_domain_name', default='Default'), cfg.IntOpt('max_payload_size', default=10000) ] TEST_CONF.register_group(keymanager_group) TEST_CONF.register_opts(keymanager_options, group=keymanager_group) # Figure out which config to load config_to_load = [] local_config = './etc/functional_tests.conf' devstack_config = '../etc/functional_tests.conf' if os.path.isfile(config_file): config_to_load.append(config_file) elif os.path.isfile(local_config): config_to_load.append(local_config) elif os.path.isfile(devstack_config): config_to_load.append(devstack_config) else: config_to_load.append('/etc/functional_tests.conf') # Actually parse config TEST_CONF( (), # Required to load an anonymous config default_config_files=config_to_load )