| 1 |
# Test code for the vmware_portgroup module. |
| 2 |
# Copyright: (c) 2018, Abhijeet Kasurde <[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 |
setup_attach_host: true |
| 10 |
setup_cluster: true |
| 11 |
setup_switch: true |
| 12 |
|
| 13 |
- name: Create portgroup without Portgroup and vSwitch |
| 14 |
vmware_portgroup: |
| 15 |
hostname: '{{ vcenter_hostname }}' |
| 16 |
username: '{{ vcenter_username }}' |
| 17 |
password: '{{ vcenter_password }}' |
| 18 |
validate_certs: false |
| 19 |
ignore_errors: true |
| 20 |
register: no_pg_vs |
| 21 |
|
| 22 |
- assert: |
| 23 |
that: |
| 24 |
- '"missing" in no_pg_vs.msg' |
| 25 |
|
| 26 |
- name: Create portgroup without Portgroup |
| 27 |
vmware_portgroup: |
| 28 |
hostname: '{{ vcenter_hostname }}' |
| 29 |
username: '{{ vcenter_username }}' |
| 30 |
password: '{{ vcenter_password }}' |
| 31 |
vswitch: '' |
| 32 |
validate_certs: false |
| 33 |
ignore_errors: true |
| 34 |
register: no_vs |
| 35 |
|
| 36 |
- assert: |
| 37 |
that: |
| 38 |
- '"missing" in no_vs.msg' |
| 39 |
|
| 40 |
- name: Create portgroup without cluster |
| 41 |
vmware_portgroup: |
| 42 |
hostname: '{{ vcenter_hostname }}' |
| 43 |
username: '{{ vcenter_username }}' |
| 44 |
password: '{{ vcenter_password }}' |
| 45 |
vswitch: '{{ switch1 }}' |
| 46 |
portgroup: 'pg_03' |
| 47 |
validate_certs: false |
| 48 |
ignore_errors: true |
| 49 |
register: no_cluster |
| 50 |
|
| 51 |
- assert: |
| 52 |
that: |
| 53 |
- '"cluster_name" in no_cluster.msg' |
| 54 |
|
| 55 |
- name: Create portgroup |
| 56 |
vmware_portgroup: |
| 57 |
hostname: '{{ vcenter_hostname }}' |
| 58 |
username: '{{ vcenter_username }}' |
| 59 |
password: '{{ vcenter_password }}' |
| 60 |
vswitch: '{{ switch1 }}' |
| 61 |
portgroup: 'pg_03' |
| 62 |
cluster_name: "{{ ccr1 }}" |
| 63 |
validate_certs: false |
| 64 |
state: present |
| 65 |
ignore_errors: true |
| 66 |
register: pg_info |
| 67 |
|
| 68 |
- assert: |
| 69 |
that: |
| 70 |
- pg_info.changed |
| 71 |
|
| 72 |
- name: Create portgroup with traffic shaping |
| 73 |
vmware_portgroup: |
| 74 |
hostname: '{{ vcenter_hostname }}' |
| 75 |
username: '{{ vcenter_username }}' |
| 76 |
password: '{{ vcenter_password }}' |
| 77 |
vswitch: '{{ switch1 }}' |
| 78 |
portgroup: 'pg_ts' |
| 79 |
cluster_name: "{{ ccr1 }}" |
| 80 |
traffic_shaping: |
| 81 |
enabled: true |
| 82 |
average_bandwidth: 100000 |
| 83 |
peak_bandwidth: 100000 |
| 84 |
burst_size: 102400 |
| 85 |
validate_certs: false |
| 86 |
state: present |
| 87 |
register: create_portgroup_with_traffic_shaping_result |
| 88 |
|
| 89 |
- assert: |
| 90 |
that: |
| 91 |
- create_portgroup_with_traffic_shaping_result.changed |
| 92 |
|
| 93 |
# Issue 955 |
| 94 |
- name: Disable traffic shaping |
| 95 |
vmware_portgroup: |
| 96 |
hostname: '{{ vcenter_hostname }}' |
| 97 |
username: '{{ vcenter_username }}' |
| 98 |
password: '{{ vcenter_password }}' |
| 99 |
vswitch: '{{ switch1 }}' |
| 100 |
portgroup: 'pg_ts' |
| 101 |
cluster_name: "{{ ccr1 }}" |
| 102 |
traffic_shaping: |
| 103 |
enabled: false |
| 104 |
validate_certs: false |
| 105 |
state: present |
| 106 |
register: disable_traffic_shaping_result |
| 107 |
|
| 108 |
- assert: |
| 109 |
that: |
| 110 |
- disable_traffic_shaping_result.changed |
| 111 |
|
| 112 |
- name: Integration test a PortGroup name with special characters |
| 113 |
block: |
| 114 |
- name: Create Switch with special characters |
| 115 |
vmware_vswitch: |
| 116 |
hostname: "{{ vcenter_hostname }}" |
| 117 |
username: "{{ vcenter_username }}" |
| 118 |
password: "{{ vcenter_password }}" |
| 119 |
validate_certs: false |
| 120 |
esxi_hostname: "{{ esxi1 }}" |
| 121 |
switch: 'Switch\%' |
| 122 |
state: present |
| 123 |
register: create_switch_with_special_characters_result |
| 124 |
|
| 125 |
- assert: |
| 126 |
that: |
| 127 |
- create_switch_with_special_characters_result.changed is sameas true |
| 128 |
|
| 129 |
- name: Create PortGroup with special characters |
| 130 |
vmware_portgroup: |
| 131 |
hostname: "{{ vcenter_hostname }}" |
| 132 |
username: "{{ vcenter_username }}" |
| 133 |
password: "{{ vcenter_password }}" |
| 134 |
validate_certs: false |
| 135 |
hosts: "{{ esxi1 }}" |
| 136 |
switch: 'Switch\%' |
| 137 |
portgroup: 'PortGroup\%' |
| 138 |
security: |
| 139 |
promiscuous_mode: false |
| 140 |
mac_changes: false |
| 141 |
forged_transmits: false |
| 142 |
state: present |
| 143 |
register: create_portgroup_with_special_characters_result |
| 144 |
|
| 145 |
- assert: |
| 146 |
that: |
| 147 |
- create_portgroup_with_special_characters_result.changed is sameas true |
| 148 |
|
| 149 |
- name: Create PortGroup with special characters(idempotency check) |
| 150 |
vmware_portgroup: |
| 151 |
hostname: "{{ vcenter_hostname }}" |
| 152 |
username: "{{ vcenter_username }}" |
| 153 |
password: "{{ vcenter_password }}" |
| 154 |
validate_certs: false |
| 155 |
hosts: "{{ esxi1 }}" |
| 156 |
switch: 'Switch\%' |
| 157 |
portgroup: 'PortGroup\%' |
| 158 |
security: |
| 159 |
promiscuous_mode: false |
| 160 |
mac_changes: false |
| 161 |
forged_transmits: false |
| 162 |
state: present |
| 163 |
register: create_portgroup_with_special_characters_idempotency_check_result |
| 164 |
|
| 165 |
- assert: |
| 166 |
that: |
| 167 |
- create_portgroup_with_special_characters_idempotency_check_result.changed is sameas false |
| 168 |
|
| 169 |
- name: Delete PortGroup with special characters |
| 170 |
vmware_portgroup: |
| 171 |
hostname: "{{ vcenter_hostname }}" |
| 172 |
username: "{{ vcenter_username }}" |
| 173 |
password: "{{ vcenter_password }}" |
| 174 |
validate_certs: false |
| 175 |
hosts: "{{ esxi1 }}" |
| 176 |
switch: 'Switch\%' |
| 177 |
portgroup: 'PortGroup\%' |
| 178 |
state: absent |
| 179 |
register: delete_portgroup_with_special_characters_result |
| 180 |
|
| 181 |
- assert: |
| 182 |
that: |
| 183 |
- delete_portgroup_with_special_characters_result.changed is sameas true |
| 184 |
|
| 185 |
- name: Delete PortGroup with special characters(idempotency check) |
| 186 |
vmware_portgroup: |
| 187 |
hostname: "{{ vcenter_hostname }}" |
| 188 |
username: "{{ vcenter_username }}" |
| 189 |
password: "{{ vcenter_password }}" |
| 190 |
validate_certs: false |
| 191 |
hosts: "{{ esxi1 }}" |
| 192 |
switch: 'Switch\%' |
| 193 |
portgroup: 'PortGroup\%' |
| 194 |
state: absent |
| 195 |
register: delete_portgroup_with_special_characters_idempotency_check_result |
| 196 |
|
| 197 |
- assert: |
| 198 |
that: |
| 199 |
- delete_portgroup_with_special_characters_idempotency_check_result.changed is sameas false |
| 200 |
|
| 201 |
- name: Delete Switch with special characters |
| 202 |
vmware_vswitch: |
| 203 |
hostname: "{{ vcenter_hostname }}" |
| 204 |
username: "{{ vcenter_username }}" |
| 205 |
password: "{{ vcenter_password }}" |
| 206 |
validate_certs: false |
| 207 |
esxi_hostname: "{{ esxi1 }}" |
| 208 |
switch: 'Switch\%' |
| 209 |
state: absent |
| 210 |
register: delete_switch_with_special_characters_result |
| 211 |
|
| 212 |
- assert: |
| 213 |
that: |
| 214 |
- delete_switch_with_special_characters_result.changed is sameas true |