Python oslo_config.cfg.OptGroup() Examples

The following are 30 code examples of oslo_config.cfg.OptGroup(). 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_ovsdb_lib.py    From os-vif with Apache License 2.0 6 votes vote down vote up
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 #2
Source File: plugin.py    From os-vif with Apache License 2.0 6 votes vote down vote up
def load(cls, plugin_name):
        """
        Load a plugin, registering its configuration options

        :param plugin_name: the name of the plugin extension

        :returns: an initialized instance of the class
        """
        cfg_group_name = "os_vif_" + plugin_name
        cfg_opts = getattr(cls, "CONFIG_OPTS")
        cfg_vals = None
        if cfg_opts and len(cfg_opts) > 0:
            cfg_group = cfg.OptGroup(
                cfg_group_name,
                "os-vif plugin %s options" % plugin_name)
            CONF.register_opts(cfg_opts, group=cfg_group)

            cfg_vals = getattr(CONF, cfg_group_name)
        return cls(cfg_vals) 
Example #3
Source File: test_list_opts.py    From watcher with Apache License 2.0 6 votes vote down vote up
def _assert_name_or_group(self, actual_sections, expected_sections):
        for name_or_group, options in actual_sections:
            section_name = name_or_group
            if isinstance(name_or_group, cfg.OptGroup):
                section_name = name_or_group.name
            elif section_name in self.none_objects:
                pass
            else:
                # All option groups should be added to list_otps with an
                # OptGroup object for some exceptions this is not possible but
                # new groups should use OptGroup
                raise Exception(
                    "Invalid option group: {0} should be of type OptGroup not "
                    "string.".format(section_name))

        self.assertIn(section_name, expected_sections)
        self.assertTrue(len(options)) 
Example #4
Source File: test_list_opts.py    From watcher with Apache License 2.0 6 votes vote down vote up
def setUp(self):
        super(TestListOpts, self).setUp()
        # These option groups will be registered using strings instead of
        # OptGroup objects this should be avoided if possible.
        self.none_objects = ['DEFAULT', 'watcher_clients_auth',
                             'watcher_strategies.strategy_1']

        self.base_sections = [
            'DEFAULT', 'api', 'database', 'watcher_decision_engine',
            'watcher_applier', 'watcher_datasources', 'watcher_planner',
            'nova_client', 'glance_client', 'gnocchi_client', 'grafana_client',
            'grafana_translators', 'cinder_client', 'ceilometer_client',
            'monasca_client', 'ironic_client', 'keystone_client',
            'neutron_client', 'watcher_clients_auth', 'collector',
            'placement_client']
        self.opt_sections = list(dict(opts.list_opts()).keys()) 
Example #5
Source File: config.py    From freezer-api with Apache License 2.0 6 votes vote down vote up
def parse_args(args=[]):
    CONF.register_cli_opts(api_common_opts())
    register_db_drivers_opt()
    # register paste configuration
    paste_grp = cfg.OptGroup('paste_deploy',
                             'Paste Configuration')
    CONF.register_group(paste_grp)
    CONF.register_opts(paste_deploy, group=paste_grp)
    log.register_options(CONF)
    policy.Enforcer(CONF)
    default_config_files = cfg.find_config_files('freezer', 'freezer-api')
    CONF(args=args,
         project='freezer-api',
         default_config_files=default_config_files,
         version=FREEZER_API_VERSION
         ) 
Example #6
Source File: nested_vif.py    From kuryr-kubernetes with Apache License 2.0 6 votes vote down vote up
def _get_parent_port_by_host_ip(self, node_fixed_ip):
        os_net = clients.get_network_client()
        node_subnet_id = oslo_cfg.CONF.pod_vif_nested.worker_nodes_subnet
        if not node_subnet_id:
            raise oslo_cfg.RequiredOptError(
                'worker_nodes_subnet', oslo_cfg.OptGroup('pod_vif_nested'))

        try:
            fixed_ips = ['subnet_id=%s' % str(node_subnet_id),
                         'ip_address=%s' % str(node_fixed_ip)]
            ports = os_net.ports(fixed_ips=fixed_ips)
        except os_exc.SDKException:
            LOG.error("Parent vm port with fixed ips %s not found!",
                      fixed_ips)
            raise

        try:
            return next(ports)
        except StopIteration:
            LOG.error("Neutron port for vm port with fixed ips %s not found!",
                      fixed_ips)
            raise kl_exc.NoResourceException 
Example #7
Source File: auth.py    From syntribos with Apache License 2.0 6 votes vote down vote up
def get_test_cases(cls, filename, file_content, meta_vars):
        """Generates the test cases

        For this particular test, only a single test
        is created (in addition to the base case, that is)
        """
        alt_user_group = cfg.OptGroup(name="alt_user",
                                      title="Alt Keystone User Config")
        CONF.register_group(alt_user_group)
        CONF.register_opts(syntribos.config.list_user_opts(),
                           group=alt_user_group)

        alt_user_id = CONF.alt_user.user_id
        alt_user_username = CONF.alt_user.username
        if not alt_user_id or not alt_user_username:
            return

        yield cls 
Example #8
Source File: options.py    From promenade with Apache License 2.0 6 votes vote down vote up
def setup(disable_keystone=False):
    cfg.CONF([], project='promenade')
    cfg.CONF.register_opts(OPTIONS)
    log_group = cfg.OptGroup(name='logging', title='Logging options')
    cfg.CONF.register_group(log_group)
    logging_options = [
        cfg.StrOpt(
            'log_level',
            choices=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
            default='DEBUG',
            help='Global log level for PROMENADE')
    ]
    cfg.CONF.register_opts(logging_options, group=log_group)
    if disable_keystone is False:
        cfg.CONF.register_opts(
            keystoneauth1.loading.get_auth_plugin_conf_options('password'),
            group='keystone_authtoken') 
Example #9
Source File: config.py    From shipyard with Apache License 2.0 5 votes vote down vote up
def register_opts(conf):
    """ Registers all the sections in this module.
    """
    for section in SECTIONS:
        conf.register_group(
            cfg.OptGroup(name=section.name,
                         title=section.title,
                         help=section.help))
        conf.register_opts(section.options, group=section.name)

    ks_loading.register_auth_conf_options(conf, group='keystone_authtoken') 
Example #10
Source File: cloudstack.py    From cloudbase-init with Apache License 2.0 5 votes vote down vote up
def register(self):
        """Register the current options to the global ConfigOpts object."""
        group = cfg.OptGroup(self.group_name, title='CloudStack Options')
        self._config.register_group(group)
        self._config.register_opts(self._options, group=group) 
Example #11
Source File: test_keystone.py    From ironic-inspector with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(KeystoneTest, self).setUp()
        self.cfg.conf.register_group(cfg.OptGroup(TESTGROUP)) 
Example #12
Source File: test_config.py    From python-tripleoclient with Apache License 2.0 5 votes vote down vote up
def setUp(self):
        super(TestBaseNetworkSettings, self).setUp()
        self.conf = self.useFixture(oslo_fixture.Config(cfg.CONF))
        # don't actually load config from ~/undercloud.conf
        self.mock_config_load = self.useFixture(
            fixtures.MockPatch('tripleoclient.utils.load_config'))
        self.conf.config(local_ip='192.168.24.1/24',
                         undercloud_admin_host='192.168.24.3',
                         undercloud_public_host='192.168.24.2',
                         undercloud_nameservers=['10.10.10.10', '10.10.10.11'])
        # ctlplane network - config group options
        self.grp0 = cfg.OptGroup(name='ctlplane-subnet',
                                 title='ctlplane-subnet')
        self.opts = [cfg.StrOpt('cidr'),
                     cfg.ListOpt('dhcp_start'),
                     cfg.ListOpt('dhcp_end'),
                     cfg.ListOpt('dhcp_exclude'),
                     cfg.StrOpt('inspection_iprange'),
                     cfg.StrOpt('gateway'),
                     cfg.BoolOpt('masquerade'),
                     cfg.ListOpt('host_routes',
                                 item_type=cfg.types.Dict(bounds=True),
                                 bounds=True,),
                     cfg.ListOpt('dns_nameservers')]
        self.conf.register_opts(self.opts, group=self.grp0)
        self.grp1 = cfg.OptGroup(name='subnet1', title='subnet1')
        self.grp2 = cfg.OptGroup(name='subnet2', title='subnet2')
        self.conf.config(cidr='192.168.24.0/24',
                         dhcp_start='192.168.24.5',
                         dhcp_end='192.168.24.24',
                         dhcp_exclude=[],
                         inspection_iprange='192.168.24.100,192.168.24.120',
                         gateway='192.168.24.1',
                         masquerade=False,
                         host_routes=[],
                         dns_nameservers=[],
                         group='ctlplane-subnet') 
Example #13
Source File: undercloud_config.py    From python-tripleoclient with Apache License 2.0 5 votes vote down vote up
def _load_subnets_config_groups():
    for group in CONF.subnets:
        g = cfg.OptGroup(name=group, title=group)
        if group == CONF.local_subnet:
            CONF.register_opts(config.get_local_subnet_opts(), group=g)
        else:
            CONF.register_opts(config.get_remote_subnet_opts(), group=g) 
Example #14
Source File: base.py    From openstacksdk with Apache License 2.0 5 votes vote down vote up
def _load_ks_cfg_opts(self):
        conf = cfg.ConfigOpts()
        for group, opts in self.oslo_config_dict.items():
            conf.register_group(cfg.OptGroup(group))
            if opts is not None:
                ks_loading.register_adapter_conf_options(conf, group)
                for name, val in opts.items():
                    conf.set_override(name, val, group=group)
        return conf

    # TODO(shade) Update this to handle service type aliases 
Example #15
Source File: plugin.py    From searchlight with Apache License 2.0 5 votes vote down vote up
def get_cfg_opts(cls):
        group = cfg.OptGroup(cls.get_config_group_name())
        opts = cls.get_plugin_opts()
        return [(group, opts)] 
Example #16
Source File: exporter.py    From galaxia with Apache License 2.0 5 votes vote down vote up
def main():
    service.prepare_service("gexporter", sys.argv)

    CONF = cfg.CONF
    opt_group = cfg.OptGroup(name='gexporter', title='Options for the\
                                                     exporter service')
    CONF.register_group(opt_group)
    CONF.register_opts(API_SERVICE_OPTS, opt_group)
    CONF.set_override('topic', CONF.gexporter.topic, opt_group)
    CONF.set_override('rabbitmq_host', CONF.gexporter.rabbitmq_host, opt_group)
    CONF.set_override('rabbitmq_port', CONF.gexporter.rabbitmq_port, opt_group)
    CONF.set_override('rabbitmq_username', CONF.gexporter.rabbitmq_username,
                      opt_group)

    endpoints = [
        controller.Controller(),
    ]

    log.info('Starting exporter service in PID %s' % os.getpid())

    rpc_server = broker.Broker(CONF.gexporter.topic,
                               CONF.gexporter.rabbitmq_host,
                               endpoints)
    print 'Galaxia Exporter service started in PID %s' % os.getpid()

    rpc_server.serve() 
Example #17
Source File: service.py    From galaxia with Apache License 2.0 5 votes vote down vote up
def prepare_service(service_name, argv=[]):
    """
    Initializes the various galaxia services
    :param service_name: Name of the service
    :param argv: Configuration file
    :return:
    """

    cfg.CONF(argv[1:], project='galaxia')

    opt_group = cfg.OptGroup(name=service_name, title='Logging options for\
                                                      the service')
    cfg.CONF.register_group(opt_group)
    cfg.CONF.register_opts(LOGGING_SERVICE_OPTS, opt_group)

    log_file = cfg.CONF._get("log_file", group=opt_group)
    log_level = cfg.CONF._get("log_level", group=opt_group)

    log_helper.setup_logging(log_file, log_level)

    db_group = cfg.OptGroup(name='db', title='Options for the database')
    cfg.CONF.register_group(db_group)
    cfg.CONF.register_opts(DB_SERVICE_OPTS, db_group)
    cfg.CONF.set_override('db_host', cfg.CONF.db.db_host, db_group)
    cfg.CONF.set_override('type', cfg.CONF.db.type, db_group)
    cfg.CONF.set_override('db_location', cfg.CONF.db.db_location, db_group)

    sql_helper.init_db(cfg.CONF.db.type, cfg.CONF.db.username,
                       cfg.CONF.db.password, cfg.CONF.db.db_host, "galaxia", cfg.CONF.db.db_location)
    load_mapping.initialize() 
Example #18
Source File: renderer.py    From galaxia with Apache License 2.0 5 votes vote down vote up
def main():
    service.prepare_service("grenderer", sys.argv)

    CONF = cfg.CONF
    opt_group = cfg.OptGroup(name='grenderer', title='Options for the\
                                                     renderer service')
    CONF.register_group(opt_group)
    CONF.register_opts(API_SERVICE_OPTS, opt_group)
    CONF.set_override('topic', CONF.grenderer.topic, opt_group)
    CONF.set_override('rabbitmq_host', CONF.grenderer.rabbitmq_host, opt_group)
    CONF.set_override('rabbitmq_port', CONF.grenderer.rabbitmq_port, opt_group)
    CONF.set_override('rabbitmq_username', CONF.grenderer.rabbitmq_username,
                      opt_group)
    CONF.set_override('handler', CONF.grenderer.handler, opt_group)

    handlers = {
        'prometheus': controller.Controller,
    }

    endpoints = [
        handlers[CONF.grenderer.handler](),
    ]

    log.info('Starting renderer service in PID %s' % os.getpid())

    rpc_server = broker.Broker(CONF.grenderer.topic,
                               CONF.grenderer.rabbitmq_host,
                               endpoints)
    print 'Galaxia Renderer service started in PID %s' % os.getpid()

    rpc_server.serve() 
Example #19
Source File: maas.py    From cloudbase-init with Apache License 2.0 5 votes vote down vote up
def register(self):
        """Register the current options to the global ConfigOpts object."""
        group = cfg.OptGroup(self.group_name, title='MAAS Options')
        self._config.register_group(group)
        self._config.register_opts(self._options, group=group) 
Example #20
Source File: user_defined.py    From syntribos with Apache License 2.0 5 votes vote down vote up
def user_defined_config():
    """Create config options for user defined test."""
    user_defined_group = cfg.OptGroup(
        name="user_defined", title="Data for user defined test")
    CONF.register_group(user_defined_group)
    options = [
        cfg.StrOpt(
            "payload", help="Path to a payload data file."), cfg.StrOpt(
                "failure_keys", help="Possible failure keys")
    ]
    CONF.register_opts(options, group=user_defined_group) 
Example #21
Source File: api.py    From galaxia with Apache License 2.0 5 votes vote down vote up
def create_metrics_exporter(self, **kwargs):
        """
        Handler to create metrics exporter
        :param kwargs:
        :return:
        """
        """
        CONF = cfg.CONF
        opt_group = cfg.OptGroup(name='gapi',
                                 title='Options for the api service')
        CONF.register_group(opt_group)
        CONF.register_opts(API_SERVICE_OPTS, opt_group)
        CONF.set_override('topic_exporter', CONF.gapi.topic_exporter,
                          opt_group)
        CONF.set_override('rabbitmq_host', CONF.gapi.rabbitmq_host,
                          opt_group)
        """
        exporter_id = str(uuid.uuid4())
        kwargs['exporter_id'] = exporter_id

        sql_query = query_list.INSERT_INTO_EXPORTER
        params = kwargs['exporter_name'], exporter_id
        try:
            conn = sql_helper.engine.connect()
            conn.execute(sql_query, params)
        except SQLAlchemyError as ex:
            return "A database exception has been hit and metrics exporter has\
                   failed"

        log.info("Initializing a client connection")
        try:
            mq_client = client.Client(CONF.gapi.topic_exporter,
                                  CONF.gapi.rabbitmq_host)
            ctxt = {}
            log.info("Publishing message to rabbitmq")
            mq_client.rpc_client.cast(ctxt, 'export_metrics', message=kwargs)
        except Exception as ex:
            return "A messaging exception has been hit and metrics export\
                   request has failed"

        return "Metrics export request has been successfully accepted" 
Example #22
Source File: client.py    From networking-odl with Apache License 2.0 5 votes vote down vote up
def _check_opt(url):
        if not url:
            raise cfg.RequiredOptError('url', cfg.OptGroup('ml2_odl'))
        required_opts = ('url', 'username', 'password')
        for opt in required_opts:
            if not getattr(cfg.CONF.ml2_odl, opt):
                raise cfg.RequiredOptError(opt, cfg.OptGroup('ml2_odl')) 
Example #23
Source File: gce.py    From cloudbase-init with Apache License 2.0 5 votes vote down vote up
def register(self):
        """Register the current options to the global ConfigOpts object."""
        group = cfg.OptGroup(self.group_name, title='GCE Options')
        self._config.register_group(group)
        self._config.register_opts(self._options, group=group) 
Example #24
Source File: plugin.py    From searchlight with Apache License 2.0 5 votes vote down vote up
def register_cfg_opts(cls, namespace):
        mgr = extension.ExtensionManager(namespace)

        for e in mgr:
            for group, opts in e.plugin.get_cfg_opts():
                if isinstance(group, str):
                    group = cfg.OptGroup(name=group)

                CONF.register_group(group)
                CONF.register_opts(opts, group=group) 
Example #25
Source File: ovf.py    From cloudbase-init with Apache License 2.0 5 votes vote down vote up
def register(self):
        """Register the current options to the global ConfigOpts object."""
        group = cfg.OptGroup(self.group_name, title='Ovf Options')
        self._config.register_group(group)
        self._config.register_opts(self._options, group=group) 
Example #26
Source File: azure.py    From cloudbase-init with Apache License 2.0 5 votes vote down vote up
def register(self):
        """Register the current options to the global ConfigOpts object."""
        group = cfg.OptGroup(self.group_name, title='Azure Options')
        self._config.register_group(group)
        self._config.register_opts(self._options, group=group) 
Example #27
Source File: vmwareguestinfo.py    From cloudbase-init with Apache License 2.0 5 votes vote down vote up
def register(self):
        """Register the current options to the global ConfigOpts object."""
        group = cfg.OptGroup(self.group_name,
                             title='VMware GuestInfo Options')
        self._config.register_group(group)
        self._config.register_opts(self._options, group=group) 
Example #28
Source File: openstack.py    From cloudbase-init with Apache License 2.0 5 votes vote down vote up
def register(self):
        """Register the current options to the global ConfigOpts object."""
        group = cfg.OptGroup(self.group_name, title='OpenStack Options')
        self._config.register_group(group)
        self._config.register_opts(self._options, group=group) 
Example #29
Source File: cloudconfig.py    From cloudbase-init with Apache License 2.0 5 votes vote down vote up
def register(self):
        """Register the current options to the global ConfigOpts object."""
        group = cfg.OptGroup(self._group_name, title='Cloud Config Options')
        self._config.register_group(group)
        self._config.register_opts(self._options, group=group) 
Example #30
Source File: ec2.py    From cloudbase-init with Apache License 2.0 5 votes vote down vote up
def register(self):
        """Register the current options to the global ConfigOpts object."""
        group = cfg.OptGroup(self.group_name, title='EC2 Options')
        self._config.register_group(group)
        self._config.register_opts(self._options, group=group)