Steve Baker | a5bd912 | 2014-08-11 14:39:00 +1200 | [diff] [blame] | 1 | heat_template_version: 2013-05-23 |
| 2 | |
| 3 | parameters: |
| 4 | key_name: |
| 5 | type: string |
| 6 | description: keypair to enable SSH access to the instance. |
| 7 | |
| 8 | instance_type: |
| 9 | type: string |
| 10 | description: Type of the instance to be created. |
Steve Baker | a5bd912 | 2014-08-11 14:39:00 +1200 | [diff] [blame] | 11 | |
| 12 | image_id: |
| 13 | type: string |
| 14 | description: ID of the image to use for the instance to be created. |
| 15 | |
| 16 | timeout: |
| 17 | type: number |
| 18 | description: Stack creation timeout |
| 19 | |
| 20 | dev_name: |
| 21 | type: string |
| 22 | description: Expected device name for volume |
| 23 | default: vdb |
| 24 | |
| 25 | test_string: |
| 26 | type: string |
| 27 | description: Test string which is written to volume |
| 28 | default: ateststring |
| 29 | |
| 30 | rescan_timeout: |
| 31 | type: number |
| 32 | description: Max number of seconds to wait for volume after rescan |
| 33 | default: 120 |
| 34 | |
| 35 | network: |
| 36 | type: string |
| 37 | |
| 38 | volume_description: |
| 39 | type: string |
| 40 | description: Description of volume |
| 41 | default: A volume description |
| 42 | |
| 43 | volume_size: |
| 44 | type: number |
| 45 | description: Size of volume |
| 46 | default: 1 |
| 47 | |
| 48 | resources: |
| 49 | volume: |
| 50 | deletion_policy: 'Snapshot' |
| 51 | type: OS::Cinder::Volume |
| 52 | properties: |
| 53 | size: {get_param: volume_size} |
| 54 | description: {get_param: volume_description} |
| 55 | |
| 56 | volume_attachment: |
| 57 | type: OS::Cinder::VolumeAttachment |
| 58 | properties: |
| 59 | volume_id: { get_resource: volume } |
| 60 | instance_uuid: { get_resource: instance } |
| 61 | |
| 62 | instance: |
| 63 | type: OS::Nova::Server |
| 64 | properties: |
| 65 | image: { get_param: image_id } |
| 66 | flavor: { get_param: instance_type } |
| 67 | key_name: { get_param: key_name } |
| 68 | networks: |
| 69 | - uuid: {get_param: network} |
| 70 | user_data_format: RAW |
| 71 | user_data: |
| 72 | str_replace: |
| 73 | template: | |
| 74 | #!/bin/sh |
| 75 | # Trigger rescan to ensure we see the attached volume |
| 76 | for i in /sys/class/scsi_host/*; do echo "- - -" > $i/scan; done |
| 77 | # Wait for the rescan as the volume doesn't appear immediately |
| 78 | for i in $(seq 1 rescan_timeout) |
| 79 | do |
| 80 | grep -q dev_name /proc/partitions && break |
| 81 | sleep 1 |
| 82 | done |
| 83 | if grep -q dev_name /proc/partitions |
| 84 | then |
| 85 | mkfs.ext4 /dev/dev_name |
| 86 | mount /dev/dev_name /mnt |
| 87 | echo "test_string" > /mnt/testfile |
| 88 | umount /mnt |
| 89 | curl -X PUT -H 'Content-Type:' --data-binary '{"Status": "SUCCESS", "Reason": "Test Complete", "Data": "Completed volume configuration.", "UniqueId": "instance1"}' "wc_url" |
| 90 | else |
| 91 | curl -X PUT -H 'Content-Type:' --data-binary '{"Status": "FAILURE", "Reason": "Test Failed", "Data": "Expected device dev_name not found.", "UniqueId": "instance1"}' "wc_url" |
| 92 | fi |
| 93 | params: |
| 94 | wc_url: { get_resource: wait_handle } |
| 95 | dev_name: { get_param: dev_name } |
| 96 | rescan_timeout: { get_param: rescan_timeout } |
| 97 | test_string: { get_param: test_string } |
| 98 | |
| 99 | wait_handle: |
| 100 | type: OS::Heat::UpdateWaitConditionHandle |
| 101 | |
| 102 | wait_condition: |
| 103 | type: AWS::CloudFormation::WaitCondition |
| 104 | properties: |
| 105 | Count: 1 |
| 106 | Handle: { get_resource: wait_handle } |
| 107 | Timeout: { get_param: timeout } |
| 108 | |
| 109 | |
| 110 | outputs: |
| 111 | status: |
| 112 | description: status |
| 113 | value: { get_attr: ['volume', 'status'] } |
| 114 | |
| 115 | size: |
| 116 | description: size |
| 117 | value: { get_attr: ['volume', 'size'] } |
| 118 | |
| 119 | display_description: |
| 120 | description: display_description |
| 121 | value: { get_attr: ['volume', 'display_description'] } |
| 122 | |
| 123 | volume_id: |
| 124 | value: { get_resource: volume } |