Option Definitions

class oslo.config.cfg.Opt(name, dest=None, short=None, default=None, positional=False, metavar=None, help=None, secret=False, required=False, deprecated_name=None, deprecated_group=None, deprecated_opts=None)

Base class for all configuration options.

An Opt object has no public methods, but has a number of public string properties:

name:
the name of the option, which may include hyphens
dest:
the (hyphen-less) ConfigOpts property which contains the option value
short:
a single character CLI option name
default:
the default value of the option
positional:
True if the option is a positional CLI argument
metavar:
the name shown as the argument to a CLI option in –help output
help:
an string explaining how the options value is used
class oslo.config.cfg.StrOpt(name, choices=None, **kwargs)

String options.

String opts do not have their values transformed and are returned as str objects.

In addition to the parameters in the base class Opt, StrOpt has an additional parameter.

Parameters:choices – Optional sequence of valid values.
class oslo.config.cfg.BoolOpt(*args, **kwargs)

Boolean options.

Bool opts are set to True or False on the command line using –optname or –noopttname respectively.

In config files, boolean values are case insensitive and can be set using 1/0, yes/no, true/false or on/off.

class oslo.config.cfg.IntOpt(name, dest=None, short=None, default=None, positional=False, metavar=None, help=None, secret=False, required=False, deprecated_name=None, deprecated_group=None, deprecated_opts=None)

Int opt values are converted to integers using the int() builtin.

class oslo.config.cfg.FloatOpt(name, dest=None, short=None, default=None, positional=False, metavar=None, help=None, secret=False, required=False, deprecated_name=None, deprecated_group=None, deprecated_opts=None)

Float opt values are converted to floats using the float() builtin.

class oslo.config.cfg.ListOpt(name, dest=None, short=None, default=None, positional=False, metavar=None, help=None, secret=False, required=False, deprecated_name=None, deprecated_group=None, deprecated_opts=None)

List Options.

List opt values are simple string values separated by commas. The opt value is a list containing these strings.

class oslo.config.cfg.DictOpt(name, dest=None, short=None, default=None, positional=False, metavar=None, help=None, secret=False, required=False, deprecated_name=None, deprecated_group=None, deprecated_opts=None)

Dictionary options.

Dictionary opt values are key:value pairs separated by commas. The opt value is a dictionary of these key/value pairs

class oslo.config.cfg.MultiStrOpt(name, dest=None, short=None, default=None, positional=False, metavar=None, help=None, secret=False, required=False, deprecated_name=None, deprecated_group=None, deprecated_opts=None)

Multi-string option.

Multistr opt values are string opts which may be specified multiple times. The opt value is a list containing all the string values specified.

class oslo.config.cfg.DeprecatedOpt(name, group=None)

Represents a Deprecated option. Here’s how you can use it

oldopts = [cfg.DeprecatedOpt(‘oldfoo’, group=’oldgroup’),
cfg.DeprecatedOpt(‘oldfoo2’, group=’oldgroup2’)]

cfg.CONF.register_group(cfg.OptGroup(‘blaa’)) cfg.CONF.register_opt(cfg.StrOpt(‘foo’, deprecated_opts=oldopts),

group=’blaa’)

Multi-value options will return all new and deprecated options. For single options, if the new option is present (“[blaa]/foo” above) it will override any deprecated options present. If the new option is not present and multiple deprecated options are present, the option corresponding to the first element of deprecated_opts will be chosen.

class oslo.config.cfg.SubCommandOpt(name, dest=None, handler=None, title=None, description=None, help=None)

Sub-command options.

Sub-command options allow argparse sub-parsers to be used to parse additional command line arguments.

The handler argument to the SubCommandOpt contructor is a callable which is supplied an argparse subparsers object. Use this handler callable to add sub-parsers.

The opt value is SubCommandAttr object with the name of the chosen sub-parser stored in the ‘name’ attribute and the values of other sub-parser arguments available as additional attributes.

class oslo.config.cfg.OptGroup(name, title=None, help=None)

Represents a group of opts.

CLI opts in the group are automatically prefixed with the group name.

Each group corresponds to a section in config files.

An OptGroup object has no public methods, but has a number of public string properties:

name:
the name of the group
title:
the group title as displayed in –help
help:
the group description as displayed in –help

Previous topic

The cfg Module

Next topic

The ConfigOpts Class

This Page