本文主要分析Nova的一个event机制,目前主要用于VIF plugin时的notification,可以实现Nova 和 Neutron之间VIF 状态信息的交互。
1. nova部分
vif_plugging_timeout配置参数的解释,用于定义创建VM时等待VIF准备好的时间
cfg.BoolOpt('vif_plugging_is_fatal',
default=True,
help="Fail instance boot if vif plugging fails"),
cfg.IntOpt('vif_plugging_timeout',
default=300,
help='Number of seconds to wait for neutron vif plugging '
'events to arrive before continuing or failing (see '
'vif_plugging_is_fatal). If this is set to zero and '
'vif_plugging_is_fatal is False, events should not '
'be expected to arrive at all.'),
_create_domain_and_network():
timeout = CONF.vif_plugging_timeout
if (self._conn_supports_start_paused and #判断是不是支持开机是暂停,主要是virt_type是否是kvm or qemu, 此处进行判断的原因是vm需要暂停一下等待linux bridge创建好并把vm连接到br-int上去
utils.is_neutron() and not
vifs_already_plugged and power_on and timeout):
events = self._get_neutron_events(network_info)#返回所有vif的active属性为False的项
else:
events = []
launch_flags = events and libvirt.VIR_DOMAIN_START_PAUSED or 0
domain = None
try:
with self.virtapi.wait_for_instance_event(#上下文管理
instance, events, deadline=timeout,
error_callback=self._neutron_failed_callback):

本文深入探讨了Nova的事件(event)机制,特别是在VIF插件通知中的应用,用于Nova和Neutron间VIF状态信息的同步。文章首先解析了Nova部分,详细介绍了_create_domain_and_network()函数中的上下文管理器和wait_for_instance_event()如何等待并处理VIF准备就绪。接着分析了Neutron部分,揭示了Neutron如何通过调用Nova的REST API来更新event状态,确保VIF插接流程的正确协调。
最低0.47元/天 解锁文章
908

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



