Skip to content

Commit 5413316

Browse files
committed
add volume
1 parent 158a393 commit 5413316

File tree

6 files changed

+529
-0
lines changed

6 files changed

+529
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
cloud/cs
2+
cs/group2
3+
cs/group3
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
test_cs_instance_1: "{{ cs_resource_prefix }}-vm1"
3+
test_cs_instance_2: "{{ cs_resource_prefix }}-vm2"
4+
test_cs_instance_3: "{{ cs_resource_prefix }}-vm3"
5+
test_cs_instance_template: "{{ cs_common_template }}"
6+
test_cs_instance_offering_1: Small Instance
7+
test_cs_disk_offering_1: Custom
8+
test_cs_volume_to_upload: https://ansible-ci-files.s3.us-east-1.amazonaws.com/test/integration/targets/cs_volume/macchinina-xen.vhd.bz2
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
dependencies:
3+
- cs_common
Lines changed: 322 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,322 @@
1+
---
2+
- name: setup
3+
ngine_io.cloudstack.volume:
4+
name: "{{ cs_resource_prefix }}_vol"
5+
zone: "{{ cs_common_zone_basic }}"
6+
state: absent
7+
register: vol
8+
- name: verify setup
9+
assert:
10+
that:
11+
- vol is successful
12+
13+
- name: setup instance 1
14+
ngine_io.cloudstack.instance:
15+
name: "{{ test_cs_instance_1 }}"
16+
template: "{{ test_cs_instance_template }}"
17+
service_offering: "{{ test_cs_instance_offering_1 }}"
18+
zone: "{{ cs_common_zone_basic }}"
19+
register: instance
20+
- name: verify create instance
21+
assert:
22+
that:
23+
- instance is successful
24+
25+
- name: setup instance 2
26+
ngine_io.cloudstack.instance:
27+
name: "{{ test_cs_instance_2 }}"
28+
template: "{{ test_cs_instance_template }}"
29+
service_offering: "{{ test_cs_instance_offering_1 }}"
30+
zone: "{{ cs_common_zone_basic }}"
31+
register: instance
32+
- name: verify create instance
33+
assert:
34+
that:
35+
- instance is successful
36+
37+
- name: test fail if missing name
38+
ngine_io.cloudstack.volume:
39+
zone: "{{ cs_common_zone_basic }}"
40+
register: vol
41+
ignore_errors: true
42+
- name: verify results of fail if missing name
43+
assert:
44+
that:
45+
- vol is failed
46+
- "vol.msg == 'missing required arguments: name'"
47+
48+
- name: test create volume in check mode
49+
ngine_io.cloudstack.volume:
50+
name: "{{ cs_resource_prefix }}_vol"
51+
zone: "{{ cs_common_zone_basic }}"
52+
disk_offering: "{{ test_cs_disk_offering_1 }}"
53+
size: 20
54+
register: vol
55+
check_mode: true
56+
- name: verify results test create volume in check mode
57+
assert:
58+
that:
59+
- vol is changed
60+
61+
- name: test create volume
62+
ngine_io.cloudstack.volume:
63+
name: "{{ cs_resource_prefix }}_vol"
64+
zone: "{{ cs_common_zone_basic }}"
65+
disk_offering: "{{ test_cs_disk_offering_1 }}"
66+
size: 20
67+
register: vol
68+
- name: verify results test create volume
69+
assert:
70+
that:
71+
- vol is changed
72+
- vol.size == 20 * 1024 ** 3
73+
- vol.name == cs_resource_prefix + "_vol"
74+
75+
- name: test create volume idempotence
76+
ngine_io.cloudstack.volume:
77+
name: "{{ cs_resource_prefix }}_vol"
78+
zone: "{{ cs_common_zone_basic }}"
79+
disk_offering: "{{ test_cs_disk_offering_1 }}"
80+
size: 20
81+
register: vol
82+
- name: verify results test create volume idempotence
83+
assert:
84+
that:
85+
- vol is not changed
86+
- vol.size == 20 * 1024 ** 3
87+
- vol.name == cs_resource_prefix + "_vol"
88+
89+
- name: test shrink volume in check mode
90+
ngine_io.cloudstack.volume:
91+
name: "{{ cs_resource_prefix }}_vol"
92+
zone: "{{ cs_common_zone_basic }}"
93+
disk_offering: "{{ test_cs_disk_offering_1 }}"
94+
size: 10
95+
shrink_ok: yes
96+
register: vol
97+
check_mode: true
98+
- name: verify results test create volume in check mode
99+
assert:
100+
that:
101+
- vol is changed
102+
- vol.size == 20 * 1024 ** 3
103+
- vol.name == cs_resource_prefix + "_vol"
104+
105+
- name: test shrink volume
106+
ngine_io.cloudstack.volume:
107+
name: "{{ cs_resource_prefix }}_vol"
108+
zone: "{{ cs_common_zone_basic }}"
109+
disk_offering: "{{ test_cs_disk_offering_1 }}"
110+
size: 10
111+
shrink_ok: yes
112+
register: vol
113+
- name: verify results test create volume
114+
assert:
115+
that:
116+
- vol is changed
117+
- vol.size == 10 * 1024 ** 3
118+
- vol.name == cs_resource_prefix + "_vol"
119+
120+
- name: test shrink volume idempotence
121+
ngine_io.cloudstack.volume:
122+
name: "{{ cs_resource_prefix }}_vol"
123+
zone: "{{ cs_common_zone_basic }}"
124+
disk_offering: "{{ test_cs_disk_offering_1 }}"
125+
size: 10
126+
shrink_ok: yes
127+
register: vol
128+
- name: verify results test create volume
129+
assert:
130+
that:
131+
- vol is not changed
132+
- vol.size == 10 * 1024 ** 3
133+
- vol.name == cs_resource_prefix + "_vol"
134+
135+
- name: test attach volume in check mode
136+
ngine_io.cloudstack.volume:
137+
name: "{{ cs_resource_prefix }}_vol"
138+
zone: "{{ cs_common_zone_basic }}"
139+
vm: "{{ test_cs_instance_1 }}"
140+
state: attached
141+
register: vol
142+
check_mode: true
143+
- name: verify results test attach volume in check mode
144+
assert:
145+
that:
146+
- vol is changed
147+
- vol.name == cs_resource_prefix + "_vol"
148+
- vol.attached is not defined
149+
150+
- name: test attach volume
151+
ngine_io.cloudstack.volume:
152+
name: "{{ cs_resource_prefix }}_vol"
153+
zone: "{{ cs_common_zone_basic }}"
154+
vm: "{{ test_cs_instance_1 }}"
155+
state: attached
156+
register: vol
157+
- name: verify results test attach volume
158+
assert:
159+
that:
160+
- vol is changed
161+
- vol.name == cs_resource_prefix + "_vol"
162+
- vol.vm == "{{ test_cs_instance_1 }}"
163+
- vol.attached is defined
164+
165+
- name: test attach volume idempotence
166+
ngine_io.cloudstack.volume:
167+
name: "{{ cs_resource_prefix }}_vol"
168+
zone: "{{ cs_common_zone_basic }}"
169+
vm: "{{ test_cs_instance_1 }}"
170+
state: attached
171+
register: vol
172+
- name: verify results test attach volume idempotence
173+
assert:
174+
that:
175+
- vol is not changed
176+
- vol.name == cs_resource_prefix + "_vol"
177+
- vol.vm == "{{ test_cs_instance_1 }}"
178+
- vol.attached is defined
179+
180+
- name: test attach attached volume to another vm in check mdoe
181+
ngine_io.cloudstack.volume:
182+
name: "{{ cs_resource_prefix }}_vol"
183+
zone: "{{ cs_common_zone_basic }}"
184+
vm: "{{ test_cs_instance_2 }}"
185+
state: attached
186+
register: vol
187+
check_mode: true
188+
- name: verify results test attach attached volume to another vm in check mode
189+
assert:
190+
that:
191+
- vol is changed
192+
- vol.name == cs_resource_prefix + "_vol"
193+
- vol.vm == "{{ test_cs_instance_1 }}"
194+
- vol.attached is defined
195+
196+
- name: test attach attached volume to another vm
197+
ngine_io.cloudstack.volume:
198+
name: "{{ cs_resource_prefix }}_vol"
199+
zone: "{{ cs_common_zone_basic }}"
200+
vm: "{{ test_cs_instance_2 }}"
201+
state: attached
202+
register: vol
203+
- name: verify results test attach attached volume to another vm
204+
assert:
205+
that:
206+
- vol is changed
207+
- vol.name == cs_resource_prefix + "_vol"
208+
- vol.vm == "{{ test_cs_instance_2 }}"
209+
- vol.attached is defined
210+
211+
- name: test attach attached volume to another vm idempotence
212+
ngine_io.cloudstack.volume:
213+
name: "{{ cs_resource_prefix }}_vol"
214+
zone: "{{ cs_common_zone_basic }}"
215+
vm: "{{ test_cs_instance_2 }}"
216+
state: attached
217+
register: vol
218+
- name: verify results test attach attached volume to another vm idempotence
219+
assert:
220+
that:
221+
- vol is not changed
222+
- vol.name == cs_resource_prefix + "_vol"
223+
- vol.vm == "{{ test_cs_instance_2 }}"
224+
- vol.attached is defined
225+
226+
- name: test detach volume in check mode
227+
ngine_io.cloudstack.volume:
228+
name: "{{ cs_resource_prefix }}_vol"
229+
zone: "{{ cs_common_zone_basic }}"
230+
state: detached
231+
register: vol
232+
check_mode: true
233+
- name: verify results test detach volume in check mdoe
234+
assert:
235+
that:
236+
- vol is changed
237+
- vol.name == cs_resource_prefix + "_vol"
238+
- vol.attached is defined
239+
240+
- name: test detach volume
241+
ngine_io.cloudstack.volume:
242+
name: "{{ cs_resource_prefix }}_vol"
243+
zone: "{{ cs_common_zone_basic }}"
244+
state: detached
245+
register: vol
246+
- name: verify results test detach volume
247+
assert:
248+
that:
249+
- vol is changed
250+
- vol.name == cs_resource_prefix + "_vol"
251+
- vol.attached is undefined
252+
253+
- name: test detach volume idempotence
254+
ngine_io.cloudstack.volume:
255+
name: "{{ cs_resource_prefix }}_vol"
256+
zone: "{{ cs_common_zone_basic }}"
257+
state: detached
258+
register: vol
259+
- name: verify results test detach volume idempotence
260+
assert:
261+
that:
262+
- vol is not changed
263+
- vol.name == cs_resource_prefix + "_vol"
264+
- vol.attached is undefined
265+
266+
- name: test delete volume in check mode
267+
ngine_io.cloudstack.volume:
268+
name: "{{ cs_resource_prefix }}_vol"
269+
zone: "{{ cs_common_zone_basic }}"
270+
state: absent
271+
register: vol
272+
check_mode: true
273+
- name: verify results test create volume in check mode
274+
assert:
275+
that:
276+
- vol is changed
277+
- vol.name == cs_resource_prefix + "_vol"
278+
279+
- name: test delete volume
280+
ngine_io.cloudstack.volume:
281+
name: "{{ cs_resource_prefix }}_vol"
282+
zone: "{{ cs_common_zone_basic }}"
283+
state: absent
284+
register: vol
285+
- name: verify results test create volume
286+
assert:
287+
that:
288+
- vol is changed
289+
- vol.name == cs_resource_prefix + "_vol"
290+
291+
- name: test delete volume idempotence
292+
ngine_io.cloudstack.volume:
293+
name: "{{ cs_resource_prefix }}_vol"
294+
zone: "{{ cs_common_zone_basic }}"
295+
state: absent
296+
register: vol
297+
- name: verify results test delete volume idempotence
298+
assert:
299+
that:
300+
- vol is not changed
301+
302+
- name: cleanup instance 1
303+
ngine_io.cloudstack.instance:
304+
name: "{{ test_cs_instance_1 }}"
305+
zone: "{{ cs_common_zone_basic }}"
306+
state: absent
307+
register: instance
308+
- name: verify create instance
309+
assert:
310+
that:
311+
- instance is successful
312+
313+
- name: cleanup instance 2
314+
ngine_io.cloudstack.instance:
315+
name: "{{ test_cs_instance_2 }}"
316+
zone: "{{ cs_common_zone_basic }}"
317+
state: absent
318+
register: instance
319+
- name: verify create instance
320+
assert:
321+
that:
322+
- instance is successful

0 commit comments

Comments
 (0)