2017-11-06 17:46:51 +01:00
|
|
|
# Test code for the vmware_dvs_portgroup module.
|
2019-04-24 19:52:48 +02:00
|
|
|
# Copyright: (c) 2017, Philippe Dellaert <philippe@dellaert.org>
|
|
|
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
2017-11-06 17:46:51 +01:00
|
|
|
|
2019-04-24 19:52:48 +02:00
|
|
|
- import_role:
|
|
|
|
name: prepare_vmware_tests
|
|
|
|
vars:
|
|
|
|
setup_dvswitch: true
|
2017-11-06 17:46:51 +01:00
|
|
|
|
|
|
|
- name: create basic portgroup
|
|
|
|
vmware_dvs_portgroup:
|
|
|
|
validate_certs: False
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
switch_name: "{{ dvswitch1 }}"
|
2017-11-06 17:46:51 +01:00
|
|
|
portgroup_name: "basic"
|
|
|
|
vlan_id: 0
|
|
|
|
num_ports: 32
|
|
|
|
portgroup_type: earlyBinding
|
|
|
|
state: present
|
|
|
|
register: dvs_pg_result_0001
|
|
|
|
|
2019-04-24 19:52:48 +02:00
|
|
|
- debug:
|
|
|
|
var: dvs_pg_result_0001
|
|
|
|
|
2017-11-06 17:46:51 +01:00
|
|
|
- name: ensure dvs portgroup is present
|
|
|
|
assert:
|
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- dvs_pg_result_0001.changed
|
2017-11-06 17:46:51 +01:00
|
|
|
|
|
|
|
- name: create basic VLAN portgroup
|
|
|
|
vmware_dvs_portgroup:
|
|
|
|
validate_certs: False
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
switch_name: "{{ dvswitch1 }}"
|
2017-11-06 17:46:51 +01:00
|
|
|
portgroup_name: "basic-vlan10"
|
|
|
|
vlan_id: 10
|
|
|
|
num_ports: 32
|
|
|
|
portgroup_type: earlyBinding
|
|
|
|
state: present
|
|
|
|
register: dvs_pg_result_0002
|
|
|
|
|
|
|
|
- name: ensure dvs portgroup is present
|
|
|
|
assert:
|
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- dvs_pg_result_0002.changed
|
2017-11-06 17:46:51 +01:00
|
|
|
|
|
|
|
- name: create basic trunk portgroup
|
|
|
|
vmware_dvs_portgroup:
|
|
|
|
validate_certs: False
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
switch_name: "{{ dvswitch1 }}"
|
2017-11-06 17:46:51 +01:00
|
|
|
portgroup_name: "basic-trunk"
|
2019-04-10 04:39:21 +02:00
|
|
|
vlan_id: 1-4094
|
2017-11-06 17:46:51 +01:00
|
|
|
vlan_trunk: True
|
|
|
|
num_ports: 32
|
|
|
|
portgroup_type: earlyBinding
|
|
|
|
state: present
|
|
|
|
register: dvs_pg_result_0003
|
|
|
|
|
|
|
|
- name: ensure dvs portgroup is present
|
|
|
|
assert:
|
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- dvs_pg_result_0003.changed
|
2017-11-06 17:46:51 +01:00
|
|
|
|
|
|
|
- name: create basic portgroup again
|
|
|
|
vmware_dvs_portgroup:
|
|
|
|
validate_certs: False
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
switch_name: "{{ dvswitch1 }}"
|
2017-11-06 17:46:51 +01:00
|
|
|
portgroup_name: "basic"
|
|
|
|
vlan_id: 0
|
|
|
|
num_ports: 32
|
|
|
|
portgroup_type: earlyBinding
|
|
|
|
state: present
|
|
|
|
register: dvs_pg_result_0004
|
|
|
|
|
|
|
|
- name: ensure dvs portgroup is present
|
|
|
|
assert:
|
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- not dvs_pg_result_0004.changed
|
2017-11-06 17:46:51 +01:00
|
|
|
|
|
|
|
- name: create basic portgroup with all security and policy settings enabled
|
|
|
|
vmware_dvs_portgroup:
|
|
|
|
validate_certs: False
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
switch_name: "{{ dvswitch1 }}"
|
2017-11-06 17:46:51 +01:00
|
|
|
portgroup_name: "basic-all-enabled"
|
|
|
|
vlan_id: 0
|
|
|
|
num_ports: 32
|
|
|
|
portgroup_type: earlyBinding
|
|
|
|
state: present
|
2017-11-19 16:01:45 +01:00
|
|
|
network_policy:
|
2017-11-06 17:46:51 +01:00
|
|
|
promiscuous: yes
|
|
|
|
forged_transmits: yes
|
|
|
|
mac_changes: yes
|
|
|
|
port_policy:
|
|
|
|
block_override: yes
|
|
|
|
ipfix_override: yes
|
|
|
|
live_port_move: yes
|
|
|
|
network_rp_override: yes
|
|
|
|
port_config_reset_at_disconnect: yes
|
|
|
|
security_override: yes
|
|
|
|
shaping_override: yes
|
|
|
|
traffic_filter_override: yes
|
|
|
|
uplink_teaming_override: yes
|
|
|
|
vendor_config_override: yes
|
|
|
|
vlan_override: yes
|
|
|
|
register: dvs_pg_result_0005
|
|
|
|
|
|
|
|
- name: ensure dvs portgroup is present
|
|
|
|
assert:
|
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- dvs_pg_result_0005.changed
|
2017-11-06 17:46:51 +01:00
|
|
|
|
|
|
|
- name: create basic portgroup with all security and policy settings enabled
|
|
|
|
vmware_dvs_portgroup:
|
|
|
|
validate_certs: False
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
switch_name: "{{ dvswitch1 }}"
|
2017-11-06 17:46:51 +01:00
|
|
|
portgroup_name: "basic-some-enabled"
|
|
|
|
vlan_id: 0
|
|
|
|
num_ports: 32
|
|
|
|
portgroup_type: earlyBinding
|
|
|
|
state: present
|
2017-11-19 16:01:45 +01:00
|
|
|
network_policy:
|
2017-11-06 17:46:51 +01:00
|
|
|
promiscuous: yes
|
|
|
|
forged_transmits: yes
|
|
|
|
mac_changes: no
|
|
|
|
port_policy:
|
|
|
|
vlan_override: yes
|
|
|
|
register: dvs_pg_result_0006
|
|
|
|
|
|
|
|
- name: ensure dvs portgroup is present
|
|
|
|
assert:
|
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- dvs_pg_result_0006.changed
|
2017-11-06 17:46:51 +01:00
|
|
|
|
|
|
|
- name: delete basic portgroup
|
|
|
|
vmware_dvs_portgroup:
|
|
|
|
validate_certs: False
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
switch_name: "{{ dvswitch1 }}"
|
2017-11-06 17:46:51 +01:00
|
|
|
portgroup_name: "basic"
|
|
|
|
vlan_id: 0
|
|
|
|
num_ports: 32
|
|
|
|
portgroup_type: earlyBinding
|
|
|
|
state: absent
|
|
|
|
register: dvs_pg_result_0007
|
|
|
|
|
|
|
|
- name: ensure dvs portgroup is removed
|
|
|
|
assert:
|
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- dvs_pg_result_0007.changed
|
2017-11-06 17:46:51 +01:00
|
|
|
|
|
|
|
- name: delete basic portgroup again
|
|
|
|
vmware_dvs_portgroup:
|
|
|
|
validate_certs: False
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
switch_name: "{{ dvswitch1 }}"
|
2017-11-06 17:46:51 +01:00
|
|
|
portgroup_name: "basic"
|
|
|
|
vlan_id: 0
|
|
|
|
num_ports: 32
|
|
|
|
portgroup_type: earlyBinding
|
|
|
|
state: absent
|
|
|
|
register: dvs_pg_result_0008
|
|
|
|
|
|
|
|
- name: ensure dvs portgroup is removed
|
|
|
|
assert:
|
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- not dvs_pg_result_0008.changed
|
2019-04-10 04:39:21 +02:00
|
|
|
|
|
|
|
- name: Check valid VLAN id range in DVS Portgroup
|
|
|
|
vmware_dvs_portgroup:
|
|
|
|
validate_certs: False
|
2019-04-24 19:52:48 +02:00
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
switch_name: "{{ dvswitch1 }}"
|
2019-04-10 04:39:21 +02:00
|
|
|
portgroup_name: "basic_trunk_0001"
|
|
|
|
vlan_id: 1-4096
|
|
|
|
vlan_trunk: True
|
|
|
|
num_ports: 32
|
|
|
|
portgroup_type: earlyBinding
|
|
|
|
state: present
|
|
|
|
register: dvs_pg_result_0009
|
|
|
|
ignore_errors: True
|
|
|
|
|
|
|
|
- name: Ensure module fails for invalid VLAN id
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not dvs_pg_result_0009.changed
|
|
|
|
- "'vlan_id range 1-4096 specified is incorrect. The valid vlan_id range is from 0 to 4094.' == '{{ dvs_pg_result_0009.msg }}'"
|