Master code detach volume from VM
来源:互联网 发布:电力牵引预算编制软件 编辑:程序博客网 时间:2024/06/08 18:28
卷卸载 业务流程
- 访问 keystone 组件做用户认证
- 认证通过,携带 token 请求 novaclient
- novaclient 接受请求,进行卷卸载
- 卸载请求路由到 VolumeAttachmentController,进入 nova-api
- nova-api 调用 cinderclient 获取 volume 信息,检证,并设定状态 detaching
- nova-api RPC CAST 到 nova-compute 进行卷卸载
- 根据 nova.conf 的配置项 compute_driver 获取 LibvirtDriver
- 获取 BDM,根据 BDM source_type 获取驱动 DriverVolumeBlockDevice
- 调用 DriverVolumeBlockDevice 进行卸载
- 调用 os_brick 获取 connector 信息
- 调用 LibvirtDriver 在主机端卸载
- VM xml 删除挂载卷信息
- 根据 BDM 中 connection_info 的 driver_volume_type 获取 LibvirtISCSIVolumeDriver,调用 LibvirtISCSIVolumeDriver 进行主机卸载
- 调用 cinderclient 进行存储端卸载
- 调用 cinderclient 更新 cinder DB
- 更新 BDM 数据库数据
nova detach volume 源码分析(基于 master 源码)
客户端接受请求并路由到 VolumeAttachmentController
nova client ↓DELETE DELETE /v2.1/servers/c2486c45-5a8f-4028-8cd1-51c0425f677a/os-volume_attachments/30d72547-9316-4c2a-84c9-6ebc30912e0a ↓nova.api.openstack.compute.volumes.VolumeAttachmentController.delete ↓ 调用 cinderclient 获取 volumevolume = self.volume_api.get(context, volume_id) ↓获取 block_device_mapping 中该 instance 挂载的所有卷(用法应该可以优化)bdms = objects.BlockDeviceMappingList.get_by_instance_uuid ↓ 核心的取消挂载过程self.compute_api.detach_volume(context, instance, volume) self.compute_api 可用的有两个: 1. nova.compute.cells_api.ComputeCellsAPI 2. nova.compute.api.API 根据 nova.conf 配置项决定使用哪一个,默认情况下是 nova.compute.api.API
nova-api 处理过程
nova.compute.api.API.detach_volume self._detach_volume ↓nova.compute.api.API._detach_volume step1: self._check_and_begin_detach(context, volume, instance) ↓ step2: self.compute_rpcapi.detach_volume(context, instance=instance, volume_id=volume['id'], attachment_id=attachment_id)
step1: 取消挂载前准备工作
nova.compute.rpcapi.ComputeAPI.detach_volume 1. self.volume_api.check_detach(context, volume, instance=instance) ↓ nova.volume.cinder.API.check_detach(和 cinder 组件无交互) 直接判断 volume 里面相关数据(available,detached,attachments) 2. self.volume_api.begin_detaching(context, volume['id']) ↓ nova.volume.cinder.API.begin_detaching cinderclient begin_detaching(os-begin_detaching) 更新 cinder DB 数据:'status': 'detaching'
step2: 卸载卷
RPC CAST 到 nova-compute
self.compute_rpcapi.detach_volume ↓nova.compute.rpcapi.detach_volume PRC CAST ↓nova.compute.manager.ComputeManager.detach_volume
核心卸载卷流程(ComputeManager.detach_volume)
nova.compute.manager.ComputeManager.detach_volume ↓nova.compute.manager.ComputeManager._detach_volume ↓ 获取 BlockDeviceMapping 对象bdm = objects.BlockDeviceMapping.get_by_volume_and_instance ↓ 获取 BDM driverdriver_bdm = driver_block_device.convert_volume(bdm)driver_bdm: nova.virt.block_device.DriverVolumeBlockDevice ↓ 实际上调用 BDM driver 执行取消挂载driver_bdm.detach(context, instance, self.volume_api, self.driver, attachment_id=attachment_id, destroy_bdm=destroy_bdm)self.volume_api = nova.volume.cinder.APIself.driver = nova.virt.libvirt.driver.LibvirtDriver ↓ 数据库删除(设定 deleted flag 位) bdm.destroy()
BDM driver detach
nova.virt.block_device.DriverVolumeBlockDevice.detach ↓ 获取 connector,为 terminate_connection 提供入参+-STEP 1---------------------|-----------------------------------+| connector = virt_driver.get_volume_connector(instance) || ↓ || nova.virt.libvirt.driver.LibvirtDriver.get_volume_connector || ↓ || os_brick.initiator.connector.get_connector_properties |+----------------------------|-----------------------------------+ ↓ 主机端取消挂载卷+-STEP 2---------------------|-----------------------------------+| self.driver_detach(context, instance, volume_api, virt_driver) || ↓ | | virt_driver.detach_volume || nova.virt.libvirt.driver.LibvirtDriver.detach_volume || ↓ || VM xml 删除挂载卷信息 || guest.detach_device_with_retry || ↓ || 主机端取消挂载 || self._disconnect_volume(connection_info, disk_dev) || ↓ || 根据 driver_volume_type 获取 LibvirtISCSIVolumeDriver || vol_driver = self._get_volume_driver(connection_info) || vol_driver.disconnect_volume(connection_info, disk_dev) || ↓ || nova.virt.libvirt.volume.iscsi.LibvirtISCSIVolumeDriver. || disconnect_volume |+----------------------------|-----------------------------------+ ↓ cinder 端取消后端存储挂载关系+-STEP 3---------------------|-----------------------------------+| volume_api.terminate_connection(context, volume_id, connector) || ↓ | | nova.volume.cinder.API.terminate_connection || cinderclient terminate_connection(os-terminate_connection) |+----------------------------|-----------------------------------+ ↓ 更新 cinder DB 数据+-STEP 4---------------------|-----------------------------------+| volume_api.detach || ↓ | | nova.volume.cinder.API.detach || cinderclient detach(os-detach) |+----------------------------------------------------------------+
- 卷卸载 业务流程
- nova detach volume 源码分析基于 master 源码
- 客户端接受请求并路由到 VolumeAttachmentController
- nova-api 处理过程
- step1 取消挂载前准备工作
- step2 卸载卷
- RPC CAST 到 nova-compute
- 核心卸载卷流程ComputeManagerdetach_volume
- BDM driver detach
0 0
- Master code detach volume from VM
- Master code attach volume to VM
- 问题:boot vm from volume failed
- detach volume流程分析
- Detach Volume 操作
- Source code analysis openstack master cinder create volume
- [openstack]卸载卷(detach volume)流程
- Creating a Java VM from Android Native Code
- Delete snapshot from volume
- nova boot-from-volume
- Boot from Volume
- OpenStack Nova: Boot From Volume
- Unable to attach cinder volume to VM
- Trigger script exited with code: 1 From https://github.com/CocoaPods/Specs 9967bbf..de7b3da master -
- From journeyman to master
- Citrix XEN VM Boot Error code: INVALID_SOURCE Unable to Boot from CD/DVD Read more: http://eitwebgu
- Detach Volume 操作 - 每天5分钟玩转 OpenStack(55)
- Accessing a Fedora Logical Volume from Ubuntu
- 《Python进行自然语言处理》代码笔记(一):第一章示例
- 动态规划的详细解析(01背包问题)
- JSP内置对象下
- eclipse安装JAVA反编译插件
- PHP性能如何实现全面优化?
- Master code detach volume from VM
- Unity3D学习(二)农夫与魔鬼过河
- phpStorm problems with php-cgi
- ubuntu 添加用户指定登录shell修改登录shell
- 将工程作为动态库方法及使用
- android UDP实例
- LeetCode | 537. Complex Number Multiplication
- UML图
- python中super工作原理