OpenStack源码分析【2021.10.08】

2021SC@SDUSC

nova/cmd/compute.py/main

Abstract

This function serves as the entry of the whole nova service. The main purpose of the function is to analyse arguements from command line and complete some routine works for the application, such as setting logger, ensure root privilege, etc. This function also does pre-work for the application. For example, it helps to init objects, load plugins, set up the Guru Meditation Report, guard db access, ensure rcp features, manage versions and launch services.

# ----------------------------------header(routine for all applications)------------------------------------------
config.parse_args(sys.argv)
# 解析命令行参数(sys.argv -- command line arguments)
logging.setup(CONF, 'nova')
# 为本应用设置日志
priv_context.init(root_helper=shlex.split(utils.get_root_helper()))
# 确认命令执行具有root权限(通过root_helper对sudo的检验)
# -------------------------------header end------------------------------------------

objects.register_all()
# 注册对象:When objects are registered, an attribute is set
# on this module automatically, pointing to the newest/latest version of
# the object.
gmr_opts.set_defaults(CONF)
# overwrite default options using attributes in CONF
os_vif.initialize()
# Ensure os-vif objects are registered and plugins loaded
# Loads all os_vif plugins and initializes them with a dictionary of configuration options.
# These configuration options are passed as-is to the individual VIF plugins that are loaded via stevedore.

gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)
# This method sets up the Guru Meditation Report to automatically get dumped to stderr or a file in a given dir
# when the given signal is received. It can also use file modification events instead of signals

cmd_common.block_db_access('nova-compute')
# 不允许进入db??为什么拦着一道?
objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()
# seems like object management?
objects.Service.enable_min_version_cache() # 清理版本缓存
server = service.Service.create(binary='nova-compute',
                                topic=compute_rpcapi.RPC_TOPIC) # Instantiates class and passes back application object.
# A service takes a manager and enables rpc by listening to queues based on topic. 
# It also periodically runs tasks on the manager and reports its state to the database services table.
service.serve(server) # launch a service
service.wait() # sorry, I cannot navigate to the original function…………the function seems to be substituded.

What’s interesting is that nearly all the functions used here can be navigated to …\Python\Python38\Lib\site-packages\oslo_xxxxxx, indicading a starkle significance of this module and also highlighting the special relationship between OpenStack components’ behaviors and oslo_xxxxxx. Thus, it may be a good idea to have a closer look at oslo, which may help to gain a more profound understanding on OpenStack system.

However, after knowing the exact purpose of this function, I came to realize that althought it serves as the entrence, it is not the key point of the system. What I’m looking for is the achievement of the concept design of the each service.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值