什么是oslo.config
oslo.config是openstack解析命令行(CLI)或者配置文件(.conf)中配置信息的库.官网地址点击打开链接
安装: $ sudo pip install oslo.config
cfg模块
每一个配置项都是一个Opt类或其子类例如:
from oslo_config import cfg
from oslo_config import types
PortType = types.Integer(1, 65535)
common_opts = [
cfg.StrOpt('bind_host',
default='0.0.0.0',
help='IP address to listen on.'),
cfg.Opt('bind_port',
type=PortType,
default=9292,
help='Port number to listen on.')
]
选项类型
选项可以有任意的类型,为了方便,在oslo.config.cfg中预先定义了选项类型的子类如下表