Skip to content

Commit

Permalink
Remove initializing tools status (#141)
Browse files Browse the repository at this point in the history
* remove initialize tools status

Signed-off-by: dianew <[email protected]>
  • Loading branch information
Tomorrow9 authored Sep 15, 2021
1 parent 0661bd8 commit 3d309c3
Show file tree
Hide file tree
Showing 17 changed files with 113 additions and 91 deletions.
12 changes: 8 additions & 4 deletions common/vm_get_ip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,18 @@

# Get VM IP address when VMware tools is installed
- include_tasks: vm_get_ip_from_vmtools.yml
when: vmtools_is_installed and vmtools_is_running
when:
- vmtools_is_running is defined
- vmtools_is_running | bool

# Get VM IP address when VMware tools not installed or not get from VMware tools
- include_tasks: vm_get_ip_from_notools.yml
when: >
(not vmtools_is_installed) or
(not vmtools_is_running) or
(vm_guest_ip is undefined or not vm_guest_ip)
(vmtools_is_installed is undefined) or
(not vmtools_is_installed | bool) or
(vmtools_is_running is undefined) or
(not vmtools_is_running | bool) or
(not vm_guest_ip)
- name: "Check VM '{{ vm_name }}' IP address"
assert:
Expand Down
17 changes: 6 additions & 11 deletions common/vm_get_vmtools_status.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
# vmtools_is_running: True or False. VMware Tools is running or not.
# vmtools_is_ovt: True or False. VMware Tools is open-vm-tools or not.
#
- name: Initialize VMware Tools installed status
set_fact:
vmtools_is_installed: False
vmtools_is_running: False
vmtools_is_ovt: False
vmtools_not_ready: True

- name: Get VMware Tools installed information first
vmware_guest_tools_info:
hostname: "{{ vsphere_host_name }}"
Expand Down Expand Up @@ -58,10 +51,12 @@
- name: Set fact of VMware Tools running status
set_fact:
vmtools_is_running: "{{ get_vmtools_info_retry.vmtools_info.vm_tools_running_status == 'guestToolsRunning' }}"
when: vmtools_is_installed and vmtools_not_ready
when:
- vmtools_is_installed | default(False)
- vmtools_not_ready | default(True)

- debug:
msg:
- "VMware tools is installed in guest: {{ vmtools_is_installed }}"
- "VMware tools is running in guest: {{ vmtools_is_running }}"
- "VMware tools is installed as open-vm-tools: {{ vmtools_is_ovt }}"
- "VMware tools is installed in guest: {{ vmtools_is_installed | default(False) }}"
- "VMware tools is running in guest: {{ vmtools_is_running | default(False) }}"
- "VMware tools is installed as open-vm-tools: {{ vmtools_is_ovt | default(False) }}"
4 changes: 3 additions & 1 deletion linux/setup/test_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,15 @@
# Get VMware tools version info
- include_tasks: ../utils/get_guest_ovt_version_build.yml
when:
- vmtools_is_installed is defined
- vmtools_is_installed | bool
- vmtools_info_from_vmtoolsd is undefined or not vmtools_info_from_vmtoolsd

# Get VM guest info guest id, guest full name and guest detailed data
- include_tasks: ../../common/vm_get_guest_info.yml
when:
- vmtools_is_installed | bool
- vmtools_is_running is defined
- vmtools_is_running | bool
- guestinfo_gathered is undefined or not guestinfo_gathered

# Create a base snapshot if it does not exist
Expand Down
11 changes: 5 additions & 6 deletions windows/check_ip_address/check_ip_address.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: True
- block:
- name: Get VM IP address from guest info
include_tasks: ../../common/vm_get_ip_from_vmtools.yml
Expand All @@ -35,12 +37,9 @@
loop: "{{ ethernet_ip_dict | dict2items }}"
loop_control:
loop_var: ip_list
when: vmtools_is_installed and vmtools_is_running

- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case '{{ ansible_play_name }}', VMware tools installed: {{ vmtools_is_installed }}, and running: {{ vmtools_is_running }}"
when: not vmtools_is_installed or not vmtools_is_running
when:
- vmtools_is_running is defined
- vmtools_is_running | bool
rescue:
- include_tasks: ../setup/rescue_cleanup.yml
vars:
Expand Down
14 changes: 5 additions & 9 deletions windows/check_os_fullname/check_os_fullname.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: True
- name: Set fact of the supported guest IDs in this test case
set_fact:
support_client_guest: ['windows9Guest', 'windows9_64Guest']
Expand Down Expand Up @@ -83,15 +85,9 @@
fail_msg: "Guest fullname in guest info: {{ os_fullname_guestinfo }}, got from guest OS: {{ os_fullname_guest }}."
success_msg: "Guest fullname in guest info: {{ os_fullname_guestinfo }} is the same as the one got from guest OS."
ignore_errors: True
when: vmtools_is_installed and vmtools_is_running

- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case '{{ ansible_play_name }}', VMware tools installed: {{ vmtools_is_installed }}, running: {{ vmtools_is_running }}, guest ID: {{ vm_guest_id }}"
when: >
(not vmtools_is_installed) or
(not vmtools_is_running) or
(vm_guest_id not in support_client_guest and vm_guest_id not in support_server_guest)
when:
- vmtools_is_running is defined
- vmtools_is_running | bool
rescue:
- include_tasks: ../setup/rescue_cleanup.yml
vars:
Expand Down
10 changes: 5 additions & 5 deletions windows/check_quiesce_snapshot/check_quiesce_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: True
- block:
- include_tasks: check_vmx_disk_enable_uuid.yml
when: guest_os_product_type | lower == "server"
Expand Down Expand Up @@ -53,11 +55,9 @@
- include_tasks: ../../common/vm_remove_snapshot.yml
vars:
snapshot_name: "{{ qs_snapshot_name }}"
when: vmtools_is_installed and vmtools_is_running
- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case due to VMware tools installed: {{ vmtools_is_installed }}, running: {{ vmtools_is_running }}"
when: not vmtools_is_installed or not vmtools_is_running
when:
- vmtools_is_running is defined
- vmtools_is_running | bool
rescue:
- include_tasks: collect_vss_logs.yml
when: collect_vss_logs is defined and collect_vss_logs
Expand Down
12 changes: 8 additions & 4 deletions windows/guest_customization/gosc_sanity_dhcp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: True
- block:
- include_tasks: win_gosc_prepare.yml
- name: Set fact of the network customize type to dhcp
Expand Down Expand Up @@ -86,12 +88,14 @@
# Check timezone configured
- include_tasks: check_timezone.yml
when:
- vmtools_is_installed and vmtools_is_running
- vcenter_is_defined is defined and vcenter_is_defined
- vmtools_is_running is defined
- vmtools_is_running | bool
- vcenter_is_defined is defined
- vcenter_is_defined | bool
- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case '{{ ansible_play_name }}', VMware tools installed: {{ vmtools_is_installed }}, running: {{ vmtools_is_running }}, or vCenter configured: {{ vcenter_is_defined | default('NA') }}"
when: not vmtools_is_installed or not vmtools_is_running or vcenter_is_defined is undefined
msg: "Skip test case due to vCenter server is not configured"
when: vcenter_is_defined is undefined
rescue:
- include_tasks: ../setup/rescue_cleanup.yml
vars:
Expand Down
12 changes: 8 additions & 4 deletions windows/guest_customization/gosc_sanity_staticip.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: True
- block:
- include_tasks: win_gosc_prepare.yml

Expand Down Expand Up @@ -78,12 +80,14 @@
success_msg: "Check guest IP address, hostname after GOSC succeed."
fail_msg: "Check guest IP address, hostname after GOSC failed."
when:
- vmtools_is_installed and vmtools_is_running
- vcenter_is_defined is defined and vcenter_is_defined
- vmtools_is_running is defined
- vmtools_is_running | bool
- vcenter_is_defined is defined
- vcenter_is_defined | bool
- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case '{{ ansible_play_name }}', VMware tools installed: {{ vmtools_is_installed }}, running: {{ vmtools_is_running }}, or vCenter configured: {{ vcenter_is_defined | default('NA') }}"
when: not vmtools_is_installed or not vmtools_is_running or vcenter_is_defined is undefined
msg: "Skip test case due to vCenter server is not configured"
when: vcenter_is_defined is undefined
rescue:
- include_tasks: ../setup/rescue_cleanup.yml
vars:
Expand Down
10 changes: 5 additions & 5 deletions windows/mouse_driver_vmtools/mouse_driver_vmtools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: True
- block:
# Get VMware pointing device driver version in Windows guest OS
- include_tasks: ../utils/win_execute_cmd.yml
Expand All @@ -30,11 +32,9 @@
- vmware_pointing_device_driver is regex("^\d+\.\d+\.\d+\.\d+$")
fail_msg: "Get VMware pointing device driver failed."
success_msg: "Get VMware pointing device driver succeed."
when: vmtools_is_installed and vmtools_is_running
- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case due to VMware tools installed: {{ vmtools_is_installed }}, running: {{ vmtools_is_running }}"
when: not vmtools_is_installed or not vmtools_is_running
when:
- vmtools_is_running is defined
- vmtools_is_running | bool
rescue:
- include_tasks: ../setup/rescue_cleanup.yml
vars:
Expand Down
14 changes: 6 additions & 8 deletions windows/network_device_ops/vmxnet3_network_device_ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@
nic_type: 'VMXNET3'
- block:
- include_tasks: ../setup/test_setup.yml
- name: Add vmxnet3 network adapter to VM and verify status
include_tasks: network_adapter_deviceops.yml
when: vmtools_is_installed and vmtools_is_running

- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case due to VMware tools installed: {{ vmtools_is_installed }}, and running: {{ vmtools_is_running }}"
when: not vmtools_is_installed or not vmtools_is_running
vars:
skip_test_no_vmtools: True
- include_tasks: network_adapter_deviceops.yml
when:
- vmtools_is_running is defined
- vmtools_is_running | bool
rescue:
- include_tasks: ../setup/rescue_cleanup.yml
vars:
Expand Down
15 changes: 13 additions & 2 deletions windows/setup/test_setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
- include_tasks: ../../common/vm_get_vmtools_status.yml
- include_tasks: ../utils/win_get_vmtools_version_build.yml
when:
- vmtools_is_installed is defined and vmtools_is_installed
- vmtools_is_installed is defined
- vmtools_is_installed | bool
- vmtools_info_from_vmtoolsd is undefined or not vmtools_info_from_vmtoolsd

# Get guest OS info if not defined
Expand All @@ -40,9 +41,19 @@
# Get VM guest info guest id, guest full name and guest detailed data
- include_tasks: ../../common/vm_get_guest_info.yml
when:
- vmtools_is_installed | bool
- vmtools_is_running is defined
- vmtools_is_running | bool
- guestinfo_gathered is undefined or not guestinfo_gathered

# Take base snapshot if not exist
- include_tasks: create_base_snapshot.yml
when: not base_snapshot_exists

# Skip test case run when VMware tools is required but not installed or not running
- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case due to VMware tools installed: {{ vmtools_is_installed | default(False) }}, running: {{ vmtools_is_running | default(False) }}"
when:
- skip_test_no_vmtools is defined
- skip_test_no_vmtools
- not (vmtools_is_running is defined and vmtools_is_running | bool)
10 changes: 5 additions & 5 deletions windows/stat_balloon/stat_balloon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: True
- block:
- include_tasks: ../utils/win_execute_cmd.yml
vars:
Expand All @@ -26,11 +28,9 @@
- win_powershell_cmd_output.stdout_lines[0] == '0 MB'
fail_msg: "stat_balloon test failed"
success_msg: "stat_balloon test passed"
when: vmtools_is_installed and vmtools_is_running
- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case due to VMware tools installed: {{ vmtools_is_installed }}, running: {{ vmtools_is_running }}"
when: not vmtools_is_installed or not vmtools_is_running
when:
- vmtools_is_running is defined
- vmtools_is_running | bool
rescue:
- include_tasks: ../setup/rescue_cleanup.yml
vars:
Expand Down
11 changes: 7 additions & 4 deletions windows/utils/shutdown_vm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@
vars:
vm_power_state_set: 'shutdown-guest'
when:
- vmtools_is_installed is defined and vmtools_is_installed
- vmtools_is_running is defined and vmtools_is_running
- vmtools_is_running is defined
- vmtools_is_running | bool

- include_tasks: win_shutdown_restart.yml
vars:
set_win_power_state: 'shutdown'
when:
- vmtools_is_installed is undefined or not vmtools_is_installed
when: >
(vmtools_is_installed is undefined) or
(not vmtools_is_installed | bool) or
(vmtools_is_running is undefined) or
(not vmtools_is_running | bool)
10 changes: 5 additions & 5 deletions windows/vgauth_check_service/vgauth_check_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: True
- block:
- name: Get VGAuthService status in Windows guest OS
include_tasks: ../utils/win_get_service_status.yml
Expand All @@ -25,11 +27,9 @@
- service_status == "Running"
fail_msg: "VGAuth Service is not running in guest OS."
success_msg: "VGAuth service is running in guest OS."
when: vmtools_is_installed and vmtools_is_running
- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case due to VMware tools installed: {{ vmtools_is_installed }}, running: {{ vmtools_is_running }}"
when: not vmtools_is_installed or not vmtools_is_running
when:
- vmtools_is_running is defined
- vmtools_is_running | bool
rescue:
- include_tasks: ../setup/rescue_cleanup.yml
vars:
Expand Down
10 changes: 5 additions & 5 deletions windows/vhba_hot_add_remove/paravirtual_vhba_device_ops.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: True
- include_tasks: hotadd_remove_vhba_test.yml
vars:
test_disk_controller_type: "paravirtual"
when: vmtools_is_installed and vmtools_is_running
- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case due to VMware tools installed: {{ vmtools_is_installed }}, running: {{ vmtools_is_running }}"
when: not vmtools_is_installed or not vmtools_is_running
when:
- vmtools_is_running is defined
- vmtools_is_running | bool
rescue:
- include_tasks: ../setup/rescue_cleanup.yml
vars:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,16 @@
- include_tasks: ../../linux/open_vm_tools/set_base_snapshot.yml
- include_tasks: detach_vmtools_and_remove.yml
when: >
(vmtools_is_installed and update_vmtools) or
(not vmtools_is_installed)
(vmtools_is_installed is undefined) or
(not vmtools_is_installed | bool) or
(vmtools_is_installed | bool and update_vmtools | bool)
- name: "Skip testcase: {{ ansible_play_name }}"
debug:
msg: "Skip test case due to VMware tools is installed, update VMware tools is set to: {{ update_vmtools }}"
when: vmtools_is_installed and not update_vmtools
when:
- vmtools_is_installed is defined
- vmtools_is_installed | bool
- not update_vmtools | bool
rescue:
- include_tasks: ../setup/rescue_cleanup.yml
vars:
Expand Down
Loading

0 comments on commit 3d309c3

Please sign in to comment.