summaryrefslogtreecommitdiffstats
path: root/ansible_collections/community/vmware/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-18 05:52:35 +0000
commit7fec0b69a082aaeec72fee0612766aa42f6b1b4d (patch)
treeefb569b86ca4da888717f5433e757145fa322e08 /ansible_collections/community/vmware/tests
parentReleasing progress-linux version 7.7.0+dfsg-3~progress7.99u1. (diff)
downloadansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.tar.xz
ansible-7fec0b69a082aaeec72fee0612766aa42f6b1b4d.zip
Merging upstream version 9.4.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'ansible_collections/community/vmware/tests')
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_root_password_expiration/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vcenter_root_password_expiration/tasks/main.yml23
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/tasks/main.yml4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_test.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/tasks/main.yml4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk_info/tasks/main.yml96
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/tasks/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f0.yml16
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/check_mode.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_with_convert.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/windows_vbs_d1_c1_f0.yml4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/tasks/main.yml8
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/tasks/main.yml28
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/tasks/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/tasks/main.yml22
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/tasks/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/tasks/main.yml105
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/tasks/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/tasks/main.yml41
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance_info/aliases3
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance_info/tasks/main.yml22
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/main.yml4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/aliases2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/tasks/main.yml131
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/main.yml6
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/main.yml2
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/main.yml4
-rw-r--r--ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/prepare_environment.yml2
-rw-r--r--ansible_collections/community/vmware/tests/sanity/ignore-2.13.txt2
-rw-r--r--ansible_collections/community/vmware/tests/sanity/ignore-2.14.txt2
-rw-r--r--ansible_collections/community/vmware/tests/sanity/ignore-2.15.txt2
-rw-r--r--ansible_collections/community/vmware/tests/sanity/ignore-2.16.txt4
-rw-r--r--ansible_collections/community/vmware/tests/sanity/ignore-2.17.txt4
-rw-r--r--ansible_collections/community/vmware/tests/unit/compat/__init__.py0
-rw-r--r--ansible_collections/community/vmware/tests/unit/compat/mock.py122
-rw-r--r--ansible_collections/community/vmware/tests/unit/compat/unittest.py38
-rw-r--r--ansible_collections/community/vmware/tests/unit/mock/path.py3
-rw-r--r--ansible_collections/community/vmware/tests/unit/mock/procenv.py2
-rw-r--r--ansible_collections/community/vmware/tests/unit/module_utils/test_vmware.py11
-rw-r--r--ansible_collections/community/vmware/tests/unit/modules/cloud/vmware/test_vmware_host_sriov.py8
-rw-r--r--ansible_collections/community/vmware/tests/unit/modules/utils.py5
46 files changed, 520 insertions, 240 deletions
diff --git a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml
index 5506fb132..2b2b39285 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/prepare_vmware_tests/tasks/setup_virtualmachines.yml
@@ -16,6 +16,8 @@
scsi: paravirtual
version: 11
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
networks:
@@ -40,6 +42,8 @@
num_cpus: 1
scsi: paravirtual
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
networks:
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_root_password_expiration/aliases b/ansible_collections/community/vmware/tests/integration/targets/vcenter_root_password_expiration/aliases
new file mode 100644
index 000000000..b1682114e
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_root_password_expiration/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_only
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vcenter_root_password_expiration/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vcenter_root_password_expiration/tasks/main.yml
new file mode 100644
index 000000000..e80baf9c9
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vcenter_root_password_expiration/tasks/main.yml
@@ -0,0 +1,23 @@
+# Test code for the vcenter_root_password_expiration module.
+# Copyright: (c) 2023, Mario Lenz <m@riolenz.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+
+- name: Set vCenter root password expiration
+ vcenter_root_password_expiration:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ state: present
+ email: "vCenter-Admin@community.vmware.example"
+ max_days_between_password_change: 93
+ min_days_between_password_change: 7
+ warn_days_before_password_expiration: 22
+ validate_certs: false
+ register: pw_expiration
+
+- assert:
+ that:
+ - pw_expiration is changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/tasks/main.yml
index 94a9941d8..d5f09d6ef 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_about_info/tasks/main.yml
@@ -15,7 +15,7 @@
- assert:
that:
- - about.about_info["{{ item }}"] is defined
+ - about.about_info[item] is defined
with_items:
- api_type
- api_version
@@ -40,7 +40,7 @@
- assert:
that:
- - about.about_info["{{ item }}"] is defined
+ - about.about_info[item] is defined
with_items:
- api_type
- api_version
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_test.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_test.yml
index 3069f15dd..14c9c5d01 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_test.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/associable_obj_test.yml
@@ -35,4 +35,4 @@
- name: Check if we get correct associable datatype for {{ category_name }}
assert:
that:
- - "'{{ expected_result }}' in {{ category_datatype }}" \ No newline at end of file
+ - "expected_result in category_datatype"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/main.yml
index 598e9da46..128f7a37f 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_category/tasks/main.yml
@@ -4,4 +4,4 @@
- import_role:
name: prepare_vmware_tests
-- include: associable_obj_types.yml
+- include_tasks: associable_obj_types.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/tasks/main.yml
index 8e6119f45..8d45b2e28 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_dvs_portgroup/tasks/main.yml
@@ -407,7 +407,7 @@
assert:
that:
- not dvs_pg_result_0013.changed
- - "'vlan_id range 1-4096 specified is incorrect. The valid vlan_id range is from 0 to 4094.' == '{{ dvs_pg_result_0013.msg }}'"
+ - "'vlan_id range 1-4096 specified is incorrect. The valid vlan_id range is from 0 to 4094.' == dvs_pg_result_0013.msg"
- name: Change VLAN on basic VLAN portgroup
community.vmware.vmware_dvs_portgroup:
@@ -508,7 +508,7 @@
assert:
that:
- not dvs_pg_result_0018.changed
- - "'No private vlan with id 10 in distributed vSwitch {{ dvswitch1 }}' == '{{ dvs_pg_result_0018.msg }}'"
+ - "'No private vlan with id 10 in distributed vSwitch {{ dvswitch1 }}' == dvs_pg_result_0018.msg"
- name: Run tests and clean up
block:
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk_info/aliases
new file mode 100644
index 000000000..07e8732a3
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk_info/tasks/main.yml
new file mode 100644
index 000000000..da18648c5
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_first_class_disk_info/tasks/main.yml
@@ -0,0 +1,96 @@
+# Test code for the vmware_first_class_disk_info module.
+# Copyright: (c) 2021, Mario Lenz <m@riolenz.de>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+ setup_datastore: true
+
+- name: Gather Info if no first-class disk exists
+ vmware_first_class_disk_info: &disk_info
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datastore_name: "{{ rw_datastore }}"
+ validate_certs: false
+ register: disk_info
+ delegate_to: localhost
+
+- debug:
+ var: disk_info
+
+- assert:
+ that:
+ - "disk_info['first_class_disks'] == []"
+
+- name: Create first-class disk through vCenter
+ vmware_first_class_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ disk_name: "firstclassdisk"
+ size: 1GB
+ datastore_name: "{{ rw_datastore }}"
+ state: present
+ validate_certs: false
+
+- name: Gather Info of the generated first-class disk
+ vmware_first_class_disk_info:
+ <<: *disk_info
+ register: disk_info
+
+- name: assert for first-class disk info
+ assert:
+ that:
+ - "(disk_info['first_class_disks'] | length) == 1"
+ - "disk_info['first_class_disks'][0]['name'] == 'firstclassdisk'"
+ - "disk_info['first_class_disks'][0]['datastore_name'] == rw_datastore"
+ - "disk_info['first_class_disks'][0]['size_mb'] == 1024"
+ - "disk_info['first_class_disks'][0]['consumption_type'] is defined"
+ - "disk_info['first_class_disks'][0]['descriptor_version'] is defined"
+ - "disk_info['first_class_disks'][0]['consumer_ids'] is defined"
+
+- name: Create a second first-class disk through vCenter
+ vmware_first_class_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ disk_name: "secondclassdisk"
+ size: 1GB
+ datastore_name: "{{ rw_datastore }}"
+ state: present
+ validate_certs: false
+
+- name: Gather Info of the two generated first-class disk
+ vmware_first_class_disk_info:
+ <<: *disk_info
+ register: disk_info
+
+- name: assert for first-class disk info
+ assert:
+ that:
+ - "(disk_info['first_class_disks'] | length) == 2"
+
+- name: Gather Info of first-class disk 'firstclassdisk'
+ vmware_first_class_disk_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datastore_name: "{{ rw_datastore }}"
+ disk_name: "firstclassdisk"
+ validate_certs: false
+ register: disk_info
+ delegate_to: localhost
+
+- name: assert for first-class disk info
+ assert:
+ that:
+ - "(disk_info['first_class_disks'] | length) == 1"
+ - "disk_info['first_class_disks'][0]['name'] == 'firstclassdisk'"
+ - "disk_info['first_class_disks'][0]['datastore_name'] == rw_datastore"
+ - "disk_info['first_class_disks'][0]['size_mb'] == 1024"
+ - "disk_info['first_class_disks'][0]['consumption_type'] is defined"
+ - "disk_info['first_class_disks'][0]['descriptor_version'] is defined"
+ - "disk_info['first_class_disks'][0]['consumer_ids'] is defined" \ No newline at end of file
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/tasks/main.yml
index 51b53f4b5..f3816b0cf 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_folder_info/tasks/main.yml
@@ -31,7 +31,7 @@
- assert:
that:
- - "{{ item }} is defined"
+ - "item is defined"
with_items:
- folder_info_0001['folder_info']
- folder_info_0001['flat_folder_info']
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f0.yml
index abe194fdf..23d35a9c8 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f0.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/cdrom_d1_c1_f0.yml
@@ -20,6 +20,8 @@
type: thin
datastore: "{{ rw_datastore }}"
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] centos.iso"
register: cdrom_vm
@@ -42,6 +44,8 @@
datastore: "{{ rw_datastore }}"
datacenter: "{{ dc1 }}"
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
state: present
@@ -66,6 +70,8 @@
datastore: "{{ rw_datastore }}"
datacenter: "{{ dc1 }}"
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
state: present
@@ -88,6 +94,8 @@
name: test_vm1
datacenter: "{{ dc1 }}"
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: client
state: present
register: cdrom_vm
@@ -110,6 +118,8 @@
name: test_vm1
datacenter: "{{ dc1 }}"
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: client
state: present
register: cdrom_vm
@@ -144,6 +154,8 @@
name: test_vm2
datacenter: "{{ dc1 }}"
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: none
state: present
register: cdrom_vm
@@ -182,6 +194,8 @@
type: thin
datastore: "{{ rw_datastore }}"
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
register: cdrom_vm
@@ -220,6 +234,8 @@
type: thin
datastore: "{{ rw_datastore }}"
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] base.iso"
register: cdrom_vm
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/check_mode.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/check_mode.yml
index 2d2ace997..e17f4effd 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/check_mode.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/check_mode.yml
@@ -19,6 +19,8 @@
scsi: paravirtual
version: 11
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
networks:
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml
index 77a94e2b5..ab1f44919 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_customize_guest_test.yml
@@ -19,6 +19,8 @@
scsi: paravirtual
version: 11
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
networks:
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_with_convert.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_with_convert.yml
index 50063016a..f4e14b534 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_with_convert.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/clone_with_convert.yml
@@ -19,6 +19,8 @@
scsi: paravirtual
version: 11
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
networks:
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/windows_vbs_d1_c1_f0.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/windows_vbs_d1_c1_f0.yml
index cd151620a..af72c9feb 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/windows_vbs_d1_c1_f0.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest/tasks/windows_vbs_d1_c1_f0.yml
@@ -22,6 +22,8 @@
type: thin
datastore: '{{ rw_datastore }}'
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: client
register: vbs_vm
@@ -56,6 +58,8 @@
type: thin
datastore: '{{ rw_datastore }}'
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: client
register: vbs_vm
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/tasks/main.yml
index 790eb4a11..6ff9d522d 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_controller/tasks/main.yml
@@ -50,8 +50,8 @@
assert:
that:
- "add_disk_controller.changed == true"
- - "{{ add_disk_controller.disk_controller_data.scsi | length | int }} == {{ scsi_num | int + 1 }}"
- - "{{ add_disk_controller.disk_controller_data.sata | length | int }} == {{ sata_num | int + 1 }}"
+ - "add_disk_controller.disk_controller_data.scsi | length | int == scsi_num | int + 1"
+ - "add_disk_controller.disk_controller_data.sata | length | int == sata_num | int + 1"
- name: delete specified disk controllers
vmware_guest_controller:
@@ -76,5 +76,5 @@
assert:
that:
- "del_disk_controller.changed == true"
- - "{{ del_disk_controller.disk_controller_data.sata | length | int }} == {{ sata_num | int }}"
- - "{{ del_disk_controller.disk_controller_data.scsi | length | int }} == {{ scsi_num | int }}"
+ - "del_disk_controller.disk_controller_data.sata | length | int == sata_num | int"
+ - "del_disk_controller.disk_controller_data.scsi | length | int == scsi_num | int"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/tasks/main.yml
index 6e50231e6..ed3ca1295 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk/tasks/main.yml
@@ -24,6 +24,8 @@
type: thin
datastore: local
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
hardware:
@@ -607,4 +609,28 @@
- name: assert that changes were made
assert:
that:
- - test_remove_ide_disk is changed \ No newline at end of file
+ - test_remove_ide_disk is changed
+
+- name: Try to remove non-existing SCSI disk
+ vmware_guest_disk:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ datacenter: "{{ dc1 }}"
+ validate_certs: false
+ name: test_vm1
+ disk:
+ - state: "absent"
+ controller_type: 'paravirtual'
+ controller_number: 0
+ unit_number: 15
+ register: test_remove_non_existing_disk
+ ignore_errors: true
+
+- debug:
+ msg: "{{ test_remove_non_existing_disk }}"
+
+- name: assert that removing non existing disk does not fail
+ assert:
+ that:
+ - test_remove_non_existing_disk is not failed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/tasks/main.yml
index decb904f9..28de37840 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_disk_info/tasks/main.yml
@@ -25,6 +25,8 @@
scsi: paravirtual
version: 11
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
networks:
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/tasks/main.yml
index cb70cbbd3..0dad050e7 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_network/tasks/main.yml
@@ -31,6 +31,8 @@
num_cpus: 1
scsi: paravirtual
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
networks:
@@ -89,7 +91,7 @@
assert:
that:
- add_netadapter is changed
- - "{{ add_netadapter.results[1].network_info | length | int }} == {{ netadapter_num | int + 2 }}"
+ - "add_netadapter.results[1].network_info | length | int == netadapter_num | int + 2"
- name: delete one specified network adapter
community.vmware.vmware_guest_network:
@@ -108,7 +110,7 @@
assert:
that:
- del_netadapter is changed
- - "{{ del_netadapter.network_info | length | int }} == {{ netadapter_num | int + 1 }}"
+ - "del_netadapter.network_info | length | int == netadapter_num | int + 1"
- name: get instance uuid of virtual machines
community.vmware.vmware_guest_info:
@@ -142,7 +144,7 @@
assert:
that:
- add_netadapter_instanceuuid is changed
- - "{{ add_netadapter_instanceuuid.network_info | length | int }} == {{ netadapter_num | int + 2 }}"
+ - "add_netadapter_instanceuuid.network_info | length | int == netadapter_num | int + 2"
- name: delete one specified network adapter
community.vmware.vmware_guest_network:
@@ -159,7 +161,7 @@
assert:
that:
- del_netadapter is changed
- - "{{ del_netadapter.network_info | length | int }} == {{ netadapter_num | int + 1 }}"
+ - "del_netadapter.network_info | length | int == netadapter_num | int + 1"
- name: delete again one specified network adapter (idempotency)
community.vmware.vmware_guest_network:
@@ -178,7 +180,7 @@
assert:
that:
- not (del_again_netadapter is changed)
- - "{{ del_again_netadapter.network_info | length | int }} == {{ netadapter_num | int + 1 }}"
+ - "del_again_netadapter.network_info | length | int == netadapter_num | int + 1"
- name: disable DirectPath I/O on a Vmxnet3 adapter
community.vmware.vmware_guest_network:
@@ -226,7 +228,7 @@
assert:
that:
- disc_netadapter is changed
- - "{{ disc_netadapter.network_info[netadapter_num | int]['connected'] }} == false"
+ - "disc_netadapter.network_info[netadapter_num | int]['connected'] == false"
- name: Check if network does not exists
community.vmware.vmware_guest_network:
@@ -396,7 +398,7 @@
- name: check that there's no adapters left
assert:
that:
- - "{{ nic_info2.network_info | length | int }} == 0"
+ - "nic_info2.network_info | length | int == 0"
- name: add new adapter(s)
community.vmware.vmware_guest_network:
@@ -412,7 +414,7 @@
- name: check that nic was created
assert:
that:
- - "{{ new_nic.network_info | length | int }} > 0"
+ - "new_nic.network_info | length | int > 0"
- name: add new PVRDMA adapter
community.vmware.vmware_guest_network:
@@ -429,7 +431,7 @@
- name: check that PVRDMA nic was created
assert:
that:
- - "{{ new_nic_pvrdma.network_info | length | int }} == {{ new_nic.network_info | length | int + 1 }}"
+ - "new_nic_pvrdma.network_info | length | int == new_nic.network_info | length | int + 1"
- name: remove PVRDMA adapter
community.vmware.vmware_guest_network:
@@ -445,7 +447,7 @@
- name: check that PVRDMA nic was removed
assert:
that:
- - "{{ new_nic_pvrdma.network_info | length | int - 1 }} == {{ remove_nic_pvrdma.network_info | length | int }}"
+ - "new_nic_pvrdma.network_info | length | int - 1 == remove_nic_pvrdma.network_info | length | int"
# https://github.com/ansible-collections/community.vmware/issues/204
- name: "Change a dvpg with in same DVS(integration test for 204)"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/tasks/main.yml
index 048470966..462ae52ae 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_powerstate/tasks/main.yml
@@ -28,6 +28,8 @@
num_cpus: 1
scsi: paravirtual
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
networks:
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/tasks/main.yml
index 622a69c70..4eeb11cf5 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_snapshot/tasks/main.yml
@@ -7,7 +7,7 @@
# Test0001: Try to delete the non-existent snapshot
- name: 0001 - Delete non-existent snapshot
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -20,7 +20,7 @@
# Test0002: Create two snapshots
- name: 0002 - Create snapshot
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -37,7 +37,7 @@
# Test0003: Reanme a to c
- name: 0003 - Rename snapshot
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -51,7 +51,7 @@
# Test0004: Create snap_a again
- name: 0004 - Re-create snapshot a
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -65,7 +65,7 @@
# Test0005: Change description of snap_c
- name: 0005 - Change description of snap_c
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -79,7 +79,7 @@
# Test0006: Delete snap_b with child remove
- name: 0006 - Delete snap_b with child remove
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -93,7 +93,7 @@
# Test0007: Delete all snapshots
- name: 0007 - Delete all snapshots
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -105,7 +105,7 @@
# Test0008: Create snap_a again and revert to it
- name: 0008 - Re-create snapshot a
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -118,7 +118,7 @@
description: "snap named a"
- name: 0008 - Revert to snap_a
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -131,7 +131,7 @@
# Test0009: Create snap_a and check in result
- name: 0009 - create snapshot a
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -144,16 +144,16 @@
description: "snap named a"
register: snapshot_details
-- debug: var=snapshot_details
+- ansible.builtin.debug: var=snapshot_details
- name: Check if snapshot details available or not
- assert:
+ ansible.builtin.assert:
that:
- "snapshot_details['msg'] == 'Snapshot named [snap_a] already exists and is current.'"
# Test0011: Failure sceanrios - when name and UUID is not specified
- name: 0011 - name and UUID is missing
- vmware_guest_snapshot:
+ community.vmware.vmware_guest_snapshot:
validate_certs: false
hostname: '{{ vcenter_hostname }}'
username: '{{ vcenter_username }}'
@@ -166,7 +166,84 @@
ignore_errors: true
- name: Check if error is shown
- assert:
+ ansible.builtin.assert:
that:
- "'one of the following is required: name, uuid' in snapshot_failure_details['msg']"
- "snapshot_failure_details.changed == false"
+
+# Test0010 : Test for revert and remove a snapshot to specify snapshot_id
+- name: 0012 - Create snapshot
+ community.vmware.vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: present
+ snapshot_name: "snap_{{item}}"
+ description: "snap named {{item}}"
+ with_items:
+ - b
+ - c
+ register: snapshot_creation_result0012
+
+- name: Create the snapshot_ids variable
+ ansible.builtin.set_fact:
+ snapshot_ids: >-
+ {{ snapshot_ids | default([])
+ + [({
+ 'name': item.snapshot_results.current_snapshot.name,
+ 'snapshot_id': item.snapshot_results.current_snapshot.id
+ })]
+ }}
+ loop: "{{ snapshot_creation_result0012.results }}"
+
+- name: 0013 - Revert to snap_b with snapshot_id
+ community.vmware.vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: revert
+ snapshot_id: "{{ item.snapshot_id }}"
+ loop: "{{ snapshot_ids }}"
+ when:
+ - item.name == "snap_b"
+ register: revert_snapshot_with_id_result
+
+- name: Make sure whether reverted with snapshot_id
+ ansible.builtin.assert:
+ that:
+ - item.changed is sameas true
+ loop: "{{ revert_snapshot_with_id_result.results }}"
+ when:
+ - item.item.name == "snap_b"
+
+- name: 0014 - Remove snap_b with snapshot_id
+ community.vmware.vmware_guest_snapshot:
+ validate_certs: false
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ datacenter: "{{ dc1 }}"
+ name: "{{ virtual_machines[0].name }}"
+ folder: "{{ virtual_machines[0].folder }}"
+ state: absent
+ snapshot_id: "{{ item.snapshot_id }}"
+ loop: "{{ snapshot_ids }}"
+ when:
+ - item.name == "snap_b"
+ register: remove_snapshot_with_id_result
+
+- name: Make sure whether removed with snapshot_id
+ ansible.builtin.assert:
+ that:
+ - item.changed is sameas true
+ loop: "{{ remove_snapshot_with_id_result.results }}"
+ when:
+ - item.item.name == "snap_b"
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/tasks/main.yml
index 2b3a23268..c675d138b 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_guest_tools_wait/tasks/main.yml
@@ -31,6 +31,8 @@
num_cpus: 1
scsi: paravirtual
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
networks:
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/tasks/main.yml
index 9d3352e6d..cab3aa222 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance/tasks/main.yml
@@ -7,33 +7,48 @@
vars:
setup_attach_host: true
-- name: Change acceptance level of given hosts
+- name: Change acceptance level of given host in check mode
vmware_host_acceptance:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ esxi1 }}'
validate_certs: false
- acceptance_level: community
- state: present
- register: host_acceptance_info
-- debug: var=host_acceptance_info
+ state: community
+ register: host_acceptance_community_check_mode
+ check_mode: true
+- debug: var=host_acceptance_community_check_mode
- assert:
that:
- - host_acceptance_info.facts is defined
+ - host_acceptance_community_check_mode.facts is defined
+ - host_acceptance_community_check_mode.changed
-- name: Change acceptance level of given hosts in check mode
+- name: Change acceptance level of given host
vmware_host_acceptance:
hostname: "{{ vcenter_hostname }}"
username: "{{ vcenter_username }}"
password: "{{ vcenter_password }}"
esxi_hostname: '{{ esxi1 }}'
validate_certs: false
- acceptance_level: community
- state: present
- register: host_acceptance_info_check_mode
- check_mode: true
-- debug: var=host_acceptance_info_check_mode
+ state: community
+ register: host_acceptance_community
+- debug: var=host_acceptance_community
+- assert:
+ that:
+ - host_acceptance_community.facts is defined
+ - host_acceptance_community.changed
+
+- name: Change acceptance level of given host again (idempotency)
+ vmware_host_acceptance:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ state: community
+ register: host_acceptance_community_again
+- debug: var=host_acceptance_community_again
- assert:
that:
- - host_acceptance_info_check_mode.facts is defined
+ - host_acceptance_community_again.facts is defined
+ - host_acceptance_community_again.changed is false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance_info/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance_info/aliases
new file mode 100644
index 000000000..07e8732a3
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance_info/aliases
@@ -0,0 +1,3 @@
+cloud/vcenter
+needs/target/prepare_vmware_tests
+zuul/vmware/vcenter_1esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance_info/tasks/main.yml
new file mode 100644
index 000000000..483391ecd
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_acceptance_info/tasks/main.yml
@@ -0,0 +1,22 @@
+# Test code for the vmware_host_acceptance module.
+# Copyright: (c) 2018, Abhijeet Kasurde <akasurde@redhat.com>
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+- import_role:
+ name: prepare_vmware_tests
+ vars:
+ setup_attach_host: true
+
+- name: Gather acceptance level of given host
+ vmware_host_acceptance_info:
+ hostname: "{{ vcenter_hostname }}"
+ username: "{{ vcenter_username }}"
+ password: "{{ vcenter_password }}"
+ esxi_hostname: '{{ esxi1 }}'
+ validate_certs: false
+ register: result
+- debug: var=result
+- assert:
+ that:
+ - result.host_acceptance_info is defined
+ - result.changed is false
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/main.yml
index 7e5369e1a..c3028864e 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_auto_start/tasks/main.yml
@@ -50,8 +50,8 @@
with_items: ['test_vm1', 'test_vm2']
- include_tasks: reset_auto_start_config.yml
- - include: vcenter_auto_start_ops.yml
+ - include_tasks: vcenter_auto_start_ops.yml
- include_tasks: reset_auto_start_config.yml
- - include: esxi_auto_start_ops.yml
+ - include_tasks: esxi_auto_start_ops.yml
always:
- include_tasks: reset_auto_start_config.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/aliases b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/aliases
index 07e8732a3..d1d14d229 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/aliases
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/aliases
@@ -1,3 +1,3 @@
cloud/vcenter
needs/target/prepare_vmware_tests
-zuul/vmware/vcenter_1esxi
+zuul/vmware/vcenter_2esxi
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/tasks/main.yml
index a1fad114a..d84dae45f 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_host_snmp/tasks/main.yml
@@ -7,7 +7,6 @@
vars:
setup_attach_host: true
-# SNMP works only with standalone ESXi server
- name: Enable and configure SNMP community in check mode
vmware_host_snmp:
hostname: '{{ esxi1 }}'
@@ -68,3 +67,133 @@
that:
- snmp_disabled is defined
- snmp_disabled.changed
+
+- name: Enable and configure SNMP community via vCenter in check mode
+ vmware_host_snmp:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: '{{ esxi2 }}'
+ community: [ test ]
+ state: enabled
+ validate_certs: false
+ register: snmp_enabled_check_mode
+ check_mode: true
+- debug: var=snmp_enabled_check_mode
+- assert:
+ that:
+ - snmp_enabled_check_mode is defined
+ - snmp_enabled_check_mode.changed
+
+- name: Enable and configure SNMP community via vCenter
+ vmware_host_snmp:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: '{{ esxi2 }}'
+ community: [ test ]
+ state: enabled
+ validate_certs: false
+ register: snmp_enabled
+- debug: var=snmp_enabled
+- assert:
+ that:
+ - snmp_enabled is defined
+ - snmp_enabled.changed
+
+- name: Enable and configure SNMP system contact and location via vCenter
+ vmware_host_snmp:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: '{{ esxi2 }}'
+ sys_contact: "admin@testemail.com"
+ sys_location: "Austin, USA"
+ state: enabled
+ validate_certs: false
+ register: snmp_enabled_sys_options
+- debug: var=snmp_enabled_sys_options
+- assert:
+ that:
+ - snmp_enabled_sys_options is defined
+ - snmp_enabled_sys_options.changed
+
+- name: Disable SNMP via vCenter
+ vmware_host_snmp:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ esxi_hostname: '{{ esxi2 }}'
+ state: disabled
+ validate_certs: false
+ register: snmp_disabled
+- debug: var=snmp_disabled
+- assert:
+ that:
+ - snmp_disabled is defined
+ - snmp_disabled.changed
+
+- name: Enable and configure SNMP community in a cluster via vCenter in check mode
+ vmware_host_snmp:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ community: [ test2 ]
+ state: enabled
+ validate_certs: false
+ register: snmp_enabled_check_mode
+ check_mode: true
+- debug: var=snmp_enabled_check_mode
+- assert:
+ that:
+ - snmp_enabled_check_mode is defined
+ - snmp_enabled_check_mode.changed
+
+- name: Enable and configure SNMP community in a cluster via vCenter
+ vmware_host_snmp:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ community: [ test2 ]
+ state: enabled
+ validate_certs: false
+ register: snmp_enabled
+- debug: var=snmp_enabled
+- assert:
+ that:
+ - snmp_enabled is defined
+ - snmp_enabled.changed
+
+- name: Enable and configure SNMP system contact and location in a cluster via vCenter
+ vmware_host_snmp:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ sys_contact: "admin2@testemail.com"
+ sys_location: "Austin, USA"
+ state: enabled
+ validate_certs: false
+ register: snmp_enabled_sys_options
+- debug: var=snmp_enabled_sys_options
+- assert:
+ that:
+ - snmp_enabled_sys_options is defined
+ - snmp_enabled_sys_options.changed
+
+- name: Disable SNMP in a cluster via vCenter
+ vmware_host_snmp:
+ hostname: '{{ vcenter_hostname }}'
+ username: '{{ vcenter_username }}'
+ password: '{{ vcenter_password }}'
+ cluster_name: "{{ ccr1 }}"
+ state: disabled
+ validate_certs: false
+ register: snmp_disabled
+- debug: var=snmp_disabled
+- assert:
+ that:
+ - snmp_disabled is defined
+ - snmp_disabled.changed
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/main.yml
index 6fb176169..086bf0399 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_object_rename/tasks/main.yml
@@ -2,4 +2,4 @@
# Copyright: (c) 2019, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-- include: dc_rename.yml
+- include_tasks: dc_rename.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/main.yml
index 8961c6916..e0baeea76 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag/tasks/main.yml
@@ -2,6 +2,6 @@
# Copyright: (c) 2019, Pavan Bidkar <pbidkar@vmware.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-- include: tag_crud_ops.yml
-- include: tag_manager_ops.yml
-- include: tag_manager_duplicate_tag_cat.yml
+- include_tasks: tag_crud_ops.yml
+- include_tasks: tag_manager_ops.yml
+- include_tasks: tag_manager_duplicate_tag_cat.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/main.yml
index c7b0209a9..d3a5abb94 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_info/tasks/main.yml
@@ -2,4 +2,4 @@
# Copyright: (c) 2020, Abhijeet Kasurde <akasurde@redhat.com>
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
-- include: tag_info.yml \ No newline at end of file
+- include_tasks: tag_info.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/main.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/main.yml
index e49301ef7..60dd2bd9b 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/main.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_tag_manager/tasks/main.yml
@@ -28,6 +28,6 @@
- name: Set category one id
set_fact: cat_one_id={{ category_one_create['category_results']['category_id'] }}
- - include: tag_manager_dict.yml
+ - include_tasks: tag_manager_dict.yml
always:
- - include: cleanup.yml
+ - include_tasks: cleanup.yml
diff --git a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/prepare_environment.yml b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/prepare_environment.yml
index 65e643b74..7e24b2d94 100644
--- a/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/prepare_environment.yml
+++ b/ansible_collections/community/vmware/tests/integration/targets/vmware_vm_inventory/prepare_environment.yml
@@ -31,6 +31,8 @@
type: thin
datastore: local
cdrom:
+ - controller_number: 0
+ unit_number: 0
type: iso
iso_path: "[{{ ro_datastore }}] fedora.iso"
hardware:
diff --git a/ansible_collections/community/vmware/tests/sanity/ignore-2.13.txt b/ansible_collections/community/vmware/tests/sanity/ignore-2.13.txt
deleted file mode 100644
index e8a48ca14..000000000
--- a/ansible_collections/community/vmware/tests/sanity/ignore-2.13.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-plugins/modules/vmware_deploy_ovf.py use-argspec-type-path!skip
-plugins/modules/vmware_host_acceptance.py validate-modules:parameter-state-invalid-choice
diff --git a/ansible_collections/community/vmware/tests/sanity/ignore-2.14.txt b/ansible_collections/community/vmware/tests/sanity/ignore-2.14.txt
deleted file mode 100644
index e8a48ca14..000000000
--- a/ansible_collections/community/vmware/tests/sanity/ignore-2.14.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-plugins/modules/vmware_deploy_ovf.py use-argspec-type-path!skip
-plugins/modules/vmware_host_acceptance.py validate-modules:parameter-state-invalid-choice
diff --git a/ansible_collections/community/vmware/tests/sanity/ignore-2.15.txt b/ansible_collections/community/vmware/tests/sanity/ignore-2.15.txt
index e8a48ca14..8203d8990 100644
--- a/ansible_collections/community/vmware/tests/sanity/ignore-2.15.txt
+++ b/ansible_collections/community/vmware/tests/sanity/ignore-2.15.txt
@@ -1,2 +1,2 @@
+plugins/modules/vmware_deploy_ovf.py replace-urlopen!skip
plugins/modules/vmware_deploy_ovf.py use-argspec-type-path!skip
-plugins/modules/vmware_host_acceptance.py validate-modules:parameter-state-invalid-choice
diff --git a/ansible_collections/community/vmware/tests/sanity/ignore-2.16.txt b/ansible_collections/community/vmware/tests/sanity/ignore-2.16.txt
new file mode 100644
index 000000000..4a0d49a7d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/sanity/ignore-2.16.txt
@@ -0,0 +1,4 @@
+plugins/modules/vmware_deploy_ovf.py replace-urlopen!skip
+plugins/modules/vmware_deploy_ovf.py use-argspec-type-path!skip
+scripts/inventory/vmware_inventory.py pep8!skip
+tests/unit/mock/loader.py pep8!skip
diff --git a/ansible_collections/community/vmware/tests/sanity/ignore-2.17.txt b/ansible_collections/community/vmware/tests/sanity/ignore-2.17.txt
new file mode 100644
index 000000000..4a0d49a7d
--- /dev/null
+++ b/ansible_collections/community/vmware/tests/sanity/ignore-2.17.txt
@@ -0,0 +1,4 @@
+plugins/modules/vmware_deploy_ovf.py replace-urlopen!skip
+plugins/modules/vmware_deploy_ovf.py use-argspec-type-path!skip
+scripts/inventory/vmware_inventory.py pep8!skip
+tests/unit/mock/loader.py pep8!skip
diff --git a/ansible_collections/community/vmware/tests/unit/compat/__init__.py b/ansible_collections/community/vmware/tests/unit/compat/__init__.py
deleted file mode 100644
index e69de29bb..000000000
--- a/ansible_collections/community/vmware/tests/unit/compat/__init__.py
+++ /dev/null
diff --git a/ansible_collections/community/vmware/tests/unit/compat/mock.py b/ansible_collections/community/vmware/tests/unit/compat/mock.py
deleted file mode 100644
index 53b6048dc..000000000
--- a/ansible_collections/community/vmware/tests/unit/compat/mock.py
+++ /dev/null
@@ -1,122 +0,0 @@
-# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-'''
-Compat module for Python3.x's unittest.mock module
-'''
-import sys
-import _io
-
-# Python 2.7
-
-# Note: Could use the pypi mock library on python3.x as well as python2.x. It
-# is the same as the python3 stdlib mock library
-
-try:
- # Allow wildcard import because we really do want to import all of mock's
- # symbols into this compat shim
- # pylint: disable=wildcard-import,unused-wildcard-import
- from unittest.mock import *
-except ImportError:
- # Python 2
- # pylint: disable=wildcard-import,unused-wildcard-import
- try:
- from mock import *
- except ImportError:
- print('You need the mock library installed on python2.x to run tests')
-
-
-# Prior to 3.4.4, mock_open cannot handle binary read_data
-if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
- file_spec = None
-
- def _iterate_read_data(read_data):
- # Helper for mock_open:
- # Retrieve lines from read_data via a generator so that separate calls to
- # readline, read, and readlines are properly interleaved
- sep = b'\n' if isinstance(read_data, bytes) else '\n'
- data_as_list = [l + sep for l in read_data.split(sep)]
-
- if data_as_list[-1] == sep:
- # If the last line ended in a newline, the list comprehension will have an
- # extra entry that's just a newline. Remove this.
- data_as_list = data_as_list[:-1]
- else:
- # If there wasn't an extra newline by itself, then the file being
- # emulated doesn't have a newline to end the last line remove the
- # newline that our naive format() added
- data_as_list[-1] = data_as_list[-1][:-1]
-
- for line in data_as_list:
- yield line
-
- def mock_open(mock=None, read_data=''):
- """
- A helper function to create a mock to replace the use of `open`. It works
- for `open` called directly or used as a context manager.
-
- The `mock` argument is the mock object to configure. If `None` (the
- default) then a `MagicMock` will be created for you, with the API limited
- to methods or attributes available on standard file handles.
-
- `read_data` is a string for the `read` methoddline`, and `readlines` of the
- file handle to return. This is an empty string by default.
- """
- def _readlines_side_effect(*args, **kwargs):
- if handle.readlines.return_value is not None:
- return handle.readlines.return_value
- return list(_data)
-
- def _read_side_effect(*args, **kwargs):
- if handle.read.return_value is not None:
- return handle.read.return_value
- return type(read_data)().join(_data)
-
- def _readline_side_effect():
- if handle.readline.return_value is not None:
- while True:
- yield handle.readline.return_value
- for line in _data:
- yield line
-
- global file_spec
- if file_spec is None:
- file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
-
- if mock is None:
- mock = MagicMock(name='open', spec=open)
-
- handle = MagicMock(spec=file_spec)
- handle.__enter__.return_value = handle
-
- _data = _iterate_read_data(read_data)
-
- handle.write.return_value = None
- handle.read.return_value = None
- handle.readline.return_value = None
- handle.readlines.return_value = None
-
- handle.read.side_effect = _read_side_effect
- handle.readline.side_effect = _readline_side_effect()
- handle.readlines.side_effect = _readlines_side_effect
-
- mock.return_value = handle
- return mock
diff --git a/ansible_collections/community/vmware/tests/unit/compat/unittest.py b/ansible_collections/community/vmware/tests/unit/compat/unittest.py
deleted file mode 100644
index 98f08ad6a..000000000
--- a/ansible_collections/community/vmware/tests/unit/compat/unittest.py
+++ /dev/null
@@ -1,38 +0,0 @@
-# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
-#
-# This file is part of Ansible
-#
-# Ansible is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Ansible is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
-
-# Make coding more python3-ish
-from __future__ import (absolute_import, division, print_function)
-__metaclass__ = type
-
-'''
-Compat module for Python2.7's unittest module
-'''
-
-import sys
-
-# Allow wildcard import because we really do want to import all of
-# unittests's symbols into this compat shim
-# pylint: disable=wildcard-import,unused-wildcard-import
-if sys.version_info < (2, 7):
- try:
- # Need unittest2 on python2.6
- from unittest2 import *
- except ImportError:
- print('You need unittest2 installed on python2.6.x to run tests')
-else:
- from unittest import *
diff --git a/ansible_collections/community/vmware/tests/unit/mock/path.py b/ansible_collections/community/vmware/tests/unit/mock/path.py
index 37959e5c8..f6a3ebb46 100644
--- a/ansible_collections/community/vmware/tests/unit/mock/path.py
+++ b/ansible_collections/community/vmware/tests/unit/mock/path.py
@@ -4,7 +4,8 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type
-from ansible_collections.community.vmware.tests.unit.compat.mock import MagicMock
+from unittest.mock import MagicMock
+
from ansible.utils.path import unfrackpath
diff --git a/ansible_collections/community/vmware/tests/unit/mock/procenv.py b/ansible_collections/community/vmware/tests/unit/mock/procenv.py
index 30f3b2bf6..4cb47f572 100644
--- a/ansible_collections/community/vmware/tests/unit/mock/procenv.py
+++ b/ansible_collections/community/vmware/tests/unit/mock/procenv.py
@@ -21,11 +21,11 @@ from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
import sys
+import unittest
import json
from contextlib import contextmanager
from io import BytesIO, StringIO
-from ansible_collections.community.vmware.tests.unit.compat import unittest
from ansible.module_utils.six import PY3
from ansible.module_utils._text import to_bytes
diff --git a/ansible_collections/community/vmware/tests/unit/module_utils/test_vmware.py b/ansible_collections/community/vmware/tests/unit/module_utils/test_vmware.py
index 11483d34d..5b1790abe 100644
--- a/ansible_collections/community/vmware/tests/unit/module_utils/test_vmware.py
+++ b/ansible_collections/community/vmware/tests/unit/module_utils/test_vmware.py
@@ -10,9 +10,10 @@ import ssl
import sys
import pytest
+from unittest import mock
+
pyvmomi = pytest.importorskip('pyVmomi')
-from ansible_collections.community.vmware.tests.unit.compat import mock
from ansible_collections.community.vmware.plugins.module_utils.vmware import option_diff
import ansible_collections.community.vmware.plugins.module_utils.vmware as vmware_module_utils
@@ -110,7 +111,7 @@ def test_lib_loading_failure(monkeypatch, fake_ansible_module, key, libname):
with pytest.raises(FailJsonException):
vmware_module_utils.PyVmomi(fake_ansible_module)
error_str = 'Failed to import the required Python library (%s)' % libname
- assert fake_ansible_module.fail_json.called_once()
+ fake_ansible_module.fail_json.assert_called_once()
assert error_str in fake_ansible_module.fail_json.call_args[1]['msg']
@@ -121,7 +122,7 @@ def test_required_params(request, params, msg, fake_ansible_module):
fake_ansible_module.params = params
with pytest.raises(FailJsonException):
vmware_module_utils.connect_to_api(fake_ansible_module)
- assert fake_ansible_module.fail_json.called_once()
+ fake_ansible_module.fail_json.assert_called_once()
# TODO: assert msg in fake_ansible_module.fail_json.call_args[1]['msg']
@@ -135,7 +136,7 @@ def test_validate_certs(monkeypatch, fake_ansible_module):
vmware_module_utils.PyVmomi(fake_ansible_module)
msg = 'pyVim does not support changing verification mode with python < 2.7.9.' \
' Either update python or use validate_certs=false.'
- assert fake_ansible_module.fail_json.called_once()
+ fake_ansible_module.fail_json.assert_called_once()
assert msg == fake_ansible_module.fail_json.call_args[1]['msg']
@@ -157,7 +158,7 @@ def test_vmdk_disk_path_split_negative(monkeypatch, fake_ansible_module):
with pytest.raises(FailJsonException):
pyv = vmware_module_utils.PyVmomi(fake_ansible_module)
pyv.vmdk_disk_path_split('[ds1]')
- assert fake_ansible_module.fail_json.called_once()
+ fake_ansible_module.fail_json.assert_called_once()
assert 'Bad path' in fake_ansible_module.fail_json.call_args[1]['msg']
diff --git a/ansible_collections/community/vmware/tests/unit/modules/cloud/vmware/test_vmware_host_sriov.py b/ansible_collections/community/vmware/tests/unit/modules/cloud/vmware/test_vmware_host_sriov.py
index 1d2190dbb..a8ade1fa9 100644
--- a/ansible_collections/community/vmware/tests/unit/modules/cloud/vmware/test_vmware_host_sriov.py
+++ b/ansible_collections/community/vmware/tests/unit/modules/cloud/vmware/test_vmware_host_sriov.py
@@ -2,14 +2,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import json
-
-
-try:
- from unittest import mock
-except ImportError:
- import mock
import unittest
+from unittest import mock
+
from ansible.module_utils import basic
from ansible.module_utils._text import to_bytes
diff --git a/ansible_collections/community/vmware/tests/unit/modules/utils.py b/ansible_collections/community/vmware/tests/unit/modules/utils.py
index 001d6c165..d27a8ef0c 100644
--- a/ansible_collections/community/vmware/tests/unit/modules/utils.py
+++ b/ansible_collections/community/vmware/tests/unit/modules/utils.py
@@ -5,9 +5,10 @@ from __future__ import absolute_import, division, print_function
__metaclass__ = type
import json
+import unittest
+
+from unittest.mock import patch
-from ansible_collections.community.vmware.tests.unit.compat import unittest
-from ansible_collections.community.vmware.tests.unit.compat.mock import patch
from ansible.module_utils import basic
from ansible.module_utils._text import to_bytes