日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

08.存储Cinder→5.场景学习→02.Create Volume→1.cinder-api处理过程

發布時間:2023/12/31 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 08.存储Cinder→5.场景学习→02.Create Volume→1.cinder-api处理过程 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

返回總目錄

1.在創建volume時將所有的日志都實時打開以便記筆記

2.在運行完創建volume的過程,停掉xshell,否則由于xshell顯示屏有數量限制,新生成的日志會沖掉之前的日志。而且日志本身也有大小限制,時間太久的日志也會丟失。描述詳細
  • 客戶(可以是 OpenStack最終用戶,也可以是其他程序)向 cinder-api發送請求:“幫我創建一個 volume。GUI 上操作的菜單為 Project -> Volumes -> Volumes -> Create Volume
  • 設置 volume 的名稱,volume type,大小,Availability Zone 等基本信息
  • 這里我們沒有設置 Volume Source,這樣會創建一個空白的 volume。
  • 查看 cinder-api 日志僅摘錄重要的日志,后同
  • ?cinder-api 接收到一個 POST 類型的 REST API,經過對 HTTP body 的分析,該請求是:創建一個 1GB 的 volume。

  • 1
    2
    3
    Jun 11 16:51:13 controller devstack@c-api.service[28558]:
    INFO cinder.api.openstack.wsgi [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    //192.168.32.73/volume/v3/20c966be6e644bdfa8858d7940d0781f/volumes
    1.WSGI是Web Server Gateway Interface的縮寫當使用RESTful web服務的時候:GET用于從服務器取回數據;POST請求通常用來創建一個實體;PUT請求和POST請求類似,但是一般用來更新一個已有的實體;DELETE方法用來從服務器上刪除資源;HEAS請求和GET請求資源類似,但是僅僅返回響應的頭部(沒有具體的響應體)2.http://192.168.32.73/volume/v3/20c966be6e644bdfa8858d7940d0781f/volumes可以通過openstack endpoint list查到
    1
    2
    3
    4
    5
    Jun 11 16:51:13 controller devstack@c-api.service[28558]:
    DEBUG cinder.api.v3.volumes [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    : {u'volume': {u'status': u'creating', u'size': 1, u'backup_id':
    None, u'user_id': None, u'name': u'vol-1', u'imageRef': None, u'availability_zone': u'nova',
    ...
    1
    2
    3
    Jun 11 16:51:13 controller devstack@c-api.service[28558]:
    INFO cinder.api.v3.volumes [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
  • 緊接著,cinder-api 啟動了一個 Flow(工作流)volume_create_api。 Flow 的執行狀態依次為 PENDING, RUNNING 和 SUCCESS。volume_create_api 當前的狀態由 PENDING 變為 RUNNING。
  • 1
    2
    3
    4
    5
    Jun 11 16:51:13 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    (3c60509d-1a85-43c9-96fb-be0a949d0eea) transitioned into state
    from state 'PENDING' {{(pid=28564) _flow_receiver
    /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:145
    當執行工作流時,就會調用/usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py文件中的_flow_receiver函數
  • volume_create_api 工作流包含若干 Task,每個 Task 完成特定的任務。 這些任務依次為 ExtractVolumeRequestTask, QuotaReserveTask, EntryCreateTask, QuotaCommitTask, VolumeCastTask,這幾個任務在源碼中都是類,在源碼中的位置是
    1
    2
    /opt/stack/cinder/cinder
    /volume/flows/api/create_volume.py
    。 Task 的執行狀態也會經歷 PENDING, RUNNING 和 SUCCESS 三個階段

  • ExtractVolumeRequestTask 獲取 request 信息Processes an api request values into a validated set of values.(將api請求值處理為經過驗證的值集。)
  • 1
    2
    3
    4
    5
    Jun 11 16:51:13 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    Task 'cinder.volume.flows.api.create_volume.;volume:create'
    (4865720e-3012-4135-8683-e14e5ac151f9) transitioned into state from state 'PENDING'
    {{(pid=28564) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194
    當執行task時,就會調用/usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py文件中的_task_receiver函數
    1
    2
    3
    4
    5
    6
    7
    Jun 11 16:51:13 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    Task
    (4865720e-3012-4135-8683-e14e5ac151f9) transitioned into state from state 'RUNNING'
    with result '{'volume_type_id': u'e3695232-2b2d-4e2d-a184-1bcde93cd8fa', 'backup_id': None,
    ...
    {{(pid=28564) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:183
  • QuotaReserveTask?預留配額 ???kwo?t? 定量;定額;配額(分配的數額) ? ?Reserves a single volume with the given size & the given volume type(用給定大小和給定卷類型預留單個卷)?
  • 1
    2
    3
    4
    5
    Jun 11 16:51:13 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    Task 'cinder.volume.flows.api.create_volume.;volume:create' ...
    transitioned into state from state 'PENDING' {{(pid=28564)
    _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194
    1
    2
    3
    4
    Jun 11 16:51:14 controller devstack@c-api.service[28558]:
    DEBUG cinder.quota [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    ['ca6af98f-f4fc-4798-b457-0c80cd44fb80', ...
    {{(pid=28564) reserve /opt/stack/cinder/cinder/quota.py:1029
    1
    2
    3
    4
    5
    6
    Jun 11 16:51:14 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    Task ...
    transitioned into state from state 'RUNNING' with result
    '{'reservations': ['ca6af98f-f4fc-4798-b457-0c80cd44fb80', ...
    _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:183

  • EntryCreateTask 在數據庫中創建 volume 條目Creates an entry for the given volume creation in the database
  • 1
    2
    3
    4
    5
    Jun 11 11:51:14 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    Task 'cinder.volume.flows.api.create_volume.;volume:create' ...
    transitioned into state from state 'PENDING' {{(pid=28564)
    _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194
    1
    2
    3
    4
    Jun 11 11:51:14 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    Task 'cinder.volume.flows.api.create_volume.;volume:create' ...
    transitioned into state from state 'RUNNING' with result ...
  • QuotaCommitTask 確認配額 Commits the reservation
  • 1
    2
    3
    4
    5
    Jun 11 11:51:14 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    Task 'cinder.volume.flows.api.create_volume.;volume:create' ...
    transitioned into state from state 'PENDING' {{(pid=28564)
    _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194
    1
    2
    3
    4
    5
    Jun 11 11:51:14 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    Task ...
    transitioned into state from state 'RUNNING' with result '{'volume_properties': ...
    {{(pid=28564) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:183
  • 最后 VolumeCastTask 是向 cinder-sheduler 發送消息,開始調度工作 ? Performs a volume create cast to the scheduler or to the volume manager
  • 1
    2
    3
    4
    5
    Jun 11 11:51:14 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    Task 'cinder.volume.flows.api.create_volume.VolumeCastTask;:create' ...
    transitioned into state from state 'PENDING' {{(pid=28564)
    _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194
    1
    2
    3
    4
    5
    Jun 11 11:51:14 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    Task 'cinder.volume.flows.api.create_volume.;volume:create' ...
    transitioned into state from state 'RUNNING' with result 'None' {{(pid=28564)
    _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:183
  • 至此,Flow volume_create_api 已經完成,狀態由 RUNNING 變為 SUCCESS,創建volume 請求成功發布cinder-api 已經成功處理了 volume create 請求,將消息發給了 cinder-scheduler
  • 1
    2
    3
    4
    5
    Jun 11 11:51:14 controller devstack@c-api.service[28558]:
    DEBUG cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
    (3c60509d-1a85-43c9-96fb-be0a949d0eea)
    transitioned into state from state 'RUNNING'
    {{(pid=28564) _flow_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:145
    1
    2
    3
    Jun 11 11:51:14 controller devstack@c-api.service[28558]:
    INFO cinder.volume.api [None req-4111af2f-99a8-4166-8647-569b038786d9 admin admin]
  • cinder-api 向 RabbitMQ 發送了一條消息:“讓cinder-scheduler 創建一個 volume”,消息是由 VolumeCastTask 發出的,因為 VolumeCastTask 沒有打印相關日志,我們只能通過源代碼查看 /opt/stack/cinder/cinder/volume/flows/api/create_volume.py ,方法為 create_volume。

  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    class VolumeCastTask(flow_utils.CinderTask):
    """Performs a volume create cast to the scheduler or to the volume manager.

    This will signal a transition of the api workflow to another child and/or
    related workflow on another component.

    Reversion strategy: rollback source volume status and error out newly
    created volume.
    """
    #...
    def _cast_create_volume(self, context, request_spec, filter_properties):
    #...
    self.scheduler_rpcapi.create_volume(
    context,
    volume,
    snapshot_id=snapshot_id,
    image_id=image_id,
    request_spec=request_spec,
    filter_properties=filter_properties,
    backup_id=backup_id)
    #...

    如果我們需要將一個函數運行在遠程計算機上并且等待從那兒獲取結果時,該怎么辦呢?這就是另外的故事了。這種模式通常被稱為遠程過程調用(Remote Procedure Call)或者 RPC,使用 RabbitMQ 來構建一個 RPC 系統

    總結

    以上是生活随笔為你收集整理的08.存储Cinder→5.场景学习→02.Create Volume→1.cinder-api处理过程的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。