本文基于openstack Stein 版本
nova 侧虚机需要挂载云盘,包括创建时挂载系统盘以及普通数据盘
代码在 nova\compute]manager.py, nova 获取volume信息,并发起attach请求,最终调用cinder api发起了attach请求。
1 | nova.compute.manager.ComputeManager._attach_volume: |
1 | nova.virt.block_device.DriverVolumeBlockDevice.attach |
1 | nova.virt.block_device.DriverVolumeBlockDevice.attach_volume |
这里没有attachment id调用了_legacy_volume_attach
1 | nova.virt.block_device.DriverVolumeBlockDevice._legacy_volume_attach |
1 | nova.libvirt.driver.ComputeDriver.attach_volume |
上面从nova收到请求,到调用cinder client 挂载云盘,再到libvirt 连接volume,从而虚机可以识别到磁盘,至此完成!