【问题标题】:HOT template for cinder volume with or without volume_type煤渣卷的 HOT 模板,带或不带 volume_type
【发布时间】:2020-09-11 13:55:53
【问题描述】:

我正在尝试为 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

错误:TypeError: : resources.kk-test-vol: : 'If' 对象不可迭代

【问题讨论】:

    标签: openstack openstack-heat openstack-cinder


    【解决方案1】:

    你能做这样的事情吗?

    ---
    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
    

    【讨论】:

      猜你喜欢
      • 2014-03-15
      • 2022-06-29
      • 1970-01-01
      • 1970-01-01
      • 2015-08-04
      • 1970-01-01
      • 2013-07-25
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多