2017-11-06 17:28:15 +01:00
|
|
|
# Test code for the vmware_vswitch module.
|
2017-08-24 14:31:13 +02: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)
|
2017-06-30 16:18:20 +02:00
|
|
|
|
2019-05-03 05:19:02 +02:00
|
|
|
- when: vcsim is not defined
|
|
|
|
block:
|
|
|
|
- import_role:
|
|
|
|
name: prepare_vmware_tests
|
|
|
|
vars:
|
|
|
|
setup_attach_host: true
|
|
|
|
|
|
|
|
# TODO: akasurde: VCSIM does not suport network manager system
|
2019-06-08 00:34:20 +02:00
|
|
|
- name: Ensure the vswitch is not already here
|
|
|
|
vmware_vswitch:
|
|
|
|
validate_certs: no
|
|
|
|
hostname: '{{ item.host }}'
|
|
|
|
username: '{{ esxi_user }}'
|
|
|
|
password: '{{ esxi_password }}'
|
|
|
|
switch: '{{ item.switch }}'
|
|
|
|
state: absent
|
|
|
|
with_items:
|
|
|
|
- {host: "{{ esxi1 }}", switch: "vmswitch_0001"}
|
|
|
|
- {host: "{{ esxi2 }}", switch: "vmswitch_0002"}
|
2019-05-03 05:19:02 +02:00
|
|
|
|
|
|
|
- name: Add a nic to a switch
|
|
|
|
vmware_vswitch:
|
2019-05-16 15:36:48 +02:00
|
|
|
hostname: '{{ esxi1 }}'
|
|
|
|
username: '{{ esxi_user }}'
|
|
|
|
password: '{{ esxi_password }}'
|
2019-05-03 05:19:02 +02:00
|
|
|
validate_certs: no
|
|
|
|
switch: vmswitch_0001
|
2019-06-08 00:34:20 +02:00
|
|
|
nics: vmnic1
|
2019-05-03 05:19:02 +02:00
|
|
|
state: present
|
|
|
|
register: add_nic_run
|
2019-06-08 00:34:20 +02:00
|
|
|
- debug: var=add_nic_run
|
2019-05-03 05:19:02 +02:00
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- add_nic_run.changed == true
|
|
|
|
|
|
|
|
- name: Add a nic to a switch again
|
|
|
|
vmware_vswitch:
|
2019-05-16 15:36:48 +02:00
|
|
|
hostname: '{{ esxi1 }}'
|
|
|
|
username: '{{ esxi_user }}'
|
|
|
|
password: '{{ esxi_password }}'
|
2019-05-03 05:19:02 +02:00
|
|
|
validate_certs: no
|
|
|
|
switch: vmswitch_0001
|
2019-06-08 00:34:20 +02:00
|
|
|
nics: vmnic1
|
2019-05-03 05:19:02 +02:00
|
|
|
state: present
|
|
|
|
register: add_nic_again_run
|
|
|
|
- assert:
|
|
|
|
that:
|
|
|
|
- add_nic_again_run.changed == false
|
|
|
|
|
|
|
|
- name: Remove a switch
|
|
|
|
vmware_vswitch:
|
2019-05-16 15:36:48 +02:00
|
|
|
hostname: '{{ esxi1 }}'
|
|
|
|
username: '{{ esxi_user }}'
|
|
|
|
password: '{{ esxi_password }}'
|
2019-05-03 05:19:02 +02:00
|
|
|
validate_certs: no
|
|
|
|
switch: vmswitch_0001
|
|
|
|
state: absent
|
|
|
|
register: remove_nic_run
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-06-08 00:34:20 +02:00
|
|
|
- remove_nic_run is changed
|
2019-05-03 05:19:02 +02:00
|
|
|
|
|
|
|
- name: Remove a switch again
|
|
|
|
vmware_vswitch:
|
2019-05-16 15:36:48 +02:00
|
|
|
hostname: '{{ esxi1 }}'
|
|
|
|
username: '{{ esxi_user }}'
|
|
|
|
password: '{{ esxi_password }}'
|
2019-05-03 05:19:02 +02:00
|
|
|
validate_certs: no
|
|
|
|
switch: vmswitch_0001
|
|
|
|
state: absent
|
|
|
|
register: remove_nic_again_run
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-06-08 00:34:20 +02:00
|
|
|
- not (remove_nic_again_run is changed)
|
2019-05-03 05:19:02 +02:00
|
|
|
|
|
|
|
- name: Add vswitch to a specific host system
|
|
|
|
vmware_vswitch:
|
|
|
|
validate_certs: False
|
2019-06-08 00:34:20 +02:00
|
|
|
hostname: '{{ vcenter_hostname }}'
|
|
|
|
username: '{{ vcenter_username }}'
|
|
|
|
password: '{{ vcenter_password }}'
|
2019-05-03 05:19:02 +02:00
|
|
|
switch: vmswitch_0002
|
2019-06-08 00:34:20 +02:00
|
|
|
nics: vmnic1
|
|
|
|
esxi_hostname: '{{ esxi2 }}'
|
2019-05-03 05:19:02 +02:00
|
|
|
register: add_vswitch_with_host_system
|
|
|
|
- debug: var=add_vswitch_with_host_system
|
|
|
|
- assert:
|
|
|
|
that:
|
2019-06-08 00:34:20 +02:00
|
|
|
- add_vswitch_with_host_system is changed
|