Skip to content

Commit fcbfb39

Browse files
committed
add ip_address
1 parent 8d8e547 commit fcbfb39

File tree

5 files changed

+386
-0
lines changed

5 files changed

+386
-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/group1
3+
cs/group3i
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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
- name: test fail vpc and network mutually exclusive
3+
ngine_io.cloudstack.ip_address:
4+
network: "{{ cs_resource_prefix }}_net_vpc"
5+
vpc: "foobar"
6+
zone: "{{ cs_common_zone_adv }}"
7+
ignore_errors: true
8+
register: ip_address
9+
- name: verify test fail vpc and network mutually exclusive
10+
assert:
11+
that:
12+
- ip_address is failed
13+
- 'ip_address.msg == "parameters are mutually exclusive: vpc|network"'
14+
15+
- name: run test for network setup
16+
import_tasks: network.yml
17+
18+
- name: run test for vpc setup
19+
import_tasks: vpc.yml
Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
---
2+
- name: setup ensure the test network is absent
3+
ngine_io.cloudstack.network:
4+
name: ipaddr_test_network
5+
state: absent
6+
zone: "{{ cs_common_zone_adv }}"
7+
8+
- name: setup create the test network
9+
ngine_io.cloudstack.network:
10+
name: ipaddr_test_network
11+
network_offering: DefaultIsolatedNetworkOfferingWithSourceNatService
12+
state: present
13+
zone: "{{ cs_common_zone_adv }}"
14+
register: base_network
15+
- name: setup verify create the test network
16+
assert:
17+
that:
18+
- base_network is successful
19+
20+
- name: setup instance to get network in implementation state
21+
ngine_io.cloudstack.instance:
22+
name: "{{ cs_resource_prefix }}-vm-cs-ip-address"
23+
template: "{{ cs_common_template }}"
24+
service_offering: "{{ cs_common_service_offering }}"
25+
zone: "{{ cs_common_zone_adv }}"
26+
networks:
27+
- "{{ base_network.name }}"
28+
register: instance
29+
until: instance is success
30+
retries: 20
31+
delay: 5
32+
- name: verify instance setup
33+
assert:
34+
that:
35+
- instance is successful
36+
37+
- name: setup clean ip_address with tags
38+
ngine_io.cloudstack.ip_address:
39+
state: absent
40+
tags:
41+
- key: unique_id
42+
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
43+
network: ipaddr_test_network
44+
zone: "{{ cs_common_zone_adv }}"
45+
46+
- name: setup associate ip_address for SNAT
47+
ngine_io.cloudstack.ip_address:
48+
network: ipaddr_test_network
49+
zone: "{{ cs_common_zone_adv }}"
50+
register: ip_address_snat
51+
52+
- name: test associate ip_address in check mode
53+
ngine_io.cloudstack.ip_address:
54+
network: ipaddr_test_network
55+
zone: "{{ cs_common_zone_adv }}"
56+
check_mode: true
57+
register: ip_address
58+
- name: verify test associate ip_address in check mode
59+
assert:
60+
that:
61+
- ip_address is successful
62+
- ip_address is changed
63+
64+
- name: test associate ip_address
65+
ngine_io.cloudstack.ip_address:
66+
network: ipaddr_test_network
67+
zone: "{{ cs_common_zone_adv }}"
68+
register: ip_address
69+
- name: verify test associate ip_address
70+
assert:
71+
that:
72+
- ip_address is successful
73+
- ip_address is changed
74+
- ip_address.ip_address is defined
75+
76+
- name: test associate ip_address with tags in check mode
77+
ngine_io.cloudstack.ip_address:
78+
network: ipaddr_test_network
79+
tags:
80+
- key: unique_id
81+
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
82+
zone: "{{ cs_common_zone_adv }}"
83+
register: ip_address_tag
84+
check_mode: true
85+
- name: verify test associate ip_address with tags in check mode
86+
assert:
87+
that:
88+
- ip_address_tag is successful
89+
- ip_address_tag is changed
90+
91+
- name: test associate ip_address with tags
92+
ngine_io.cloudstack.ip_address:
93+
network: ipaddr_test_network
94+
tags:
95+
- key: unique_id
96+
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
97+
zone: "{{ cs_common_zone_adv }}"
98+
register: ip_address_tag
99+
- name: verify test associate ip_address with tags
100+
assert:
101+
that:
102+
- ip_address_tag is successful
103+
- ip_address_tag is changed
104+
- ip_address_tag.ip_address is defined
105+
- ip_address_tag.tags.0.key == "unique_id"
106+
- ip_address_tag.tags.0.value == "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
107+
108+
- name: test associate ip_address with tags idempotence
109+
ngine_io.cloudstack.ip_address:
110+
network: ipaddr_test_network
111+
tags:
112+
- key: unique_id
113+
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
114+
zone: "{{ cs_common_zone_adv }}"
115+
register: ip_address_tag
116+
- name: verify test associate ip_address with tags idempotence
117+
assert:
118+
that:
119+
- ip_address_tag is successful
120+
- ip_address_tag is not changed
121+
- ip_address_tag.ip_address is defined
122+
- ip_address_tag.state == "Allocated"
123+
- ip_address_tag.tags.0.key == "unique_id"
124+
- ip_address_tag.tags.0.value == "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
125+
126+
- name: test disassiociate ip_address with missing param ip_address
127+
ngine_io.cloudstack.ip_address:
128+
state: absent
129+
network: ipaddr_test_network
130+
zone: "{{ cs_common_zone_adv }}"
131+
ignore_errors: true
132+
register: ip_address_err
133+
- name: verify test disassiociate ip_address with missing param ip_address
134+
assert:
135+
that:
136+
- ip_address_err is failed
137+
- 'ip_address_err.msg == "state is absent but any of the following are missing: ip_address, tags"'
138+
139+
- name: test disassociate ip_address in check mode
140+
ngine_io.cloudstack.ip_address:
141+
state: absent
142+
ip_address: "{{ ip_address.ip_address }}"
143+
network: ipaddr_test_network
144+
zone: "{{ cs_common_zone_adv }}"
145+
check_mode: true
146+
register: ip_address
147+
- name: verify test disassociate ip_address in check mode
148+
assert:
149+
that:
150+
- ip_address is successful
151+
- ip_address is changed
152+
153+
- name: test disassociate ip_address
154+
ngine_io.cloudstack.ip_address:
155+
state: absent
156+
ip_address: "{{ ip_address.ip_address }}"
157+
network: ipaddr_test_network
158+
zone: "{{ cs_common_zone_adv }}"
159+
register: ip_address
160+
- name: verify test disassociate ip_address
161+
assert:
162+
that:
163+
- ip_address is successful
164+
- ip_address is changed
165+
166+
- name: test disassociate ip_address idempotence
167+
ngine_io.cloudstack.ip_address:
168+
state: absent
169+
ip_address: "{{ ip_address.ip_address }}"
170+
network: ipaddr_test_network
171+
zone: "{{ cs_common_zone_adv }}"
172+
register: ip_address
173+
- name: verify test disassociate ip_address idempotence
174+
assert:
175+
that:
176+
- ip_address is successful
177+
- ip_address is not changed
178+
179+
- name: test disassociate ip_address with tags with check mode
180+
ngine_io.cloudstack.ip_address:
181+
state: absent
182+
tags:
183+
- key: unique_id
184+
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
185+
network: ipaddr_test_network
186+
zone: "{{ cs_common_zone_adv }}"
187+
check_mode: true
188+
register: ip_address
189+
- name: verify test disassociate ip_address with tags in check mode
190+
assert:
191+
that:
192+
- ip_address is successful
193+
- ip_address is changed
194+
195+
- name: test disassociate ip_address with tags
196+
ngine_io.cloudstack.ip_address:
197+
state: absent
198+
tags:
199+
- key: unique_id
200+
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
201+
network: ipaddr_test_network
202+
zone: "{{ cs_common_zone_adv }}"
203+
register: ip_address
204+
- name: verify test disassociate ip_address with tags
205+
assert:
206+
that:
207+
- ip_address is successful
208+
- ip_address is changed
209+
210+
- name: test disassociate ip_address with tags idempotence
211+
ngine_io.cloudstack.ip_address:
212+
state: absent
213+
tags:
214+
- key: unique_id
215+
value: "adacd65e-7868-5ebf-9f8b-e6e0ea779861"
216+
network: ipaddr_test_network
217+
zone: "{{ cs_common_zone_adv }}"
218+
register: ip_address
219+
- name: verify test disassociate ip_address with tags idempotence
220+
assert:
221+
that:
222+
- ip_address is successful
223+
- ip_address is not changed
224+
225+
- name: cleanup instance
226+
ngine_io.cloudstack.instance:
227+
name: "{{ cs_resource_prefix }}-vm-cs-ip-address"
228+
zone: "{{ cs_common_zone_adv }}"
229+
state: expunged
230+
register: instance
231+
- name: verify instance cleanup
232+
assert:
233+
that:
234+
- instance is successful
235+
236+
- name: clean the test network
237+
ngine_io.cloudstack.network:
238+
name: ipaddr_test_network
239+
state: absent
240+
zone: "{{ cs_common_zone_adv }}"
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
---
2+
- name: setup vpc
3+
ngine_io.cloudstack.vpc:
4+
name: "{{ cs_resource_prefix }}_vpc_ip_address"
5+
cidr: 10.10.111.0/16
6+
zone: "{{ cs_common_zone_adv }}"
7+
register: vpc
8+
- name: verify setup vpc
9+
assert:
10+
that:
11+
- vpc is successful
12+
13+
- name: setup clean ip_address with tags
14+
ngine_io.cloudstack.ip_address:
15+
state: absent
16+
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
17+
tags:
18+
- key: unique_id
19+
value: "86cdce4c-dce7-11e8-8394-00262df3bf70"
20+
zone: "{{ cs_common_zone_adv }}"
21+
22+
- name: test associate ip_address in vpc with tags in check mode
23+
ngine_io.cloudstack.ip_address:
24+
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
25+
tags:
26+
- key: unique_id
27+
value: "86cdce4c-dce7-11e8-8394-00262df3bf70"
28+
zone: "{{ cs_common_zone_adv }}"
29+
register: ip_address_tag
30+
check_mode: yes
31+
- name: verify test associate ip_address in vpc with tags in check mode
32+
assert:
33+
that:
34+
- ip_address_tag is successful
35+
- ip_address_tag is changed
36+
37+
- name: test associate ip_address in vpc with tags
38+
ngine_io.cloudstack.ip_address:
39+
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
40+
tags:
41+
- key: unique_id
42+
value: "86cdce4c-dce7-11e8-8394-00262df3bf70"
43+
zone: "{{ cs_common_zone_adv }}"
44+
register: ip_address_tag
45+
- name: verify test associate ip_address in vpc with tags
46+
assert:
47+
that:
48+
- ip_address_tag is successful
49+
- ip_address_tag is changed
50+
- ip_address_tag.ip_address is defined
51+
- ip_address_tag.tags.0.key == "unique_id"
52+
- ip_address_tag.tags.0.value == "86cdce4c-dce7-11e8-8394-00262df3bf70"
53+
54+
- name: test associate ip_address in vpc with tags idempotence
55+
ngine_io.cloudstack.ip_address:
56+
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
57+
tags:
58+
- key: unique_id
59+
value: "86cdce4c-dce7-11e8-8394-00262df3bf70"
60+
zone: "{{ cs_common_zone_adv }}"
61+
register: ip_address_tag
62+
- name: verify test associate ip_address in vpc with tags idempotence
63+
assert:
64+
that:
65+
- ip_address_tag is successful
66+
- ip_address_tag is not changed
67+
- ip_address_tag.ip_address is defined
68+
- ip_address_tag.state == "Allocated"
69+
- ip_address_tag.tags.0.key == "unique_id"
70+
- ip_address_tag.tags.0.value == "86cdce4c-dce7-11e8-8394-00262df3bf70"
71+
72+
- name: test disassociate ip_address in vpc in check mode
73+
ngine_io.cloudstack.ip_address:
74+
state: absent
75+
ip_address: "{{ ip_address_tag.ip_address }}"
76+
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
77+
zone: "{{ cs_common_zone_adv }}"
78+
check_mode: true
79+
register: ip_address
80+
- name: verify test disassociate ip_address in vpc in check mode
81+
assert:
82+
that:
83+
- ip_address is successful
84+
- ip_address is changed
85+
86+
- name: test disassociate ip_address in vpc
87+
ngine_io.cloudstack.ip_address:
88+
state: absent
89+
ip_address: "{{ ip_address_tag.ip_address }}"
90+
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
91+
zone: "{{ cs_common_zone_adv }}"
92+
register: ip_address
93+
- name: verify test disassociate ip_address in vpc
94+
assert:
95+
that:
96+
- ip_address is successful
97+
- ip_address is changed
98+
99+
- name: test disassociate ip_address in vpc idempotence
100+
ngine_io.cloudstack.ip_address:
101+
state: absent
102+
ip_address: "{{ ip_address_tag.ip_address }}"
103+
vpc: "{{ cs_resource_prefix }}_vpc_ip_address"
104+
zone: "{{ cs_common_zone_adv }}"
105+
register: ip_address
106+
- name: verify test disassociate ip_address in vpc idempotence
107+
assert:
108+
that:
109+
- ip_address is successful
110+
- ip_address is not changed
111+
112+
- name: cleanup vpc
113+
ngine_io.cloudstack.vpc:
114+
name: "{{ cs_resource_prefix }}_vpc_ip_address"
115+
zone: "{{ cs_common_zone_adv }}"
116+
state: absent
117+
register: vpc
118+
- name: verify cleanup vpc
119+
assert:
120+
that:
121+
- vpc is successful

0 commit comments

Comments
 (0)