nova-rootwrap
安装
为了使用root_wrap
以将普通用户的指令修改为sudo
运行的指令,且不需要输入密码,则首先需要在/etc/sudoers
中配置对应的配置项,例如允许ms
用户运行nova-rootwrap
ms ALL = (root) NOPASSWD: /usr/bin/nova-rootwrap /etc/nova/rootwrap.conf*
2025/3/28大约 3 分钟
为了使用root_wrap
以将普通用户的指令修改为sudo
运行的指令,且不需要输入密码,则首先需要在/etc/sudoers
中配置对应的配置项,例如允许ms
用户运行nova-rootwrap
ms ALL = (root) NOPASSWD: /usr/bin/nova-rootwrap /etc/nova/rootwrap.conf*
一些PCI设备提供独占设备能力和共享能力,在使用SR-IOV时,物理设备会被虚拟化为多个PCI设备,虚拟化设备可以分配给不同的主机,在PCI直通的情况下,完整的物理设备只会分配给一个主机。
硬件要求:
intel_iommu=on
或amd_iommu=on
到内核参数。验证命令:
dmesg | grep -i iommu # 检查 IOMMU 是否启用
lspci -v # 查看 PCI 设备信息及地址(如 0000:41:00.0)
Openstack中使用启动器oslo_service.service.Launcher
管理各种Service
,启动器能在收到systemctl stop
发出的kill -15
信号之后,执行内部services
的stop()
方法,如果能在stop()
中添加优雅关闭的逻辑代码,则能实现服务的生命流程托管于Launcher
,从而实现整个主进程的优雅关闭
主要用于启动rpc服务,启动定时任务
以nova.service.Service.create
方法为例:
# 父类为oslo_service.Service
@classmethod
def create(cls, host=None, binary=None, topic=None, manager=None,
report_interval=None, periodic_enable=None,
periodic_fuzzy_delay=None, periodic_interval_max=None):
# 相关配置检查
if not host:
host = CONF.host
if not binary:
binary = os.path.basename(sys.argv[0])
if not topic:
topic = binary.rpartition('nova-')[2]
if not manager:
# 为当前的wsgi服务配置对应的manager,manager中用来启动定时任务,或暴露endpoint服务端点
manager = SERVICE_MANAGERS.get(binary)
if report_interval is None:
report_interval = CONF.report_interval
if periodic_enable is None:
periodic_enable = CONF.periodic_enable
if periodic_fuzzy_delay is None:
periodic_fuzzy_delay = CONF.periodic_fuzzy_delay
debugger.init()
# 调用超类的构造方法
service_obj = cls(host, binary, topic, manager,
report_interval=report_interval,
periodic_enable=periodic_enable,
periodic_fuzzy_delay=periodic_fuzzy_delay,
periodic_interval_max=periodic_interval_max)
try:
utils.raise_if_old_compute()
except exception.TooOldComputeService as e:
if CONF.workarounds.disable_compute_service_check_for_ffu:
LOG.warning(str(e))
else:
raise
return service_obj
主要用于启动rpc服务,启动定时任务
以nova.service.Service.create
方法为例:
# 父类为oslo_service.Service
@classmethod
def create(cls, host=None, binary=None, topic=None, manager=None,
report_interval=None, periodic_enable=None,
periodic_fuzzy_delay=None, periodic_interval_max=None):
# 相关配置检查
if not host:
host = CONF.host
if not binary:
binary = os.path.basename(sys.argv[0])
if not topic:
topic = binary.rpartition('nova-')[2]
if not manager:
# 为当前的wsgi服务配置对应的manager,manager中用来启动定时任务,或暴露endpoint服务端点
manager = SERVICE_MANAGERS.get(binary)
if report_interval is None:
report_interval = CONF.report_interval
if periodic_enable is None:
periodic_enable = CONF.periodic_enable
if periodic_fuzzy_delay is None:
periodic_fuzzy_delay = CONF.periodic_fuzzy_delay
debugger.init()
# 调用超类的构造方法
service_obj = cls(host, binary, topic, manager,
report_interval=report_interval,
periodic_enable=periodic_enable,
periodic_fuzzy_delay=periodic_fuzzy_delay,
periodic_interval_max=periodic_interval_max)
try:
utils.raise_if_old_compute()
except exception.TooOldComputeService as e:
if CONF.workarounds.disable_compute_service_check_for_ffu:
LOG.warning(str(e))
else:
raise
return service_obj
主要用于启动rpc服务,启动定时任务
以nova.service.Service.create
方法为例:
# 父类为oslo_service.Service
@classmethod
def create(cls, host=None, binary=None, topic=None, manager=None,
report_interval=None, periodic_enable=None,
periodic_fuzzy_delay=None, periodic_interval_max=None):
# 相关配置检查
if not host:
host = CONF.host
if not binary:
binary = os.path.basename(sys.argv[0])
if not topic:
topic = binary.rpartition('nova-')[2]
if not manager:
# 为当前的wsgi服务配置对应的manager,manager中用来启动定时任务,或暴露endpoint服务端点
manager = SERVICE_MANAGERS.get(binary)
if report_interval is None:
report_interval = CONF.report_interval
if periodic_enable is None:
periodic_enable = CONF.periodic_enable
if periodic_fuzzy_delay is None:
periodic_fuzzy_delay = CONF.periodic_fuzzy_delay
debugger.init()
# 调用超类的构造方法
service_obj = cls(host, binary, topic, manager,
report_interval=report_interval,
periodic_enable=periodic_enable,
periodic_fuzzy_delay=periodic_fuzzy_delay,
periodic_interval_max=periodic_interval_max)
try:
utils.raise_if_old_compute()
except exception.TooOldComputeService as e:
if CONF.workarounds.disable_compute_service_check_for_ffu:
LOG.warning(str(e))
else:
raise
return service_obj
🌈相关链接openstack中的Service
在创建RPCServer
和RPCClient
都需要指定transport
,openstack的每个模块中rpcapi.py
的init()
方法中都会存在create_transport()
方法,本质是调用msg_transport._get_transport