From c5e1c001bb83b30954af8fcdce4502a8926e1195 Mon Sep 17 00:00:00 2001 From: Steven Hardy Date: Thu, 4 Sep 2014 10:28:52 +0100 Subject: [PATCH] Add a server with volumes ResourceGroup example Adds an example in response to a ML question, shows how you can create a resource group containing a number of nested stacks containing identical volumes and volume attachment resources, then pass in the server ID to have the volumes attached to one server. Also moves the current basic example into a resource_group subdirectory, so we can collect related examples, and make more obvious that the volume_with_attachment template is part of another example rather than a standalone example template. Change-Id: I1ffc1656286a981b6dc219038e03adbb8d5af775 --- hot/{ => resource_group}/resource_group.yaml | 0 hot/resource_group/server_with_volumes.yaml | 52 +++++++++++++++++++ .../volume_with_attachment.yaml | 26 ++++++++++ 3 files changed, 78 insertions(+) rename hot/{ => resource_group}/resource_group.yaml (100%) create mode 100644 hot/resource_group/server_with_volumes.yaml create mode 100644 hot/resource_group/volume_with_attachment.yaml diff --git a/hot/resource_group.yaml b/hot/resource_group/resource_group.yaml similarity index 100% rename from hot/resource_group.yaml rename to hot/resource_group/resource_group.yaml diff --git a/hot/resource_group/server_with_volumes.yaml b/hot/resource_group/server_with_volumes.yaml new file mode 100644 index 00000000..aa3ca9d9 --- /dev/null +++ b/hot/resource_group/server_with_volumes.yaml @@ -0,0 +1,52 @@ +heat_template_version: 2013-05-23 + +description: > + Example of using ResourceGroup to attach multiple volumes to an instance + +parameters: + key_name: + type: string + description: keypair to enable SSH access to the instance. + default: stack_key + + image_id: + type: string + description: ID of the image to use for the instance to be created. + default: cirros-0.3.2-x86_64-disk + + volume_size: + type: number + description: Size of volume to attach to instance + default: 1 + constraints: + - range: {min: 1, max: 10} + + num_volumes: + type: number + description: Number of volumes to attach to instance + default: 2 + constraints: + - range: {min: 1, max: 10} + + instance_type: + type: string + description: Type of the instance to be created. + default: m1.nano + +resources: + instance: + type: OS::Nova::Server + properties: + image: { get_param: image_id } + flavor: { get_param: instance_type } + key_name: { get_param: key_name } + + group_of_volumes: + type: OS::Heat::ResourceGroup + properties: + count: {get_param: num_volumes} + resource_def: + type: volume_with_attachment.yaml + properties: + instance_id: {get_resource: instance} + volume_size: {get_param: volume_size} diff --git a/hot/resource_group/volume_with_attachment.yaml b/hot/resource_group/volume_with_attachment.yaml new file mode 100644 index 00000000..28ae35b7 --- /dev/null +++ b/hot/resource_group/volume_with_attachment.yaml @@ -0,0 +1,26 @@ +heat_template_version: 2013-05-23 + +parameters: + volume_size: + type: number + description: Size of volume to attach to instance + default: 1 + constraints: + - range: {min: 1, max: 10} + + instance_id: + type: string + description: Server to attach volume to + +resources: + volume: + type: OS::Cinder::Volume + properties: + size: { get_param: volume_size } + description: Volume for stack + + volume_attachment: + type: OS::Cinder::VolumeAttachment + properties: + volume_id: { get_resource: volume } + instance_uuid: { get_param: instance_id}