有没有一种方法可以根据 HOT 中的输入参数来计算资源价值?

Is there a way to calculate resource value based on input parameter in HOT?

我需要根据一个卷大小自动计算另一个卷大小。 简化示例:

有一个入参

data_disk_size:
  type: number
  default: 50

我们希望第二卷是: 100 如果 1 < data_disk_size < 200; 200 如果 200 < data_disk_size < 400;否则 400

据我所知,条件块无济于事,因为它仅使用布尔值进行操作,可用选项是 if 和 yaql。 但是我无法同时使用它们:

  instance_volume_2:
    type: OS::Cinder::Volume
    properties:
      ...
      size:
        if:
        - yaql:
            expression: $.data > 1 and $.data < 200
            data: {get_param: data_disk_size}
        - 100
        - 200 {only for test, there should be nested if}

它给出:

'ERROR: if.yaql: The function "yaql" is invalid in this context'

所以唯一剩下的选项是纯 yaql,但它没有 if 运算符!

我错过了什么?也许有简单的方法可以做到?

我找到了解决方案!丑陋,但工作一个:)

YAQL没有if,但是有其他逻辑运算符,比如and/or。 所以价值可以这样计算:

instance_volume_2:
  type: OS::Cinder::Volume
    properties:
      ...
      size:
        yaql:
          expression: (($.data < 200 and 100) or ($.data < 400 and 200)) or 400
          data: {get_param: data_disk_size}