从cinder 删除volume 分析cinder rpc
发布日期:2021-09-16 04:36:56 浏览次数:5 分类:技术文章

本文共 1775 字,大约阅读时间需要 5 分钟。

从volume_rpcapi delete_volume开始删除volume

self.volume_rpcapi.delete_volume(context,                                         volume,                                         unmanage_only,                                         cascade)

def delete_volume(self, ctxt, volume, unmanage_only=False, cascade=False):        volume.create_worker()        cctxt = self._get_cctxt(volume.service_topic_queue)     这个cctxt是封闭context的地方,不过个 volume.service_topic_queue从字面上看是topic的名字,         msg_args = {            'volume': volume, 'unmanage_only': unmanage_only,            'cascade': cascade,        }        cctxt.cast(ctxt, 'delete_volume', **msg_args)

volume.service_topic_queue   这里其实我还看了点时间, 从数据库里查找字段,发现根本没有,去objects里的volumes.py里找,也没看到,这就奇怪了,于是多调试了下,并看了下继承,发现原来是在base.py里的ClusteredObject

class ClusteredObject(object):    @property    def service_topic_queue(self):        return self.cluster_name or self.host    原来是host字段

现在终于名字了,这个是取host字段值,名字写的这么高大上,有点名不副实的感觉。

def _get_cctxt(self, host=None, version=None, **kwargs):        if host:            server = utils.extract_host(host)            # TODO(dulek): If we're pinned before 3.6, we should send stuff the            # old way - addressing server=host@backend, topic=cinder-volume.            # Otherwise we're addressing server=host,            # topic=cinder-volume.host@backend. This conditional can go away            # when we stop supporting 3.x.            if self.client.can_send_version('3.6'):                kwargs['topic'] = '%(topic)s.%(host)s' % {'topic': self.TOPIC,               #这里到组装topic了,topic=self.TOPIC.host   这个host就是service_topic_queue  取出来的值 'host': server} server = utils.extract_host(server, 'host') kwargs['server'] = server return super(VolumeAPI, self)._get_cctxt(version=version, **kwargs)

分析完毕。

转载地址:https://blog.csdn.net/wllabs/article/details/77646376 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:horizon 创建主机 设置系统盘默认创建方式
下一篇:使用qemu-monitor 从host直接连接vm

发表评论

最新留言

感谢大佬
[***.8.128.20]2024年04月07日 05时35分49秒