I need to automatically calculate one volume size based on another. Simplified example:
There is an input parameter
data_disk_size:
type: number
default: 50
And we want second volume to be: 100 if 1 < data_disk_size < 200; 200 if 200 < data_disk_size < 400; else 400
As i understood, conditions block would not help as it operates only with boolean values and available options are if and yaql. But i could not manage to use them together:
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}
It gives:
'ERROR: if.yaql: The function "yaql" is invalid in this context'
So the only remaining option is pure yaql, BUT it has no if operator!
What am i missing? Maybe there is simple way to do it?
I`ve found solution! Ugly, but working one :)
YAQL has no if, but has other logic operators, such as and/or. So value can be calculated this way:
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}