[openstack]建立卷(create volume)流程
nova-api和cinder-api都提供了建立卷的api,圖1是使用nova client建立卷的流程,把nova client和nova-api替換成cinder client後即是cinder client建立卷的流程。
圖中約定:
- 藍色箭頭:代表http請求;
- 粉色箭頭:表示程式碼執行在相應服務的程序地址空間;
- 綠色箭頭:代表RPC,通過訊息佇列傳送請求;
- 黑色箭頭:如何執行相應請求與具體的儲存系統有關;
圖1 create volume flow
1:nova volume-create
nova client向nova-api傳送建立卷的http請求;
1.1: parse request body
class VolumeController的create方法(nova-stable-havana/nova/api/openstack/compute/contrib/volumes.py)
1.2: create volume
class API的create方法(nova-stable-havana/nova/volume/cinder.py)
1.2.1: parse request body
class VolumeController中create方法(cinder-stable-havana/cinder/api/v1/volumes.py)
1.2.2: build create volume flow
class API中create方法(cinder-stable-havana/cinder/volume/api.py)
get_api_flow函式(cinder-stable-havana/cinder/volume/flows/create_volume/__init__.py)
1.2.3: create volume(cast)
class VolumeAPI中create_volume(cinder-stable-havana/cinder/volume/rpcapi.py)
1.2.3.1: schedule request
class SchedulerManager中create_volume方法(cinder-stable-havana/cinder/scheduler/manager.py)
get_scheduler_flow函式(cinder-stable-havana/cinder/volume/flows/create_volume/__init__.py)
1.2.3.2: create volume(cast)
class FilterScheduler中FilterScheduler方法(cinder-stable-havana/cinder/scheduler/filter_scheduler.py)
class VolumeManager中create_volume方法(cinder-stable-havana/cinder/volume/manager.py)
1.2.3.2.1: build create volume flow
get_manager_flow函式(cinder-stable-havana/cinder/volume/flows/create_volume/__init__.py)
1.2.3.2.2: create volume
class VolumeDriver中create_volume方法(cinder-stable-havana/cinder/volume)
1.2.3.2.2.1: create volume now
後端儲存系統建立卷的方式各不相同,具體實現方式參見相應driver的實現
1.2.3.2.2.2: volume created
卷建立成功,反回
1.2.3.2.3: export volume and update database
匯出卷並且更新相應的資料庫
1.2.4: volume creating
卷建立請求是非同步的,將請求發給cinder-api後不會等待卷建立成功後再返回,而是直接返回正在建立的卷的資訊
1.3: volume creating