How to reference each resource ID in a Heat::ResourceGroup

Asked by Antonio

Hi,
referring to the following template that creates a ResourceGroup of vm_count VMs and volumes and attaches each volume to a VM

heat_template_version: 2014-10-16

description: Template

parameters:
  image:
        type: string
        label: Server Image
        description: Image Name
        default: Centos
  flavor:
        type: string
        label: Flavor
        default: m1.tiny
  vm_count:
        type: number
        label: Qty
        default: 1
  name_server:
        type: string
        label: Server Name
        default: server1
  secgroup_id:
        type: string
        label: Security Group
        description: Name of the security group
        default: default
  v_size:
        type: number
        label: Volume Size
        description: Volume size
        default: 50
  v_type:
        type: string
        label: Volume Type
        description: Volume Type
        default: iscsi
  name_net:
        type: string
        label: Network Name
        description: Network name
        default: LAN-App
  name_subnet:
        type: string
        label: Subnet Name
        description: Subnet name
        default: LAN-subnet-App

resources:
  group_vms:
      type: OS::Heat::ResourceGroup
      properties:
        count: { get_param: vm_count }
        resource_def:
            type: OS::Nova::Server
            properties:
              name:
                  list_join: ['_', [ {get_param: name_server}, _%index% ]]
              image: { get_param: image }
              flavor: { get_param: flavor }
              security_groups:
                  - { get_param: secgroup_id }
              networks:
                  - network: { get_param: name_net }

  group_volumes:
      type: OS::Heat::ResourceGroup
      properties:
        count: { get_param: vm_count }
        resource_def:
            type: OS::Cinder::Volume
            properties:
              name: volume_app_%index%
              volume_type: { get_param: v_type }
              size: { get_param: v_size }

  group_volumes_attach:
      type: OS::Heat::ResourceGroup
      properties:
        count: { get_param: vm_count }
        resource_def:
            type: OS::Cinder::VolumeAttachment
            properties:
              volume_id: { get_attr: [ group_volumes, refs, %index% ] }
              instance_uuid: { get_attr: [ group_vms, refs, %index% ] }

how can I do the attachment for each volume to each vm from 0 to vm_count-1?
The variable %index% is not allowed in the get_attr. Is there a way to use it correctly?
I need to create all the resources in a single file YAML. I cannot use nested files, everything should be created (VMs, volumes and attachments) in the same YAML file.

Thanks

Question information

Language:
English Edit question
Status:
Expired
For:
Heat Templates Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Launchpad Janitor (janitor) said :
#1

This question was expired because it remained in the 'Open' state without activity for the last 15 days.