[openstack-dev] [Heat] referencing the index of a ResourceGroup

2014-09-10 Thread Jason Greathouse
I'm trying to find a way to create a set of servers and attach a new volume
to each server.

I first tried to use block_device_mapping but that requires an existing
snapshot or volume and the deployment would fail when Rackspace
intermittently timed out trying to create the new volume from a snapshot.

I'm now trying with 3 ResourceGroups: OS::Cinder::Volume to build volumes
followed by OS::Nova::Server and then trying to attach the volumes
with OS::Cinder::VolumeAttachment.

This works when I do a single server and volume if I reference the
VolumeAttachment properties like this:
volume_id: { get_attr: [group_volumes, refs, 0] }

Is there a way to add the index reference to the property when using
get_attr? Something like this:
volume_id: { get_attr: [group_volumes, refs, %index%] }

Here is my template for reference:

heat_template_version: 2013-05-23

resources:
group_volumes:
type: "OS::Heat::ResourceGroup"
properties:
count: 1
resource_def:
type: "OS::Cinder::Volume"
properties:
size: 150
description: stack-test-vol-%index%
name: stack-test-vol-%index%
volume_type: SATA

group_servers:
type: "OS::Heat::ResourceGroup"
properties:
count: 1
resource_def:
type: "OS::Nova::Server"
properties:
key_name: root-20140819
flavor: performance1-2
image: 255df5fb-e3d4-45a3-9a07-c976debf7c14
name: heat-test-withdisk-%index%
networks:
- uuid: ----
- uuid: ----
user_data: |
{"role":"build", "env":"test"}
user_data_format: RAW
config_drive: true

attach_volumes:
type: "OS::Heat::ResourceGroup"
properties:
count: 1
resource_def:
type: "OS::Cinder::VolumeAttachment"
properties:
instance_uuid: { get_attr: [group_servers, refs, 0] }
mountpoint: /dev/xvdg
volume_id: { get_attr: [group_volumes, refs, 0] }
#properties:
#instance_uuid: { get_attr: [group_servers, refs,
"%index%"] } #This doesn't work
#mountpoint: /dev/xvdg
#volume_id: { get_attr: [group_volumes, refs,
"%index%"] }


-- 
*Jason Greathouse*
Sr. Systems Engineer

*[image: LeanKitlogo] *
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [Heat] referencing the index of a ResourceGroup

2014-09-11 Thread Steven Hardy
On Wed, Sep 10, 2014 at 04:44:01PM -0500, Jason Greathouse wrote:
>I'm trying to find a way to create a set of servers and attach a new
>volume to each server.  
>I first tried to use block_device_mapping but that requires an existing
>snapshot or volume and the deployment would fail when Rackspace
>intermittently timed out trying to create the new volume from a
>snapshot.  
>I'm now trying with 3 ResourceGroups: OS::Cinder::Volume to build volumes
>followed by OS::Nova::Server and then trying to attach the volumes
>with  OS::Cinder::VolumeAttachment.

Basically creating lots of resource groups for related things is the wrong
pattern.  You need to create one nested stack template containing the
related things (Server, Volume and VolumeAttachment in this case), and use
ResourceGroup to multiply them as a unit.

I answered a similar question here on the openstack general ML recently
(which for future reference may be a better ML for usage questions like
this, as it's not really development discussion):

http://lists.openstack.org/pipermail/openstack/2014-September/009216.html

Here's another example which I used in a summit demo, which I think
basically does what you need?

https://github.com/hardys/demo_templates/tree/master/juno_summit_intro_to_heat/example3_server_with_volume_group

Steve.

___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [Heat] referencing the index of a ResourceGroup

2014-09-11 Thread Jason Greathouse
My mistake about the mailing list, The openstack heat wiki page (
https://wiki.openstack.org/wiki/Heat) only lists the "dev" list. I will
make sure to ask future usage questions on the other one.

Thank you for the response and example. This is what I was missing.

On Thu, Sep 11, 2014 at 3:21 AM, Steven Hardy  wrote:

> On Wed, Sep 10, 2014 at 04:44:01PM -0500, Jason Greathouse wrote:
> >I'm trying to find a way to create a set of servers and attach a new
> >volume to each server.
> >I first tried to use block_device_mapping but that requires an
> existing
> >snapshot or volume and the deployment would fail when Rackspace
> >intermittently timed out trying to create the new volume from a
> >snapshot.
> >I'm now trying with 3 ResourceGroups: OS::Cinder::Volume to build
> volumes
> >followed by OS::Nova::Server and then trying to attach the volumes
> >with  OS::Cinder::VolumeAttachment.
>
> Basically creating lots of resource groups for related things is the wrong
> pattern.  You need to create one nested stack template containing the
> related things (Server, Volume and VolumeAttachment in this case), and use
> ResourceGroup to multiply them as a unit.
>
> I answered a similar question here on the openstack general ML recently
> (which for future reference may be a better ML for usage questions like
> this, as it's not really development discussion):
>
> http://lists.openstack.org/pipermail/openstack/2014-September/009216.html
>
> Here's another example which I used in a summit demo, which I think
> basically does what you need?
>
>
> https://github.com/hardys/demo_templates/tree/master/juno_summit_intro_to_heat/example3_server_with_volume_group
>
> Steve.
>
> ___
> OpenStack-dev mailing list
> OpenStack-dev@lists.openstack.org
> http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev
>



-- 
*Jason Greathouse*
Sr. Systems Engineer

*[image: LeanKitlogo] *
___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [Heat] referencing the index of a ResourceGroup

2014-09-11 Thread Mike Spreitzer
Steven Hardy  wrote on 09/11/2014 04:21:18 AM:

> On Wed, Sep 10, 2014 at 04:44:01PM -0500, Jason Greathouse wrote:
> >I'm trying to find a way to create a set of servers and attach a 
new
> >volume to each server. 
> >...
> 
> Basically creating lots of resource groups for related things is the 
wrong
> pattern.  You need to create one nested stack template containing the
> related things (Server, Volume and VolumeAttachment in this case), and 
use
> ResourceGroup to multiply them as a unit.
> 
> I answered a similar question here on the openstack general ML recently
> (which for future reference may be a better ML for usage questions like
> this, as it's not really development discussion):
> 
> 
http://lists.openstack.org/pipermail/openstack/2014-September/009216.html
> 
> Here's another example which I used in a summit demo, which I think
> basically does what you need?
> 
> https://github.com/hardys/demo_templates/tree/master/
> juno_summit_intro_to_heat/example3_server_with_volume_group

There is also an example of exactly this under review.  See 
https://review.openstack.org/#/c/97366/

Regards,
Mike___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev


Re: [openstack-dev] [Heat] referencing the index of a ResourceGroup

2014-09-11 Thread Steven Hardy
On Thu, Sep 11, 2014 at 10:06:01AM -0500, Jason Greathouse wrote:
>My mistake about the mailing list, The openstack heat wiki page
>(https://wiki.openstack.org/wiki/Heat) only lists the "dev" list. I will
>make sure to ask future usage questions on the other one.

No worries, we should update the wiki by the sounds of it.

Since you're not the first person to ask this question this week, I wrote a
quick blog post with some more info:

http://hardysteven.blogspot.co.uk/2014/09/using-heat-resourcegroup-resources.html

Steve

___
OpenStack-dev mailing list
OpenStack-dev@lists.openstack.org
http://lists.openstack.org/cgi-bin/mailman/listinfo/openstack-dev