带有或不带有volume_type的煤渣体积的HOT模板

问题描述

我正在尝试为Openstack卷编写HOT模板,并且需要具有volume_type作为参数。我还需要支持未提供参数且认为Cinder认卷类型的情况。

第一次尝试是将null传递给volume_type,希望它将提供认的卷类型。但是,无论我通过什么(null,〜,认值““”),似乎都无法获取认的卷类型。

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”对象不可迭代

解决方法

你能做这样的事吗?

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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...