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