Heat: parameterized type

asked 2016-10-26 07:38:12 -0500

mathias gravatar image

updated 2016-10-26 07:44:17 -0500

Hi, does anybody know if something like

  instance_type:
    type: string

  instance_properties:
    type: json

resources:

  node:
    type: { get_param: instance_type }
    properties: { get_param: instance_properties }

should work? I am getting

Resource node type type must be string

On the other hand, this works fine:

  instances:
    type: OS::Heat::ResourceGroup
    properties:
      count: { get_param: count }
      resource_def:
        type: { get_param: instance_type }
        properties:
          map_merge:
            - name:
                list_join: ['-', [{ get_param: name }, '%index%']]
              image: { get_param: image }
              flavor: { get_param: flavor }
              key: { get_param: key }
              networks:
                - { get_attr: [ service_network, network ] }
                - { get_attr: [ cluster_network, network ] }
              security_groups: { get_param: security_groups }
              config: { get_resource: cluster_init }
            - { get_param: instance_properties }

Should be the same thing, no?

cheers Mathias

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2016-10-26 09:34:12 -0500

hkominos gravatar image

updated 2016-10-26 09:57:29 -0500

In the example you give it would be nice to see the parameters part. I assume that your code looks like this :

parameters:
  instance_type:
    type: string

resources:
  node:
    type: { get_param: instance_type }

?? (note the parameters part)

edit flag offensive delete link more

Comments

You are seeing ther relevant parameters already :)

  instance_type:
    type: string

  instance_properties:
    type: json

I just forgot to put "parameters:" as the first line ;)

mathias gravatar imagemathias ( 2016-10-26 10:45:36 -0500 )edit
0

answered 2016-11-12 11:26:49 -0500

zaneb gravatar image

updated 2016-11-12 11:28:42 -0500

You can't use an intrinsic function (like get_param) in the type of a resource because of reasons. The ResourceGroup example works because the intrinsic functions are resolved in the parent template, not in the context of the nested stack that the ResourceGroup creates.

What you can do is specify type mapping in an environment file. That allows you to do what you want (runtime selection of a resource type) by passing different environment files. (Note that you don't have to remap an existing resource type; you can make up a new type and map it to one or other real resource types in the environment.)

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2016-10-26 07:38:12 -0500

Seen: 139 times

Last updated: Nov 12 '16