Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Attach existing volumes to heat instances

Hi there,

I have 'n' created volumes that I wish to attach to 'n' instances using heat. These volumes have a patterned name (volume_%id%).

I've created a template where the volumes are referenced as 'parameters' like :

   parameters: 
      volume_00:
         description: ID of the volume_00
         label: volume_00 ID
         type: string
         default: d6ec3b01-8c9a-4677-842f-c1d054b1fa6c
      volume_01:
         description: (...)

On the other hand, the resources are created with :

resources:
port_00:
    type: OS::Neutron::Port
    properties:
        network: { get_param: network_name }
        fixed_ips:
            - subnet_id: { get_param: subnet_name }
instance_00:
    type: OS::Nova::Server
    properties:
        key_name: { get_param: key_name }
        image: { get_param: image_id }
        flavor: { get_param: flavor_id }
        networks:
            - port: { get_resource: port_00 }
volume_attachment_00:
    type: OS::Cinder::VolumeAttachment
    properties:
        volume_id: { get_param: volume_00 }
        instance_uuid: { get_resource: instance_00 }
        mountpoint: { get_param: mount_point }

Instead of rewriting 'n' times these statements, can I populate a file with the IDs (from 00 to 'n') and the corresponding volume_ids that can be used with a "repeat" statement to generate 'n' instances ? I can put the resources in a nested template, but how can I get the volume ids from a file to be sourced as the template parameters ?

Any help, suggestion appreciated :)

Regards