Debian Codegraph @

ansible_collections/community/vmware/tests/integration/targets/vmware_dvswitch_info/tasks/main.yml

raw
1 # Test code for the vmware_dvswitch_info module.
2 # Copyright: (c) 2020, sky-joker <[email protected]>
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 - import_role:
6 name: prepare_vmware_tests
7 vars:
8 setup_datacenter: true
9
10 - name: add distributed vSwitch
11 vmware_dvswitch:
12 hostname: "{{ vcenter_hostname }}"
13 username: "{{ vcenter_username }}"
14 password: "{{ vcenter_password }}"
15 validate_certs: false
16 datacenter_name: "{{ dc1 }}"
17 switch_name: "{{ dvswitch1 }}"
18 mtu: 9000
19 uplink_quantity: 2
20 discovery_proto: lldp
21 discovery_operation: both
22 state: present
23 register: add_distributed_vswitch_result
24
25 - assert:
26 that:
27 - add_distributed_vswitch_result.changed
28
29 - name: get list of info about dvswitches - check_mode is enabled
30 vmware_dvswitch_info:
31 hostname: "{{ vcenter_hostname }}"
32 username: "{{ vcenter_username }}"
33 password: "{{ vcenter_password }}"
34 validate_certs: false
35 switch_name: "{{ dvswitch1 }}"
36 check_mode: true
37 register: info_dvswitches_result
38
39 - debug: var=info_dvswitches_result
40
41 - assert:
42 that:
43 - info_dvswitches_result.distributed_virtual_switches.0.configure.folder is defined
44 - info_dvswitches_result.distributed_virtual_switches.0.configure.hosts is defined
45 - info_dvswitches_result.distributed_virtual_switches.0.configure.settings is defined
46
47 - name: get list of info about all dvswitches
48 vmware_dvswitch_info:
49 hostname: "{{ vcenter_hostname }}"
50 username: "{{ vcenter_username }}"
51 password: "{{ vcenter_password }}"
52 validate_certs: false
53 register: info_dvswitches_result
54
55 - debug: var=info_dvswitches_result
56
57 - assert:
58 that:
59 - info_dvswitches_result.distributed_virtual_switches | length == 1
60 - info_dvswitches_result.distributed_virtual_switches.0.configure.folder is defined
61 - info_dvswitches_result.distributed_virtual_switches.0.configure.hosts is defined
62 - info_dvswitches_result.distributed_virtual_switches.0.configure.settings is defined
63
64 - name: get list of info about dvswitches
65 vmware_dvswitch_info:
66 hostname: "{{ vcenter_hostname }}"
67 username: "{{ vcenter_username }}"
68 password: "{{ vcenter_password }}"
69 validate_certs: false
70 switch_name: "{{ dvswitch1 }}"
71 register: info_dvswitches_result
72
73 - debug: var=info_dvswitches_result
74
75 - assert:
76 that:
77 - info_dvswitches_result.distributed_virtual_switches.0.configure.folder is defined
78 - info_dvswitches_result.distributed_virtual_switches.0.configure.hosts is defined
79 - info_dvswitches_result.distributed_virtual_switches.0.configure.settings is defined
80
81 - name: get list of info about dvswitches - add folder param
82 vmware_dvswitch_info:
83 hostname: "{{ vcenter_hostname }}"
84 username: "{{ vcenter_username }}"
85 password: "{{ vcenter_password }}"
86 validate_certs: false
87 folder: "{{ dc1 }}/network"
88 switch_name: "{{ dvswitch1 }}"
89 register: info_dvswitches_result
90
91 - debug: var=info_dvswitches_result
92
93 - assert:
94 that:
95 - info_dvswitches_result.distributed_virtual_switches.0.configure.folder is defined
96 - info_dvswitches_result.distributed_virtual_switches.0.configure.hosts is defined
97 - info_dvswitches_result.distributed_virtual_switches.0.configure.settings is defined
98
99 - name: get list of info about one dvswitches with properties specify
100 vmware_dvswitch_info:
101 hostname: "{{ vcenter_hostname }}"
102 username: "{{ vcenter_username }}"
103 password: "{{ vcenter_password }}"
104 validate_certs: false
105 switch_name: "{{ dvswitch1 }}"
106 schema: vsphere
107 properties:
108 - name
109 register: info_dvswitches_with_properties_result
110
111 - debug: var=info_dvswitches_with_properties_result
112
113 - assert:
114 that:
115 - info_dvswitches_with_properties_result.distributed_virtual_switches.0.name is defined
116 - info_dvswitches_with_properties_result.distributed_virtual_switches.0.name == dvswitch1
117
118 - name: get list of info about one dvswitches with properties specify - add folder param
119 vmware_dvswitch_info:
120 hostname: "{{ vcenter_hostname }}"
121 username: "{{ vcenter_username }}"
122 password: "{{ vcenter_password }}"
123 validate_certs: false
124 folder: "{{ dc1 }}/network"
125 switch_name: "{{ dvswitch1 }}"
126 schema: vsphere
127 properties:
128 - name
129 register: info_dvswitches_with_properties_result
130
131 - debug: var=info_dvswitches_with_properties_result
132
133 - assert:
134 that:
135 - info_dvswitches_with_properties_result.distributed_virtual_switches.0.name is defined
136
137 - name: get list of info about dvswitches with multiple properties specify
138 vmware_dvswitch_info:
139 hostname: "{{ vcenter_hostname }}"
140 username: "{{ vcenter_username }}"
141 password: "{{ vcenter_password }}"
142 validate_certs: false
143 switch_name: "{{ dvswitch1 }}"
144 schema: vsphere
145 properties:
146 - name
147 - summary.numPorts
148 - config.maxMtu
149 register: info_dvswitches_with_properties_result
150
151 - debug: var=info_dvswitches_with_properties_result
152
153 - assert:
154 that:
155 - info_dvswitches_with_properties_result.distributed_virtual_switches.0.name is defined
156 - info_dvswitches_with_properties_result.distributed_virtual_switches.0.summary.numPorts is defined
157 - info_dvswitches_with_properties_result.distributed_virtual_switches.0.config.maxMtu is defined
158
159 - name: get list of info about dvswitches with multiple properties specify - add folder param
160 vmware_dvswitch_info:
161 hostname: "{{ vcenter_hostname }}"
162 username: "{{ vcenter_username }}"
163 password: "{{ vcenter_password }}"
164 validate_certs: false
165 folder: "{{ dc1 }}/network"
166 switch_name: "{{ dvswitch1 }}"
167 schema: vsphere
168 properties:
169 - name
170 - summary.numPorts
171 - config.maxMtu
172 register: info_dvswitches_with_properties_result
173
174 - debug: var=info_dvswitches_with_properties_result
175
176 - assert:
177 that:
178 - info_dvswitches_with_properties_result.distributed_virtual_switches.0.name is defined
179 - info_dvswitches_with_properties_result.distributed_virtual_switches.0.summary.numPorts is defined
180 - info_dvswitches_with_properties_result.distributed_virtual_switches.0.config.maxMtu is defined
181
182 - name: delete distributed vSwitch
183 vmware_dvswitch:
184 hostname: "{{ vcenter_hostname }}"
185 username: "{{ vcenter_username }}"
186 password: "{{ vcenter_password }}"
187 validate_certs: false
188 datacenter_name: "{{ dc1 }}"
189 switch_name: "{{ dvswitch1 }}"
190 state: absent
191 register: delete_distributed_vswitch_result
192
193 - assert:
194 that:
195 - delete_distributed_vswitch_result.changed
196
197 - name: get list of info about all dvswitches
198 vmware_dvswitch_info:
199 hostname: "{{ vcenter_hostname }}"
200 username: "{{ vcenter_username }}"
201 password: "{{ vcenter_password }}"
202 validate_certs: false
203 register: info_dvswitches_result
204
205 - assert:
206 that:
207 - info_dvswitches_result.distributed_virtual_switches | length == 0
208
209 - name: get list of when not exist the dvswitch
210 vmware_dvswitch_info:
211 hostname: "{{ vcenter_hostname }}"
212 username: "{{ vcenter_username }}"
213 password: "{{ vcenter_password }}"
214 validate_certs: false
215 switch_name: "not_exist_the_dvswitch"
216 register: info_dvswitches_result
217
218 - assert:
219 that:
220 - info_dvswitches_result.distributed_virtual_switches | length == 0