heat_template_version: 2013-05-23 parameters: key_name: type: string description: keypair to enable SSH access to the instance. instance_type: type: string description: Type of the instance to be created. default: m1.small image_id: type: string description: ID of the image to use for the instance to be created. timeout: type: number description: Stack creation timeout dev_name: type: string description: Expected device name for volume default: vdb rescan_timeout: type: number description: Max number of seconds to wait for volume after rescan default: 120 backup_id: type: string description: backup_id to create volume from network: type: string volume_description: type: string description: Description of volume default: A volume description resources: volume: type: OS::Cinder::Volume properties: backup_id: { get_param: backup_id } description: { get_param: volume_description } volume_attachment: type: OS::Cinder::VolumeAttachment properties: volume_id: { get_resource: volume } instance_uuid: { get_resource: instance } instance: type: OS::Nova::Server properties: image: { get_param: image_id } flavor: { get_param: instance_type } key_name: { get_param: key_name } networks: - uuid: {get_param: network} user_data_format: RAW user_data: str_replace: template: | #!/bin/sh # Trigger rescan to ensure we see the attached volume for i in /sys/class/scsi_host/*; do echo "- - -" > $i/scan; done # Wait for the rescan as the volume doesn't appear immediately for i in $(seq 1 rescan_timeout) do grep -q dev_name /proc/partitions && break sleep 1 done if grep -q dev_name /proc/partitions then mount /dev/dev_name /mnt TESTDATA=$(cat /mnt/testfile) curl -X PUT -H 'Content-Type:' --data-binary '{"Status": "SUCCESS", "Reason": "Test Complete", "Data": "Volume Data:'$TESTDATA'", "UniqueId": "instance1"}' "wc_url" else curl -X PUT -H 'Content-Type:' --data-binary '{"Status": "FAILURE", "Reason": "Test Failed", "Data": "Expected device dev_name not found.", "UniqueId": "instance1"}' "wc_url" fi params: wc_url: { get_resource: wait_handle } dev_name: { get_param: dev_name } rescan_timeout: { get_param: rescan_timeout } wait_handle: type: OS::Heat::UpdateWaitConditionHandle wait_condition: type: AWS::CloudFormation::WaitCondition properties: Count: 1 Handle: { get_resource: wait_handle } Timeout: { get_param: timeout } outputs: status: description: status value: { get_attr: ['volume', 'status'] } size: description: size value: { get_attr: ['volume', 'size'] } display_description: description: display_description value: { get_attr: ['volume', 'display_description'] } volume_id: value: { get_resource: volume } testfile_data: description: Contents of /mnt/testfile from the mounted volume value: { get_attr: ['wait_condition', 'Data'] }