主要记录在阅读neutron的源码时遇到的各种知识点
目录
oslo_conf 的全局配置
关于oslo_conf模块的使用参考oslo.config Quick Start!
代码如下
service_opts = [
cfg.IntOpt('periodic_interval',
default=40,
help=_('Seconds between running periodic tasks')),
cfg.IntOpt('api_workers',
help=_('Number of separate API worker processes for service. '
'If not specified, the default is equal to the number '
'of CPUs available for best performance.')),
......
]
CONF = cfg.CONF ## <--- 此处没有说明导入的config文件
CONF.register_opts(service_opts)
简单来说,oslo_conf的作用是将配置文件的配置参数读取到内存中,但这里并没有指定应该导入的配置文件。而且在一个源码文件中会使用 似乎 并未定义过的值,例如:
def run_wsgi_app(app):
server = wsgi.Server("Neutron")
server.start(app, cfg.CONF.bind_port, cfg.CONF.bind_host,
workers=_get_api_workers())
LOG.info(_LI("Neutron service started, listening on %(host)s:%(port)s"),
{
'host': cfg.CONF.bind_host

这篇博客主要记录了阅读Neutron源码时涉及的知识点,包括oslo_conf的全局配置用法,@classmethod在服务启动中的应用,以及functools.partial作为回调函数的概念,最后提到了数据库模块sqlalchemy的相关内容。
最低0.47元/天 解锁文章
4279

被折叠的 条评论
为什么被折叠?



