Ask Your Question

Creating multiple instance with new volumes and attaching them.

asked 2017-06-28 05:55:47 -0600

Mohd Ali gravatar image

i have written heat template to create a vm with new volume and also attach it while creation, no problem there, when i modify the template to create multiple vm with new volume creation and attach them it fails,, i have found out it tries to attach volume to an id instead of vms id.

```[root@controller ~]# cat heat2.yml
heat_template_version: 2015-10-15

     type: OS::Heat::ResourceGroup
       count: 2
         type: OS::Nova::Server
           name: vm_%index%
           image: cirros
           flavor:  m1.extra_tiny
           - network: self_service

     type: OS::Cinder::Volume
       size: 1

     type: OS::Cinder::VolumeAttachment
       instance_uuid: { get_resource:   my_instance }
       volume_id: { get_resource:  volume_creation }

 stack_status          | CREATE_FAILED                                                                                      |
| stack_status_reason   | Resource CREATE failed: Error: resources.DB_Volume_att: Failed to attach volume ba2ad58a-c422-4258 |
|                       | -9eae-8fbd5e5d6661 to server 8821ba48-6317-4c4e-9f41-b6a0d5068745 - Instance 8821ba48-6317-4c4e-   |
|                       | 9f41-b6a0d5068745 could not be found. (HTTP 404) (Request-ID: req-e26c0ba3-a687-434f-              |
|                       | b7a7-eb53c1b063e2)  

[root@controller ~]# openstack server list
| ID                                   | Name                          | Status  | Networks               |
| 62f6ffc9-a0bb-4ec5-8495-4c5a2aff228e | vm_0                          | ACTIVE  | self_service= |
| b9744fba-25ab-4b2c-bcc8-69735d908ee9 | vm_1                          | ACTIVE  | self_service= |
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted

answered 2017-07-03 09:02:08 -0600

zaneb gravatar image

You're trying to attach a volume to a ResourceGroup, which obviously doesn't work - it can only be attached to a Server. It will work if you do something like:

   instance_uuid: { get_attr: [my_instance, resources.0] }

but ultimately this is not going to get you want you want - you can't attach the same volume to every server in the group. What you want to do is keep your original, working, template (with just one server and volume) and use that as the scaled unit of the ResourceGroup in a different template:

     type: OS::Heat::ResourceGroup
       count: 2
         type: my_server_volume_template.yaml
           name: vm_%index%

Note that you'll have to add a 'name' parameter to my_server_volume_template.yaml to pass the name with the index through.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2017-06-28 05:55:47 -0600

Seen: 1,757 times

Last updated: Jul 03 '17