读neutron源码,各种细节杂记

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

主要记录在阅读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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值