2017-06-30 16:16:48 +02:00
|
|
|
# Test code for the vmware_dvswitch module.
|
2017-11-06 17:28:15 +01:00
|
|
|
# Copyright: (c) 2017, Abhijeet Kasurde <akasurde@redhat.com>
|
|
|
|
# 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
|
2019-05-16 15:36:48 +02:00
|
|
|
vars:
|
|
|
|
setup_datacenter: true
|
2017-06-30 16:16:48 +02:00
|
|
|
|
2019-04-24 19:52:48 +02:00
|
|
|
- &dvs_data
|
2019-05-22 08:10:09 +02:00
|
|
|
name: Add distributed vSwitch
|
2017-06-30 16:16:48 +02:00
|
|
|
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 }}"
|
2017-06-30 16:16:48 +02:00
|
|
|
state: present
|
|
|
|
switch_name: dvswitch_0001
|
|
|
|
mtu: 9000
|
|
|
|
uplink_quantity: 2
|
|
|
|
discovery_proto: lldp
|
|
|
|
discovery_operation: both
|
|
|
|
register: dvs_result_0001
|
|
|
|
|
2019-05-22 08:10:09 +02:00
|
|
|
- name: Ensure distributed vswitch is present
|
2017-06-30 16:16:48 +02:00
|
|
|
assert:
|
|
|
|
that:
|
2019-04-24 19:52:48 +02:00
|
|
|
- dvs_result_0001.changed
|
2017-06-30 16:16:48 +02:00
|
|
|
|
2019-05-16 15:36:48 +02:00
|
|
|
- name: Create a VM folder on given Datacenter
|
|
|
|
vcenter_folder:
|
|
|
|
hostname: '{{ vcenter_hostname }}'
|
|
|
|
username: '{{ vcenter_username }}'
|
|
|
|
password: '{{ vcenter_password }}'
|
|
|
|
datacenter: '{{ dc1 }}'
|
|
|
|
folder_name: network_folder
|
|
|
|
folder_type: network
|
|
|
|
state: present
|
|
|
|
validate_certs: no
|
|
|
|
register:
|
|
|
|
network_folder_result
|
|
|
|
|
2019-05-22 08:10:09 +02:00
|
|
|
- name: Add distributed vSwitch using folder
|
|
|
|
vmware_dvswitch:
|
|
|
|
validate_certs: False
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
2019-05-16 15:36:48 +02:00
|
|
|
folder: "{{ network_folder_result.result.path }}"
|
2019-05-22 08:10:09 +02:00
|
|
|
state: present
|
|
|
|
switch_name: dvswitch_0002
|
|
|
|
mtu: 9000
|
|
|
|
uplink_quantity: 2
|
|
|
|
discovery_proto: lldp
|
|
|
|
discovery_operation: both
|
|
|
|
register: dvs_result_0002
|
|
|
|
|
|
|
|
- name: Ensure distributed vswitch is present
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- dvs_result_0002.changed
|
|
|
|
|
2018-11-30 09:34:43 +01:00
|
|
|
# vcsim doesn't support ldp check (self.dvs.config.linkDiscoveryProtocolConfig.protocol)
|
2019-04-24 19:52:48 +02:00
|
|
|
- when: vcsim is not defined
|
|
|
|
block:
|
|
|
|
- <<: *dvs_data
|
|
|
|
name: add distributed vSwitch again
|
|
|
|
register: dvs_result_0002
|
2017-06-30 16:16:48 +02:00
|
|
|
|
2019-04-24 19:52:48 +02:00
|
|
|
- name: ensure distributed vswitch is present
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- not dvs_result_0002.changed
|
2017-06-30 16:16:48 +02:00
|
|
|
|
2019-04-24 19:52:48 +02:00
|
|
|
# FIXME: Remove this testcase from block once vcsim supports distributed vswitch delete method
|
2017-06-30 16:16:48 +02:00
|
|
|
# Currently, vcsim does not support distributed vswitch delete option,
|
2019-04-24 19:52:48 +02:00
|
|
|
# Once this feature is available we can move this out of this block
|
2017-06-30 16:16:48 +02:00
|
|
|
|
|
|
|
# Testcase 0003: Add Distributed vSwitch
|
2019-04-24 19:52:48 +02:00
|
|
|
- name: delete the distributed vSwitch
|
|
|
|
vmware_dvswitch:
|
|
|
|
validate_certs: False
|
|
|
|
hostname: "{{ vcenter_hostname }}"
|
|
|
|
username: "{{ vcenter_username }}"
|
|
|
|
password: "{{ vcenter_password }}"
|
|
|
|
datacenter_name: "{{ dc1 }}"
|
|
|
|
state: absent
|
|
|
|
switch_name: dvswitch_0001
|
|
|
|
register: dvs_result_0003
|
|
|
|
|
|
|
|
- name: ensure distributed vswitch is present
|
|
|
|
assert:
|
|
|
|
that:
|
|
|
|
- dvs_result_0003.changed
|