Comment 1 for bug 1224111

Revision history for this message
Steven Hardy (shardy) wrote : Re: HOT cannot be used as a provider template

Confirmed, my testing indicates the same. We really need to fix this ASAP..

Here's a reproducer.

1. Create minimal provider resource template which has constraints on a parameter

# cat /tmp/hot_minimal.yaml
heat_template_version: 2013-05-23

parameters:
  InstanceType:
    type: string
    description: Instance type for WordPress server
    default: m1.small
    constraints:
      - allowed_values: [m1.small, m1.medium, m1.large]
        description: InstanceType must be one of m1.small, m1.medium or m1.large
  ImageId:
    type: string
    description: ID of the image to use for the WordPress server
    default: F18-x86_64-cfntools
    constraints:
      - allowed_values: [ F18-i386-cfntools, F18-x86_64-cfntools ]
        description: >
          Image ID bust be either F18-i386-cfntools or F18-x86_64-cfntools
  DBName:
    type: string
    description: WordPress database name
    default: wordpress
    constraints:
      - length: { min: 1, max: 64 }
        description: DBName must be between 1 and 64 characters
      - allowed_pattern: '[a-zA-Z][a-zA-Z0-9]*'
        description: >
          DBName must begin with a letter and contain only alphanumeric
          characters

resources:
  wordpress_instance:
    type: OS::Nova::Server
    properties:
      image: { get_param: ImageId }
      flavor: { get_param: InstanceType }

2. Create an environment file pointing to the template above

# cat env_minimal.yaml
resource_registry:
    # Define a custom resource type based on a template
    "My::Custom::Server": file:///tmp/hot_minimal.yaml

3 . Create a template which uses the provder resource

# cat minimal_test.yaml
heat_template_version: 2013-05-23

resources:
  wordpress_instance:
    type: My::Custom::Server

4. Launch the template

heat --debug create test_stack --template-file=./minimal_test.yaml --environment-file=./env_minimal.yaml

We get this in the engine log:

2013-09-18 14:51:01.628 7560 INFO heat.engine.environment [-] Registering My::Custom::Server -> file:///tmp/hot_minimal.yaml
SHDEBUG getting num val for MinLength from [(1, u'DBName must be between 1 and 64 characters')]
2013-09-18 14:51:01.630 7560 ERROR heat.openstack.common.rpc.amqp [-] Exception during message handling
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp Traceback (most recent call last):
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/openstack/common/rpc/amqp.py", line 461, in _process_data
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp **args)
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/openstack/common/rpc/dispatcher.py", line 172, in dispatch
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp result = getattr(proxyobj, method)(ctxt, **kwargs)
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/service.py", line 56, in wrapped
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp return func(self, ctx, *args, **kwargs)
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/service.py", line 256, in create_stack
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp env, **common_params)
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/parser.py", line 108, in __init__
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp for (name, data) in template_resources.items())
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/parser.py", line 108, in <genexpr>
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp for (name, data) in template_resources.items())
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/resource.py", line 133, in __new__
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp return ResourceClass(name, json, stack)
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/resources/template_resource.py", line 55, in __init__
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp .schema_from_params(tmpl.param_schemata()))
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 658, in schema_from_params
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp in params_snippet.items())
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 657, in <genexpr>
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp return dict((n, Schema.from_parameter(p)) for n, p
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 219, in from_parameter
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp constraints=list(constraints()))
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 209, in constraints
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp yield Length(get_num(parameters.MIN_LENGTH),
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 199, in get_num
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp val = Property.str_to_num(val)
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 539, in str_to_num
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp return int(value)
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp TypeError: int() argument must be a string or a number, not 'list'
2013-09-18 14:51:01.630 7560 TRACE heat.openstack.common.rpc.amqp
2013-09-18 14:51:01.631 7560 ERROR heat.openstack.common.rpc.common [-] Returning exception int() argument must be a string or a number, not 'list' to caller
2013-09-18 14:51:01.631 7560 ERROR heat.openstack.common.rpc.common [-] ['Traceback (most recent call last):\n', ' File "/usr/lib/python2.7/site-packages/heat/openstack/common/rpc/amqp.py", line 461, in _process_data\n **args)\n', ' File "/usr/lib/python2.7/site-packages/heat/openstack/common/rpc/dispatcher.py", line 172, in dispatch\n result = getattr(proxyobj, method)(ctxt, **kwargs)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/service.py", line 56, in wrapped\n return func(self, ctx, *args, **kwargs)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/service.py", line 256, in create_stack\n env, **common_params)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/parser.py", line 108, in __init__\n for (name, data) in template_resources.items())\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/parser.py", line 108, in <genexpr>\n for (name, data) in template_resources.items())\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/resource.py", line 133, in __new__\n return ResourceClass(name, json, stack)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/resources/template_resource.py", line 55, in __init__\n .schema_from_params(tmpl.param_schemata()))\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 658, in schema_from_params\n in params_snippet.items())\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 657, in <genexpr>\n return dict((n, Schema.from_parameter(p)) for n, p\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 219, in from_parameter\n constraints=list(constraints()))\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 209, in constraints\n yield Length(get_num(parameters.MIN_LENGTH),\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 199, in get_num\n val = Property.str_to_num(val)\n', ' File "/usr/lib/python2.7/site-packages/heat/engine/properties.py", line 539, in str_to_num\n return int(value)\n', "TypeError: int() argument must be a string or a number, not 'list'\n"]