Python oslo_config.cfg.BoolOpt() Examples

The following are 30 code examples of oslo_config.cfg.BoolOpt(). 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: injector.py    From gnocchi with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: test_db_manage.py    From watcher with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: test_db_manage.py    From watcher with Apache License 2.0 6 votes vote down vote up
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 #4
Source File: test_db_manage.py    From watcher with Apache License 2.0 6 votes vote down vote up
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 #5
Source File: config.py    From st2 with Apache License 2.0 6 votes vote down vote up
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: base.py    From python-tripleoclient with Apache License 2.0 6 votes vote down vote up
def get_base_opts(self):
        _opts = [
            # TODO(aschultz): rename undercloud_output_dir
            cfg.StrOpt('output_dir',
                       default=constants.UNDERCLOUD_OUTPUT_DIR,
                       help=(
                           'Directory to output state, processed heat '
                           'templates, ansible deployment files.'),
                       ),
            cfg.BoolOpt('cleanup',
                        default=True,
                        help=('Cleanup temporary files. Setting this to '
                              'False will leave the temporary files used '
                              'during deployment in place after the command '
                              'is run. This is useful for debugging the '
                              'generated files or if errors occur.'),
                        ),
        ]
        return self.sort_opts(_opts) 
Example #7
Source File: config.py    From st2 with Apache License 2.0 6 votes vote down vote up
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 #8
Source File: config.py    From st2 with Apache License 2.0 6 votes vote down vote up
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 #9
Source File: config.py    From syntribos with Apache License 2.0 6 votes vote down vote up
def list_remote_opts():
    """Method defining remote URIs for payloads and templates."""
    return [
        cfg.StrOpt(
            "cache_dir",
            default="",
            help=_("Base directory where cached files can be saved")),
        cfg.StrOpt(
            "payloads_uri",
            default=("https://github.com/openstack/syntribos-payloads/"
                     "archive/master.tar.gz"),
            help=_("Remote URI to download payloads.")),
        cfg.StrOpt(
            "templates_uri",
            default=("https://github.com/openstack/"
                     "syntribos-openstack-templates/archive/master.tar.gz"),
            help=_("Remote URI to download templates.")),
        cfg.BoolOpt("enable_cache", default=True,
                    help=_(
                        "Cache remote template & payload resources locally")),
    ] 
Example #10
Source File: base.py    From searchlight with Apache License 2.0 6 votes vote down vote up
def get_plugin_opts(cls):
        """Options that can be overridden per plugin.
        """
        opts = [
            cfg.StrOpt("resource_group_name"),
            cfg.BoolOpt("enabled", default=cls.is_plugin_enabled_by_default()),
            cfg.StrOpt("admin_only_fields"),
            cfg.BoolOpt('mapping_use_doc_values'),
            cfg.ListOpt('override_region_name',
                        help="Override the region name configured in "
                             "'service_credentials'. This is useful when a "
                             "service is deployed as a cloud-wide service "
                             "rather than per region (e.g. Region1,Region2)."),
            cfg.ListOpt('publishers',
                        help='Used to configure publishers for the plugin, '
                             'value could be publisher names configured in '
                             'setup.cfg file.'
                        )
        ]
        if cls.NotificationHandlerCls:
            opts.extend(cls.NotificationHandlerCls.get_plugin_opts())
        return opts 
Example #11
Source File: gce.py    From cloudbase-init with Apache License 2.0 6 votes vote down vote up
def __init__(self, config):
        super(GCEOptions, self).__init__(config, group="gce")
        self._options = [
            cfg.StrOpt(
                "metadata_base_url",
                default="http://metadata.google.internal/computeMetadata/v1/",
                help="The base URL where the service looks for metadata"),
            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."),
        ] 
Example #12
Source File: openstack.py    From cloudbase-init with Apache License 2.0 6 votes vote down vote up
def __init__(self, config):
        super(OpenStackOptions, self).__init__(config, group="openstack")
        self._options = [
            cfg.StrOpt(
                "metadata_base_url", default="http://169.254.169.254/",
                help="The base URL where the service looks for metadata",
                deprecated_group="DEFAULT"),
            cfg.BoolOpt(
                "add_metadata_private_ip_route", default=True,
                help="Add a route for the metadata ip address to the gateway",
                deprecated_group="DEFAULT"),
            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."),
        ] 
Example #13
Source File: ec2.py    From cloudbase-init with Apache License 2.0 6 votes vote down vote up
def __init__(self, config):
        super(EC2Options, self).__init__(config, group="ec2")
        self._options = [
            cfg.StrOpt(
                "metadata_base_url", default="http://169.254.169.254/",
                help="The base URL where the service looks for metadata",
                deprecated_name="ec2_metadata_base_url",
                deprecated_group="DEFAULT"),
            cfg.BoolOpt(
                "add_metadata_private_ip_route", default=True,
                help="Add a route for the metadata ip address to the gateway",
                deprecated_name="ec2_add_metadata_private_ip_route",
                deprecated_group="DEFAULT"),
            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."),
        ] 
Example #14
Source File: trigger_re_fire.py    From st2 with Apache License 2.0 6 votes vote down vote up
def _parse_config():
    cli_opts = [
        cfg.BoolOpt('verbose',
                    short='v',
                    default=False,
                    help='Print more verbose output'),
        cfg.StrOpt('trigger-instance-id',
                   short='t',
                   required=True,
                   dest='trigger_instance_id',
                   help='Id of trigger instance'),
    ]
    CONF.register_cli_opts(cli_opts)
    st2cfg.register_opts(ignore_errors=False)

    CONF(args=sys.argv[1:]) 
Example #15
Source File: setup_pack_virtualenv.py    From st2 with Apache License 2.0 5 votes vote down vote up
def _register_cli_opts():
    cli_opts = [
        cfg.MultiStrOpt('pack', default=None, required=True, positional=True,
                        help='Name of the pack to setup the virtual environment for.'),
        cfg.BoolOpt('update', default=False,
                   help=('Check this option if the virtual environment already exists and if you '
                         'only want to perform an update and installation of new dependencies. If '
                         'you don\'t check this option, the virtual environment will be destroyed '
                         'then re-created. If you check this and the virtual environment doesn\'t '
                         'exist, it will create it..')),
        cfg.BoolOpt('python3', default=False,
                    help='Use Python 3 binary when creating a virtualenv for this pack.'),
    ]
    do_register_cli_opts(cli_opts) 
Example #16
Source File: purge_executions.py    From st2 with Apache License 2.0 5 votes vote down vote up
def _register_cli_opts():
    cli_opts = [
        cfg.StrOpt('timestamp', default=None,
                   help='Will delete execution and liveaction models older than ' +
                   'this UTC timestamp. ' +
                   'Example value: 2015-03-13T19:01:27.255542Z.'),
        cfg.StrOpt('action-ref', default='',
                   help='action-ref to delete executions for.'),
        cfg.BoolOpt('purge-incomplete', default=False,
                    help='Purge all models irrespective of their ``status``.' +
                    'By default, only executions in completed states such as "succeeeded" ' +
                    ', "failed", "canceled" and "timed_out" are deleted.'),
    ]
    do_register_cli_opts(cli_opts) 
Example #17
Source File: bootstrap.py    From st2 with Apache License 2.0 5 votes vote down vote up
def register_opts():
    content_opts = [
        cfg.BoolOpt('all', default=False, help='Register sensors, actions and rules.'),
        cfg.BoolOpt('triggers', default=False, help='Register triggers.'),
        cfg.BoolOpt('sensors', default=False, help='Register sensors.'),
        cfg.BoolOpt('actions', default=False, help='Register actions.'),
        cfg.BoolOpt('runners', default=False, help='Register runners.'),
        cfg.BoolOpt('rules', default=False, help='Register rules.'),
        cfg.BoolOpt('aliases', default=False, help='Register aliases.'),
        cfg.BoolOpt('policies', default=False, help='Register policies.'),
        cfg.BoolOpt('configs', default=False, help='Register and load pack configs.'),

        cfg.StrOpt('pack', default=None, help='Directory to the pack to register content from.'),
        cfg.StrOpt('runner-dir', default=None, help='Directory to load runners from.'),
        cfg.BoolOpt('setup-virtualenvs', default=False, help=('Setup Python virtual environments '
                                                              'all the Python runner actions.')),

        # General options
        # Note: This value should default to False since we want fail on failure behavior by
        # default.
        cfg.BoolOpt('no-fail-on-failure', default=False,
                    help=('Don\'t exit with non-zero if some resource registration fails.')),
        # Note: Fail on failure is now a default behavior. This flag is only left here for backward
        # compatibility reasons, but it's not actually used.
        cfg.BoolOpt('fail-on-failure', default=True,
                    help=('Exit with non-zero if some resource registration fails.'))
    ]
    try:
        cfg.CONF.register_cli_opts(content_opts, group='register')
    except:
        sys.stderr.write('Failed registering opts.\n') 
Example #18
Source File: script_setup.py    From st2 with Apache License 2.0 5 votes vote down vote up
def register_common_cli_options():
    """
    Register common CLI options.
    """
    cfg.CONF.register_cli_opt(cfg.BoolOpt('verbose', short='v', default=False)) 
Example #19
Source File: config.py    From st2 with Apache License 2.0 5 votes vote down vote up
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 #20
Source File: download_pack.py    From st2 with Apache License 2.0 5 votes vote down vote up
def _register_cli_opts():
    cli_opts = [
        cfg.MultiStrOpt('pack', default=None, required=True, positional=True,
                        help='Name of the pack to install (download).'),
        cfg.BoolOpt('verify-ssl', default=True,
                   help=('Verify SSL certificate of the Git repo from which the pack is '
                         'installed.')),
        cfg.BoolOpt('force', default=False,
                    help='True to force pack download and ignore download '
                         'lock file if it exists.'),
        cfg.BoolOpt('use-python3', default=False,
                    help='True to use Python3 binary.')
    ]
    do_register_cli_opts(cli_opts) 
Example #21
Source File: config.py    From st2 with Apache License 2.0 5 votes vote down vote up
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 #22
Source File: config.py    From st2 with Apache License 2.0 5 votes vote down vote up
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 #23
Source File: config.py    From st2 with Apache License 2.0 5 votes vote down vote up
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 #24
Source File: config.py    From st2 with Apache License 2.0 5 votes vote down vote up
def _register_app_opts():
    # Note "host", "port", "allow_origin", "mask_secrets" options are registered as part of
    # st2common config since they are also used outside st2api
    static_root = os.path.join(cfg.CONF.system.base_path, 'static')
    template_path = os.path.join(BASE_DIR, 'templates/')

    pecan_opts = [
        cfg.StrOpt(
            'root', default='st2api.controllers.root.RootController',
            help='Action root controller'),
        cfg.StrOpt('static_root', default=static_root),
        cfg.StrOpt('template_path', default=template_path),
        cfg.ListOpt('modules', default=['st2api']),
        cfg.BoolOpt('debug', default=False),
        cfg.BoolOpt('auth_enable', default=True),
        cfg.DictOpt('errors', default={'__force_dict__': True})
    ]

    CONF.register_opts(pecan_opts, group='api_pecan')

    logging_opts = [
        cfg.BoolOpt('debug', default=False),
        cfg.StrOpt(
            'logging', default='/etc/st2/logging.api.conf',
            help='location of the logging.conf file'),
        cfg.IntOpt(
            'max_page_size', default=100,
            help='Maximum limit (page size) argument which can be '
                 'specified by the user in a query string.')
    ]

    CONF.register_opts(logging_opts, group='api') 
Example #25
Source File: manage.py    From gnocchi with Apache License 2.0 5 votes vote down vote up
def upgrade():
    conf = cfg.ConfigOpts()
    sack_number_opt = copy.copy(_SACK_NUMBER_OPT)
    sack_number_opt.default = 128
    conf.register_cli_opts([
        cfg.BoolOpt("skip-index", default=False,
                    help="Skip index upgrade."),
        cfg.BoolOpt("skip-storage", default=False,
                    help="Skip storage upgrade."),
        cfg.BoolOpt("skip-incoming", default=False,
                    help="Skip incoming storage upgrade."),
        cfg.BoolOpt("skip-archive-policies-creation", default=False,
                    help="Skip default archive policies creation."),
        sack_number_opt,
    ])
    conf = service.prepare_service(conf=conf, log_to_std=True)
    if not conf.skip_index:
        index = indexer.get_driver(conf)
        LOG.info("Upgrading indexer %s", index)
        index.upgrade()
    if not conf.skip_storage:
        s = storage.get_driver(conf)
        LOG.info("Upgrading storage %s", s)
        s.upgrade()
    if not conf.skip_incoming:
        i = incoming.get_driver(conf)
        LOG.info("Upgrading incoming storage %s", i)
        i.upgrade(conf.sacks_number)

    if (not conf.skip_archive_policies_creation
            and not index.list_archive_policies()
            and not index.list_archive_policy_rules()):
        if conf.skip_index:
            index = indexer.get_driver(conf)
        for name, ap in six.iteritems(archive_policy.DEFAULT_ARCHIVE_POLICIES):
            index.create_archive_policy(ap)
        index.create_archive_policy_rule("default", "*", "low") 
Example #26
Source File: shell.py    From oslo.policy with Apache License 2.0 5 votes vote down vote up
def main():
    conf = cfg.ConfigOpts()

    conf.register_cli_opt(cfg.StrOpt(
        'policy',
        required=True,
        help='path to a policy file.'))

    conf.register_cli_opt(cfg.StrOpt(
        'access',
        required=True,
        help='path to a file containing OpenStack Identity API '
             'access info in JSON format.'))

    conf.register_cli_opt(cfg.StrOpt(
        'target',
        help='path to a file containing custom target info in '
             'JSON format. This will be used to evaluate the policy with.'))

    conf.register_cli_opt(cfg.StrOpt(
        'rule',
        help='rule to test.'))

    conf.register_cli_opt(cfg.BoolOpt(
        'is_admin',
        help='set is_admin=True on the credentials used for the evaluation.',
        default=False))

    conf.register_cli_opt(cfg.StrOpt(
        'enforcer_config',
        help='configuration file for the oslopolicy-checker enforcer'))

    conf()

    tool(conf.policy, conf.access, conf.rule, conf.is_admin,
         conf.target, conf.enforcer_config) 
Example #27
Source File: notification_handler.py    From searchlight with Apache License 2.0 5 votes vote down vote up
def get_plugin_opts(cls):
        opts = super(InstanceHandler, cls).get_plugin_opts()
        opts.extend([
            cfg.BoolOpt(
                'use_versioned_notifications',
                help='Expect versioned notifications and ignore unversioned',
                default=True)
        ])
        return opts 
Example #28
Source File: test_healthcheck.py    From octavia with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(TestHealthCheck, self).setUp()

        # We need to define these early as they are late loaded in oslo
        # middleware and our configuration overrides would not apply.
        # Note: These must match exactly the option definitions in
        # oslo.middleware healthcheck! If not you will get duplicate option
        # errors.
        healthcheck_opts = [
            cfg.BoolOpt(
                'detailed', default=False,
                help='Show more detailed information as part of the response. '
                     'Security note: Enabling this option may expose '
                     'sensitive details about the service being monitored. '
                     'Be sure to verify that it will not violate your '
                     'security policies.'),
            cfg.ListOpt(
                'backends', default=[],
                help='Additional backends that can perform health checks and '
                     'report that information back as part of a request.'),
        ]
        cfg.CONF.register_opts(healthcheck_opts, group='healthcheck')

        self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
        self.conf.config(group='healthcheck', backends=['octavia_db_check'])
        self.UNAVAILABLE = (healthcheck_plugins.OctaviaDBHealthcheck.
                            UNAVAILABLE_REASON)

        def reset_pecan():
            pecan.set_config({}, overwrite=True)

        self.addCleanup(reset_pecan) 
Example #29
Source File: config.py    From freezer-api with Apache License 2.0 5 votes vote down vote up
def api_common_opts():

    _COMMON = [
        cfg.IPOpt('bind-host',
                  default='0.0.0.0',
                  dest='bind_host',
                  help='IP address to listen on. Default is 0.0.0.0'),
        cfg.PortOpt('bind-port',
                    default=9090,
                    dest='bind_port',
                    help='Port number to listen on. Default is 9090'
                    ),
        cfg.BoolOpt('enable_v1_api',
                    default=False,
                    help="""Default False, That is the v2 Freezer API
                    will be deployed. When this option is set
                    to ``True``, Freezer-api service will respond
                    to requests on registered endpoints conforming
                    to the v1 OpenStack Freezer api.
                    The v1 OpenStack Freezer API functions
                    as follows:
                        * Multi-tenancy is not supported under this
                         api version.
                        * Everything is user based.
                        * Freezer api v1 supports Oslo.db.
                        * Use elasticsearch db with v1 api version
                    The v2 OpenStack Freezer API functions
                    as follows:
                        * Multi-tenancy is supported under this api version.
                        * Freezer api v2 supports Oslo.db.
                        * Recommended to use oslo.db with api v2
                    Possible values:
                        * True
                        * False
                    """)
    ]

    return _COMMON 
Example #30
Source File: __init__.py    From designate with Apache License 2.0 5 votes vote down vote up
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)]