Rama Krishna. G
Rama Krishna. G

Reputation: 536

Openstack flavor validation in heat template

I am verifiying the user passed flavor in the heat template. At present the heat template allows me to mention the name of the flavor in the allowed values. Small code snippet below,

parameters:
flavor_type:  
type: string
        label: Flavor type
        description: Type of instance (flavor) to be used
        constraints:
          - allowed_values: [m1.xlarge ]
            description: Value must be one of m1.xlarge.

This works when user passes the flavor with name m1.xlarge but not with other names.

I would like to allow the custom flavors with specific sizes (RAM - 8, HD - 150, VCPU -8). These individual values I would like to verify in the heat template against with passed flavor.

I feel this is a valid use case to check the flavors. Is it something possible in the heat template ?

Thanks, Rama Krishna

Upvotes: 0

Views: 295

Answers (1)

Praveen Yalagandula
Praveen Yalagandula

Reputation: 4704

Heat Spec has the concept of custom constraints. Search for "custom constraint" at https://docs.openstack.org/heat/pike/template_guide/hot_spec.html. You can leverage that to validate the input to be one of the flavors available to the user using that template

flavor_type:
  type: string
    label: Flavor type
    description: Type of instance (flavor) to be used
    constraints:
      - custom_constraint: nova.flavor

Upvotes: 1

Related Questions