Openstack如何发现计算节点

启动nova-compute ,定时调用update_available_resource,在_update_resource_stats函数中,通过RPC调用将主机信息和虚拟机管理器信息上报给nova-scheduler,这样openstack就识别了结算节点.

启动nova-compute时:

两步,一个是构建service,一个是启动service,实现都在nova\service.py

def main():
    config.parse_args(sys.argv)
    logging.setup('nova')
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    if not CONF.conductor.use_local:
        block_db_access()
        objects_base.NovaObject.indirection_api = \
            conductor_rpcapi.ConductorAPI()
    #构建服务
    server = service.Service.create(binary='nova-compute',
                                    topic=CONF.compute_topic,
                                    db_allowed=CONF.conductor.use_local)
    #启动服务                                
    service.serve(server)
    service.wait()
    def _update_resource_stats(self, context, values):
        stats = values.copy()
        stats['id'] = self.compute_node['id']
        self.scheduler_client.update_resource_stats(
            context, (self.host, self.nodename), stats)

具体代码分析见原文: https://blog.csdn.net/idwtwt/article/details/62227893

发布了39 篇原创文章 · 获赞 247 · 访问量 103万+

猜你喜欢

转载自blog.csdn.net/zhongbeida_xue/article/details/103531428