Skip to content

Commit 8e54e67

Browse files
committed
add instance_info
1 parent 5e242d4 commit 8e54e67

File tree

4 files changed

+101
-0
lines changed

4 files changed

+101
-0
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
cloud/cs
2+
shippable/cs/group1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
test_cs_instance_template: "{{ cs_common_template }}"
3+
test_cs_instance_offering_1: Small Instance
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: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
---
2+
- name: setup ssh key
3+
ngine_io.cloudstack.ssh_key:
4+
name: "{{ cs_resource_prefix }}-sshkey"
5+
register: sshkey
6+
7+
- name: setup affinity group
8+
ngine_io.cloudstack.affinity_group:
9+
name: "{{ cs_resource_prefix }}-ag"
10+
11+
- name: setup security group
12+
ngine_io.cloudstack.security_group:
13+
name: "{{ cs_resource_prefix }}-sg"
14+
15+
- name: setup instance
16+
ngine_io.cloudstack.instance:
17+
name: "{{ cs_resource_prefix }}-vm"
18+
template: "{{ test_cs_instance_template }}"
19+
service_offering: "{{ test_cs_instance_offering_1 }}"
20+
affinity_group: "{{ cs_resource_prefix }}-ag"
21+
security_group: "{{ cs_resource_prefix }}-sg"
22+
ssh_key: "{{ cs_resource_prefix }}-sshkey"
23+
tags: []
24+
zone: "{{ cs_common_zone_basic }}"
25+
register: instance
26+
until: instance is successful
27+
retries: 20
28+
delay: 5
29+
30+
- name: test instance info in check mode
31+
ngine_io.cloudstack.instance_info:
32+
name: "{{ cs_resource_prefix }}-vm"
33+
register: instance_info
34+
check_mode: true
35+
- name: verify test instance info in check mode
36+
assert:
37+
that:
38+
- instance_info is successful
39+
- instance_info is not changed
40+
- instance_info.instances[0].id == instance.id
41+
- instance_info.instances[0].domain == instance.domain
42+
- instance_info.instances[0].account == instance.account
43+
- instance_info.instances[0].zone == instance.zone
44+
- instance_info.instances[0].name == instance.name
45+
- instance_info.instances[0].service_offering == instance.service_offering
46+
- instance_info.instances[0].host != ""
47+
48+
- name: test instance info
49+
ngine_io.cloudstack.instance_info:
50+
name: "{{ cs_resource_prefix }}-vm"
51+
register: instance_info
52+
- name: verify test instance info
53+
assert:
54+
that:
55+
- instance_info is successful
56+
- instance_info is not changed
57+
- instance_info.instances[0].id == instance.id
58+
- instance_info.instances[0].domain == instance.domain
59+
- instance_info.instances[0].account == instance.account
60+
- instance_info.instances[0].zone == instance.zone
61+
- instance_info.instances[0].name == instance.name
62+
- instance_info.instances[0].service_offering == instance.service_offering
63+
- instance_info.instances[0].host != ""
64+
65+
- name: test instance info for all instances
66+
ngine_io.cloudstack.instance_info:
67+
register: instance_info
68+
- name: verify test instance info
69+
assert:
70+
that:
71+
- instance_info is successful
72+
- instance_info is not changed
73+
- instance_info.instances | length > 0
74+
- '"id" in instance_info.instances[0]'
75+
- '"domain" in instance_info.instances[0]'
76+
- '"account" in instance_info.instances[0]'
77+
- '"zone" in instance_info.instances[0]'
78+
- '"name" in instance_info.instances[0]'
79+
- '"service_offering" in instance_info.instances[0]'
80+
- '"host" in instance_info.instances[0]'
81+
82+
- name: remember host
83+
set_fact:
84+
host: "{{ instance_info.instances[0]['host']}}"
85+
86+
- name: test instance info for all instances of a host
87+
ngine_io.cloudstack.instance_info:
88+
host: "{{ host }}"
89+
register: instance_info
90+
- name: verify test instance info
91+
assert:
92+
that:
93+
- instance_info.instances[0]['host'] == host

0 commit comments

Comments
 (0)