2018-12-12 10:13:54 +01:00
|
|
|
# Test code for the vmware_dvswitch_pvlans module.
|
|
|
|
# Copyright: (c) 2018, Christian Kotte <christian.kotte@gmx.de>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
|
2019-04-24 19:52:48 +02:00
|
|
|
- import_role:
|
|
|
|
name: prepare_vmware_tests
|
2018-12-12 10:13:54 +01:00
|
|
|
|
|
|
|
# Testcase 0001: Add Distributed vSwitch
|
|
|
|
- name: add distributed vSwitch
|
|
|
|
vmware_dvswitch:
|
|
|
|
validate_certs: False
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
datacenter_name: "{{ dc1 }}"
|
2018-12-12 10:13:54 +01:00
|
|
|
state: present
|
|
|
|
switch_name: dvswitch_0001
|
|
|
|
mtu: 9000
|
|
|
|
uplink_quantity: 2
|
|
|
|
discovery_proto: lldp
|
|
|
|
discovery_operation: both
|
|
|
|
register: dvs_result_0001
|
|
|
|
|
|
|
|
- debug:
|
2019-04-24 19:52:48 +02:00
|
|
|
var: dvs_result_0001
|
2018-12-12 10:13:54 +01:00
|
|
|
|
2019-04-24 19:52:48 +02:00
|
|
|
- name: ensure distributed vswitch is present
|
|
|
|
assert:
|
2018-12-12 10:13:54 +01:00
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- dvs_result_0001 is changed
|
2018-12-12 10:13:54 +01:00
|
|
|
|
2019-04-24 19:52:48 +02:00
|
|
|
- &pv_data
|
|
|
|
name: Configure PVLANs
|
2018-12-12 10:13:54 +01:00
|
|
|
vmware_dvswitch_pvlans:
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
2018-12-12 10:13:54 +01:00
|
|
|
switch: dvswitch_0001
|
|
|
|
primary_pvlans:
|
|
|
|
- primary_pvlan_id: 1
|
|
|
|
- primary_pvlan_id: 4
|
|
|
|
secondary_pvlans:
|
|
|
|
- primary_pvlan_id: 1
|
|
|
|
secondary_pvlan_id: 2
|
|
|
|
pvlan_type: isolated
|
|
|
|
- primary_pvlan_id: 1
|
|
|
|
secondary_pvlan_id: 3
|
|
|
|
pvlan_type: community
|
|
|
|
- primary_pvlan_id: 4
|
|
|
|
secondary_pvlan_id: 5
|
|
|
|
pvlan_type: community
|
|
|
|
validate_certs: no
|
2019-04-24 19:52:48 +02:00
|
|
|
register: pvlans_result
|
|
|
|
|
|
|
|
- debug:
|
|
|
|
var: pvlans_result
|
2018-12-12 10:13:54 +01:00
|
|
|
|
|
|
|
- name: ensure pvlans were configured
|
|
|
|
assert:
|
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- pvlans_result is changed
|
2018-12-12 10:13:54 +01:00
|
|
|
|
2019-05-16 15:36:48 +02:00
|
|
|
- when: vcsim is not defined
|
|
|
|
block:
|
|
|
|
- <<: *pv_data
|
|
|
|
name: Configure PVLANs in check mode
|
|
|
|
register: pvlans_result_check_mode
|
|
|
|
check_mode: yes
|
|
|
|
- debug:
|
|
|
|
var: pvlans_result_check_mode
|
|
|
|
- name: ensure pvlans were not changed
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not (pvlans_result_check_mode is changed)
|