Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Windows] Add getting VMware Snapshot Provider service status in test case check_quiesce_snapshot #539

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions windows/check_quiesce_snapshot/check_quiesce_snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"
Tomorrow9 marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
22 changes: 12 additions & 10 deletions windows/check_quiesce_snapshot/collect_vss_logs.yml
Original file line number Diff line number Diff line change
@@ -1,41 +1,43 @@
# 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 }}"
when:
- "'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 }}"
when:
- "'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
Expand Down
34 changes: 22 additions & 12 deletions windows/utils/win_enable_vss_log.yml
Original file line number Diff line number Diff line change
@@ -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 }}"
Expand All @@ -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'