From a18abf1224ff3862ed19b67ec7ea0ac0f65cfc3c Mon Sep 17 00:00:00 2001 From: Diane Wang Date: Mon, 29 Jan 2024 11:05:02 +0800 Subject: [PATCH] [Windows] Add getting VMware Snapshot Provider service status in test case check_quiesce_snapshot (#539) Signed-off-by: Diane Wang --- .../check_quiesce_snapshot.yml | 18 +++++++--- .../collect_vss_logs.yml | 22 ++++++------ windows/utils/win_enable_vss_log.yml | 34 ++++++++++++------- 3 files changed, 47 insertions(+), 27 deletions(-) diff --git a/windows/check_quiesce_snapshot/check_quiesce_snapshot.yml b/windows/check_quiesce_snapshot/check_quiesce_snapshot.yml index 48d722005..569d0a420 100644 --- a/windows/check_quiesce_snapshot/check_quiesce_snapshot.yml +++ b/windows/check_quiesce_snapshot/check_quiesce_snapshot.yml @@ -16,21 +16,24 @@ vars: skip_test_no_vmtools: true + - name: "Set fact of the remote path in guest OS" + ansible.builtin.set_fact: + quiesce_scripts_freeze_thaw_path: "C:\\Windows\\" + quiesce_scripts_tools_path: "C:\\Program Files\\VMware\\VMware Tools\\backupScripts.d\\" + quiesce_log_file_path: "C:\\vmbackup.log" + - name: "Check disk.EnableUUID in VMX file" include_tasks: check_vmx_disk_enable_uuid.yml when: guest_os_product_type | lower == "server" - name: "Enable vss logging" include_tasks: ../utils/win_enable_vss_log.yml + vars: + win_vmbackup_log_path: "{{ quiesce_log_file_path }}" when: - vmtools_version is defined and vmtools_version - vmtools_version is version('11.0.0', '>=') - - name: "Set fact of the remote path in guest OS" - ansible.builtin.set_fact: - quiesce_scripts_freeze_thaw_path: "C:\\Windows\\" - quiesce_scripts_tools_path: "C:\\Program Files\\VMware\\VMware Tools\\backupScripts.d\\" - - name: "Get Windows guest OS time" include_tasks: ../utils/win_get_time.yml @@ -45,6 +48,11 @@ - name: "Copy custom scripts to guest OS" include_tasks: copy_custom_scripts_to_guest.yml + - name: "Get VMware Snapshot Provider service status in guest OS" + include_tasks: ../utils/win_get_service_status.yml + vars: + win_service_name: "vmvss" + - name: "Set fact of collecting quiesce log file" ansible.builtin.set_fact: collect_vss_logs: true diff --git a/windows/check_quiesce_snapshot/collect_vss_logs.yml b/windows/check_quiesce_snapshot/collect_vss_logs.yml index 362787365..2d35c8a32 100644 --- a/windows/check_quiesce_snapshot/collect_vss_logs.yml +++ b/windows/check_quiesce_snapshot/collect_vss_logs.yml @@ -1,17 +1,18 @@ # Copyright 2021-2023 VMware, Inc. # SPDX-License-Identifier: BSD-2-Clause --- -- name: Set fact of the saved event log files +- name: "Set fact of the paths of saved event log and vmbackup log files" ansible.builtin.set_fact: system_event_log: "C:\\system.evtx" application_event_log: "C:\\application.evtx" -# Get System event logs -- include_tasks: ../utils/win_execute_cmd.yml +- name: "Save System event logs" + include_tasks: ../utils/win_execute_cmd.yml vars: win_powershell_cmd: "(Get-WmiObject Win32_NTEventlogFile | where-object LogfileName -eq 'System').BackupEventlog('{{ system_event_log }}')" win_execute_cmd_ignore_error: true -- include_tasks: ../utils/win_get_file.yml +- name: "Get System event logs" + include_tasks: ../utils/win_get_file.yml vars: win_get_file_src_path: "{{ system_event_log }}" win_get_file_dst_path: "{{ current_test_log_folder }}" @@ -19,12 +20,13 @@ - "'failed' in win_powershell_cmd_output" - not win_powershell_cmd_output.failed -# Get Application event logs -- include_tasks: ../utils/win_execute_cmd.yml +- name: "Save Application event logs" + include_tasks: ../utils/win_execute_cmd.yml vars: win_powershell_cmd: "(Get-WmiObject Win32_NTEventlogFile | where-object LogfileName -eq 'Application').BackupEventlog('{{ application_event_log }}')" win_execute_cmd_ignore_error: true -- include_tasks: ../utils/win_get_file.yml +- name: "Get Application event logs" + include_tasks: ../utils/win_get_file.yml vars: win_get_file_src_path: "{{ application_event_log }}" win_get_file_dst_path: "{{ current_test_log_folder }}" @@ -32,10 +34,10 @@ - "'failed' in win_powershell_cmd_output" - not win_powershell_cmd_output.failed -# Get vmbackup log file -- include_tasks: ../utils/win_get_file.yml +- name: "Get vmbackup log file" + include_tasks: ../utils/win_get_file.yml vars: - win_get_file_src_path: "C://vmbackup.log" + win_get_file_src_path: "{{ quiesce_log_file_path }}" win_get_file_dst_path: "{{ current_test_log_folder }}" when: - vmtools_version is defined and vmtools_version diff --git a/windows/utils/win_enable_vss_log.yml b/windows/utils/win_enable_vss_log.yml index 3b0660b61..4435cc78c 100644 --- a/windows/utils/win_enable_vss_log.yml +++ b/windows/utils/win_enable_vss_log.yml @@ -1,24 +1,34 @@ # Copyright 2021-2023 VMware, Inc. # SPDX-License-Identifier: BSD-2-Clause --- -# Enable VMware tools vss log in tools.conf -- name: Set fact of VMware tools config file path +# Enable VMware Tools vss log in tools.conf +# Parameter: +# win_vmbackup_log_path: the vmbackup log file path in guest OS +# +- name: "Check required parameter" + ansible.builtin.assert: + that: + - win_vmbackup_log_path is defined + - win_vmbackup_log_path + fail_msg: "Parameter 'win_vmbackup_log_path' is required to be defined as the vmbackup log file path." + +- name: "Set fact of VMware Tools config file path" ansible.builtin.set_fact: vmtools_conf_path: "C:\\ProgramData\\VMware\\VMware Tools\\tools.conf" vmtools_conf_template: "C:\\ProgramData\\VMware\\VMware Tools\\tools.conf.example" -# Check if VMware tools config file exists -- include_tasks: win_check_file_exist.yml +- name: "Check if VMware Tools config file exists" + include_tasks: win_check_file_exist.yml vars: win_check_file_exist_file: "{{ vmtools_conf_path }}" -# Copy VMware tools config file from template file -- include_tasks: win_execute_cmd.yml +- name: "Copy VMware Tools config file from template file" + include_tasks: win_execute_cmd.yml vars: win_powershell_cmd: "Copy-Item '{{ vmtools_conf_template }}' -Destination '{{ vmtools_conf_path }}'" when: win_check_file_exist_result is defined and not win_check_file_exist_result -- name: Enable vss log in VMware tools config file +- name: "Enable vss log in VMware Tools config file" community.windows.win_lineinfile: path: "{{ vmtools_conf_path }}" regexp: "{{ item.key }}" @@ -28,15 +38,15 @@ - {key: '^#vmvss.handler.*', value: 'vmvss.handler = vmx'} - {key: '^#vmbackup.level.*', value: 'vmbackup.level = debug'} - {key: '^#vmbackup.handler.*', value: 'vmbackup.handler = file'} - - {key: '^#vmbackup.data.*', value: 'vmbackup.data = C://vmbackup.log'} + - {key: '^#vmbackup.data.*', value: "vmbackup.data = {{ win_vmbackup_log_path }}"} delegate_to: "{{ vm_guest_ip }}" -# Restart VMware tools service -- include_tasks: win_execute_cmd.yml +- name: "Restart VMware Tools service" + include_tasks: win_execute_cmd.yml vars: win_powershell_cmd: "Restart-Service -Force -Name VMTools" -# Make sure VMware tools service is running before taking quiesce snapshot -- include_tasks: win_wait_service_status.yml +- name: "Make sure VMware Tools service is running" + include_tasks: win_wait_service_status.yml vars: win_service_name: 'VMTools'