簡體   English   中英

帶或不帶 volume_type 的煤渣體積的 HOT 模板

[英]HOT template for cinder volume with or without volume_type

我正在嘗試為 Openstack 卷編寫一個 HOT 模板,並且需要將 volume_type 作為參數。 我還需要支持不給定參數的情況,默認為Cinder默認卷類型。

第一次嘗試是將 null 傳遞給 volume_type ,希望它能提供默認的卷類型。 但是,無論我通過什么 (null, ~, default, "" ) ,似乎都無法獲得默認的卷類型。

type: OS::Cinder::Volume
properties:
  name: test
  size: 1
  volume_type: { if: ["voltype_given" , {get_param:[typename]} , null] }

當您定義了“volume_type”屬性時,有什么方法可以獲得默認的卷類型?

或者,有沒有辦法讓“volume_type”屬性本身在條件后面? 我嘗試了幾種方法,但沒有運氣。 就像是:

type: OS::Cinder::Volume
properties:
  if: ["voltype_given" , [ volume_type: {get_param:[typename]} ] , ""]
  name: test
  size: 1

錯誤:類型錯誤::resources.kk-test-vol::“如果”對象不可迭代

你能做這樣的事情嗎?

---
parameters:
  typename:
    type: string

conditions:

  use_default_type: {equals: [{get_param: typename}, '']}

resources:
  MyVolumeWithDefault:
    condition: use_default_type
    type: OS::Cinder::Volume
    properties:
      name: test
      size: 1

  MyVolumeWithExplicit:
    condition: {not: use_default_type}
    type: OS::Cinder::Volume
    properties:
      name: test
      size: 1
      volume_type: {get_param: typename}

  # e.g. if you need to refer to the volume from another resource
  MyVolumeAttachment:
    type: OS::Cinder::VolumeAttachment
    properties:
      instance_uid: some-instance-uuid
      volume_id:
        if:
          - use_default_type
          - get_resource: MyVolumeWithDefault
          - get_resource: MyVolumeWithExplicit

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM