from nova to ironic(7)

本文详细解析了OpenStack中Ironic与Nova组件如何通过特定流程实现集成,重点关注了资源更新、节点信息获取及数据库同步的过程。

前面说到ironic配置中和nova打交道的地方在哪里,从nova create一个hardware的instance其实改动的只是nova的几个manager和driver而已,在scheduler进行

filter的时候,从DB的ComputeNode中拿出信息就可以知道当前使用的是什么类型的hypervisor, cpu info 等,那么这些信息是怎么进到ComputeNode中的呢,不同的

compute_driver需要不同的信息,trace一下这一过程:

在启动rpc service时,调用self.manager.pre_start_hook(),

def pre_start_hook(self):
        """After the service is initialized, but before we fully bring
        the service up by listening on RPC queues, make sure to update
        our available resources (and indirectly our available nodes).
        """
        self.update_available_resource(nova.context.get_admin_context()) #东西都在这个function中

在update_available_resource中不同的driver开始发挥不同的作用,对使用ironic而言,compute_manager是“ironic.nova.compute.manager.ClusteredComputeManager”

最后还是到nova.compute.manager.ComputeManager

def update_available_resource(self, context):
        """See driver.get_available_resource()

        Periodic process that keeps that the compute host's understanding of
        resource availability and usage in sync with the underlying hypervisor.

        :param context: security context
        """
        new_resource_tracker_dict = {}
        nodenames = set(self.driver.get_available_nodes())
        for nodename in nodenames:
            rt = self._get_resource_tracker(nodename)
            rt.update_available_resource(context)
            new_resource_tracker_dict[nodename] = rt


在driver(IronicDriver)中get_available_nodes()

self._refresh_cache()#在函数中node_list = ironicclient.call('node.list', detail=True, limit=0),用ironicclient node-list列出available nodes

node_uuids = list(self.node_cache.keys())

and next

rt = self._get_resource_tracker(nodename)#rt是nova.compute.resource_tracker中的类ResourceTracker
rt.update_available_resource(context)
#ResourceTracker中的update_availabl_resource

往里面还可以追很远,怎么讲数据到的数据库呢?

1._sync_compute_node

2._update:

self._update_resource_stats(context, values)

3.self.scheduler_client.update_resource_stats( context, (self.host, self.nodename), stats)

4. self.reportclient.update_resource_stats(context, name, stats)('nova.scheduler.client.report.SchedulerReportClient', scheduler的client有query和report两种)

5 在conductor中的update_resource_stats

self.conductor_api.compute_node_update(context,  {'id': compute_node_id},   updates)

6.终于到数据库了!

def compute_node_update(self, context, node, values):
        result = self.db.compute_node_update(context, node['id'], values)
        return jsonutils.to_primitive(result)

openstak的框架本身替我们做了很多common的东西,方便加自己的driver甚至大的module以及project

到这里,ironic和nova就连起来了,下面有空会把trace IronicDriver启动instance的情况记上


源码地址: https://pan.quark.cn/s/d1f41682e390 miyoubiAuto 米游社每日米游币自动化Python脚本(务必使用Python3) 8更新:更换cookie的获取地址 注意:禁止在B站、贴吧、或各大论坛大肆传播! 作者已退游,项目不维护了。 如果有能力的可以pr修复。 小引一波 推荐关注几个非常可爱有趣的女孩! 欢迎B站搜索: @嘉然今天吃什么 @向晚大魔王 @乃琳Queen @贝拉kira 第三方库 食用方法 下载源码 在Global.py中设置米游社Cookie 运行myb.py 本地第一次运行时会自动生产一个文件储存cookie,请勿删除 当前仅支持单个账号! 获取Cookie方法 浏览器无痕模式打开 http://user.mihoyo.com/ ,登录账号 按,打开,找到并点击 按刷新页面,按下图复制 Cookie: How to get mys cookie 当触发时,可尝试按关闭,然后再次刷新页面,最后复制 Cookie。 也可以使用另一种方法: 复制代码 浏览器无痕模式打开 http://user.mihoyo.com/ ,登录账号 按,打开,找到并点击 控制台粘贴代码并运行,获得类似的输出信息 部分即为所需复制的 Cookie,点击确定复制 部署方法--腾讯云函数版(推荐! ) 下载项目源码和压缩包 进入项目文件夹打开命令行执行以下命令 xxxxxxx为通过上面方式或取得米游社cookie 一定要用双引号包裹!! 例如: png 复制返回内容(包括括号) 例如: QQ截图20210505031552.png 登录腾讯云函数官网 选择函数服务-新建-自定义创建 函数名称随意-地区随意-运行环境Python3....
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值