上一節我們 shelve instance 到 Glance,本節討論如何通過 unshelve 操作恢復該 instance。
因為 Glance 中保存了 instance 的 image,unshelve 的過程其實就是通過該 image launch 一個新的 instance,nova-scheduler 也會調度合適的計算節點來創建該 instance。
instance unshelve 后可能運行在與 shelve 之前不同的計算節點上,但 instance 的其他屬性(比如 flavor,IP 等)不會改變。
下面是 Unshelve instance 的流程圖
-
向 nova-api 發送請求
-
nova-api 發送消息
-
nova-scheduler 執行調度
-
nova-scheduler 發送消息
-
nova-compute 執行操作
下面我們詳細討論每一個步驟。
向 nova-api 發送請求
客戶(可以是 OpenStack 最終用戶,也可以是其他程序)向 API(nova-api)發送請求:“幫我 Unshelve 這個 Instance”
查看日志 /opt/stack/logs/n-api.log
nova-api 發送消息
nova-api 向 Messaging(RabbitMQ)發送了一條消息:“unshelve 這個 Instance” 查看源代碼 /opt/stack/nova/nova/compute/api.py,方法是 unshelve。
nova-scheduler 執行調度
nova-scheduler 收到消息后,會為 instance 選擇合適的計算節點。 查看日志 /opt/stack/logs/n-sch.log
經過篩選,最終 devstack-controller 被選中 launch instance。
nova-scheduler 發送消息
nova-scheduler 發送消息,告訴被選中的計算節點可以 launch instance 了 源代碼在 /opt/stack/nova/nova/scheduler/filter_scheduler.py 第 95 行,方法為 select_destinations
nova-compute 執行操作
nova-compute 執行 unshelve 的過程與 launch instance 非常類似。 一樣會經過如下幾個步驟: 1. 為 instance 准備 CPU、內存和磁盤資源 2. 創建 instance 鏡像文件 3. 創建 instance 的 XML 定義文件 4. 創建虛擬網絡並啟動 instance
日志記錄在 /opt/stack/logs/n-cpu.log,分析留給大家練習。
以上就是 Unshelve 操作的分析,下一節我們討論 Migrate 操作。