Debian Codegraph @

heat_tempest_plugin/tests/scenario/templates/test_volumes_create_from_backup.yaml

raw
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.
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 rescan_timeout:
26 type: number
27 description: Max number of seconds to wait for volume after rescan
28 default: 120
29
30 backup_id:
31 type: string
32 description: backup_id to create volume from
33
34 network:
35 type: string
36
37 volume_description:
38 type: string
39 description: Description of volume
40 default: A volume description
41
42 wc_extra_args:
43 type: string
44 description: extra options to add to CURL command
45 default: ""
46
47 resources:
48 volume:
49 type: OS::Cinder::Volume
50 properties:
51 backup_id: { get_param: backup_id }
52 description: { get_param: volume_description }
53
54 volume_attachment:
55 type: OS::Cinder::VolumeAttachment
56 properties:
57 volume_id: { get_resource: volume }
58 instance_uuid: { get_resource: instance }
59
60 instance:
61 type: OS::Nova::Server
62 properties:
63 image: { get_param: image_id }
64 flavor: { get_param: instance_type }
65 key_name: { get_param: key_name }
66 networks:
67 - uuid: {get_param: network}
68 user_data_format: RAW
69 user_data:
70 str_replace:
71 template: |
72 #!/bin/sh
73 # Trigger rescan to ensure we see the attached volume
74 for i in /sys/class/scsi_host/*; do echo "- - -" > $i/scan; done
75 # Wait for the rescan as the volume doesn't appear immediately
76 for i in $(seq 1 rescan_timeout)
77 do
78 grep -q dev_name /proc/partitions && break
79 sleep 1
80 done
81 if grep -q dev_name /proc/partitions
82 then
83 mount /dev/dev_name /mnt
84 TESTDATA=$(cat /mnt/testfile)
85 curl wc_extra_args -X PUT -H 'Content-Type:' --data-binary '{"Status": "SUCCESS", "Reason": "Test Complete", "Data": "Volume Data:'$TESTDATA'", "UniqueId": "instance1"}' "wc_url"
86 else
87 curl wc_extra_args -X PUT -H 'Content-Type:' --data-binary '{"Status": "FAILURE", "Reason": "Test Failed", "Data": "Expected device dev_name not found.", "UniqueId": "instance1"}' "wc_url"
88 fi
89 params:
90 wc_url: { get_resource: wait_handle }
91 dev_name: { get_param: dev_name }
92 rescan_timeout: { get_param: rescan_timeout }
93 wc_extra_args: { get_param: wc_extra_args }
94
95 wait_handle:
96 type: OS::Heat::UpdateWaitConditionHandle
97
98 wait_condition:
99 type: OS::Heat::WaitCondition
100 depends_on: instance
101 properties:
102 handle: { get_resource: wait_handle }
103 timeout: { get_param: timeout }
104
105
106 outputs:
107 status:
108 description: status
109 value: { get_attr: ['volume', 'status'] }
110
111 size:
112 description: size
113 value: { get_attr: ['volume', 'size'] }
114
115 display_description:
116 description: display_description
117 value: { get_attr: ['volume', 'display_description'] }
118
119 volume_id:
120 value: { get_resource: volume }
121
122 testfile_data:
123 description: Contents of /mnt/testfile from the mounted volume
124 value: { get_attr: ['wait_condition', 'data'] }