2

Say I want to name a a resource based on 2 variables so I have something like:

heat_template_version: 2013-05-23

description: Create network with

parameters:
  client_code:
    type: string
    description: 4 character customer code. Will be used for instance naming
  project_code:
    type: string
    description: 3 character project code

Now I would like to create resource with the name based on the client and project:

resources:
  test:
    type: OS::Neutron::Net
    properties:
      name: {get_param: client_code}{get_param: project_code}

That resource creation gives me a parse error. Is there anyway I can achieve this, or do I need to use a pre-script to generate my template?

5

I found a solution using 'list_join':

heat_template_version: 2013-05-23

  int_network:
    type: OS::Neutron::Net
    properties:
    name:
       list_join: ['-', [ {get_param: tenant}, 'net']]
| improve this answer | |
5

I found a solution using str_replace. My code looks something like:

heat_template_version: 2013-05-23

description: Create network with

parameters:
  client_code:
    type: string
    description: 4 character customer code. Will be used for instance naming
  project_code:
    type: string
    description: 3 character project code

resources:
  test:
    type: OS::Neutron::Net
    properties:
      name:
        str_replace:
        template: cust%-proj%
        params:
          "cust%": { get_param: client_code } 
          "proj%": { get_param: project_code }
| improve this answer | |
  • doesn't always work e.g. when working with OS::Neutron::Net attribute value_specs, instead I had to use list_join – Jonas Libbrecht May 3 '18 at 7:11
  • @JonasLibbrecht My answer is 3 years old, it is quite feasible that it no longer accurate – chriscowley May 4 '18 at 14:47
  • As I am testing this on OSP Newton stable, that is at least 2 years old, your answer seems to be invalid – Jonas Libbrecht May 5 '18 at 16:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.