def_get_compute_api_class_name(): """Returns the name of compute API class.""" cell_type = nova.cells.opts.get_cell_type() return CELL_TYPE_TO_CLS_NAME[cell_type]
def__init__(self, *args, **kwargs): LOG.warning(_LW('The cells feature of Nova is considered experimental ' 'by the OpenStack project because it receives much ' 'less testing than the rest of Nova. This may change ' 'in the future, but current deployers should be aware ' 'that the use of it in production right now may be ' 'risky.')) # Mostly for tests. cell_state_manager = kwargs.pop('cell_state_manager', None) super(CellsManager, self).__init__(service_name='cells', *args, **kwargs) if cell_state_manager isNone: cell_state_manager = cells_state.CellStateManager self.state_manager = cell_state_manager() self.msg_runner = messaging.MessageRunner(self.state_manager) # cell功能的具体执行者 cells_driver_cls = importutils.import_class( CONF.cells.driver) self.driver = cells_driver_cls() self.instances_to_heal = iter([])
defbuild_instances(self, ctxt, target_cell, build_inst_kwargs): """Called by the cell scheduler to tell a child cell to build instance(s). """ method_kwargs = dict(build_inst_kwargs=build_inst_kwargs) # 创建虚拟机是一个具体到某个cell中的功能,所以使用了指定cell的消息处理类生成一个实例 message = _TargetedMessage(self, ctxt, 'build_instances', method_kwargs, 'down', target_cell) # 在指定的cell上执行'build_instances' message.process()
definstance_delete_everywhere(self, ctxt, instance, delete_type): """This is used by API cell when it didn't know what cell an instance was in, but the instance was requested to be deleted or soft_deleted. So, we'll broadcast this everywhere. """ method_kwargs = dict(instance=instance, delete_type=delete_type) # 删除所有cell中的指定虚拟机,所以使用了广播的消息处理类生成一个实例 message = _BroadcastMessage(self, ctxt, 'instance_delete_everywhere', method_kwargs, 'down', run_locally=False) # 在所有cell上执行'instance_delete_everywhere' message.process()