Skip to content

[Windows] Fix guest OS fullname issue #681

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion windows/check_inbox_driver/get_inbox_driver_info.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
block:
- name: "Set fact of the file path for recording inbox drivers info"
ansible.builtin.set_fact:
drivers_info_file_path: "{{ current_test_log_folder }}/{{ ('-').join(guest_os_ansible_distribution.split(' ')[1:-1]) }}-{{ guest_os_build_num }}-{{ guest_os_ansible_architecture.replace('-', '') }}.json"
drivers_info_file_path: "{{ current_test_log_folder }}/{{ ('-').join(guest_os_ansible_distribution.split(' ')[1:]) }}-{{ guest_os_build_num }}-{{ guest_os_ansible_architecture.replace('-', '') }}.json"
- name: "Dump inbox drivers info to json file"
ansible.builtin.copy:
dest: "{{ drivers_info_file_path }}"
Expand Down
117 changes: 42 additions & 75 deletions windows/check_os_fullname/check_os_fullname.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,97 +2,64 @@
# SPDX-License-Identifier: BSD-2-Clause
---
# Description:
# This test case is used for check VM guest OS fullname is reported correctly
# in guest info through VMware Tools. When VMware Tools is not installed or not
# running in VM, this test case result is 'No Run'.
# This test case is used for checking VM guest OS fullname
# and guest OS ID are reported correctly in the VM guest info
# by VMware Tools. When VMware Tools is not installed or not
# running in the guest OS, this test case result is 'Blocked'.
#
- name: check_os_fullname
hosts: localhost
gather_facts: false
tasks:
- block:
- include_tasks: ../setup/test_setup.yml
- name: "Test case block"
block:
- name: "Test setup"
include_tasks: ../setup/test_setup.yml
vars:
skip_test_no_vmtools: true

# Get OS info inside guest OS
- include_tasks: ../utils/win_get_fullname.yml
- ansible.builtin.debug:
msg:
- "Get guest fullname in guest OS: {{ os_fullname_guest }}"
- "Get OS architecture in guest OS: {{ guest_os_ansible_architecture }}"
- "VM guest ID is: {{ vm_guest_id }}"

# Get ESXi version info if not defined
- include_tasks: ../../common/esxi_get_version_build.yml
when: >
(esxi_version is undefined) or
(esxi_version == 'N/A')
- name: "Get VM guest info"
include_tasks: ../../common/vm_get_guest_info.yml

# Get guest fullname from VM guest info
- include_tasks: ../../common/vm_get_guest_info.yml
- name: "Set fact of the pre-defined guest OS info list"
include_tasks: win_guest_os_info.yml

- name: "Known issue - ignore incorrect guestID of Windows 11"
- name: "Print the guest OS info before checking"
ansible.builtin.debug:
msg:
- "The guestID of Windows 11 guest in guestinfo is empty on ESXi 7.0U3c. Ignore this known issue."
- "Please refer to https://knowledge.broadcom.com/external/article?legacyId=86517."
tags:
- known_issue
when:
- not guestinfo_guest_id
- esxi_version is defined and esxi_version
- esxi_version is version('7.0.3', '=')
- esxi_build is defined and esxi_build
- esxi_build == "19193900"
- "'Windows 11' in os_fullname_guest"
- vmtools_version is defined and vmtools_version
- vmtools_version is version('12.0.0', '>=')
- name: "Check guest ID got from guest info is not empty"
- "OS architecture got in guest OS: {{ guest_os_ansible_architecture }}"
- "OS fullname got in guest OS: {{ guest_os_ansible_distribution }}"
- "OS fullname got in VM guest info: {{ guestinfo_guest_full_name }}"
- "VM guest ID configured: {{ vm_guest_id }}"
- "VM guest ID got in VM guest info: {{ guestinfo_guest_id }}"
- "VM hardware version: {{ vm_hardware_version }}"

- name: "Set fact of current OS name"
ansible.builtin.set_fact:
current_gos: "{{ guest_os_ansible_distribution.strip('Microsoft ') }}"

- name: "Get OS info in the pre-defined guest OS info list matched current OS"
ansible.builtin.set_fact:
current_gos_info: "{{ win_gos_info | selectattr('win_guest', 'equalto', current_gos) }}"

- name: "Check current OS in the pre-defined guest OS info list"
ansible.builtin.assert:
that:
- guestinfo_guest_id
fail_msg: "Guest ID in guest info is '{{ guestinfo_guest_id }}', which should be a valid value firstly."
when: >
(not "'Windows 11' in os_fullname_guest") or
(esxi_version is undefined) or
(not esxi_version is version('7.0.3', '=')) or
(esxi_version is version('7.0.3', '=') and (esxi_build is undefined or esxi_build != "19193900")) or
(vmtools_version is undefined or vmtools_version is version('12.0.0', '<'))
- current_gos_info | length == 1
fail_msg: >
"The pre-defined guest OS info list does not contain this OS version: {{ current_gos }},
please check whether this guest OS is supported and add it to the list accordingly."

- name: Initialize the expected guest fullname
- name: "Set fact of the matched current OS info"
ansible.builtin.set_fact:
expected_guest_fullname: ""
# Set expected guest fullname for Windows client
- block:
- include_tasks: win10_fullname.yml
when: "'Windows 10' in os_fullname_guest"
- include_tasks: win11_fullname.yml
when: "'Windows 11' in os_fullname_guest"
when: guest_os_product_type == "client"
current_gos_info: "{{ current_gos_info[0] }}"

# Set expected guest fullname for Windows Server
- block:
- block:
- include_tasks: winsrv2016orlater_fullname.yml
- include_tasks: winsrv2019_fullname.yml
when: not "'Windows Server 2022' in os_fullname_guest"
- include_tasks: winsrv2022_fullname.yml
when:
- "'Windows Server 2022' in os_fullname_guest"
- guest_os_build_num | int == 20348
- include_tasks: winsrvnext_fullname.yml
when:
- guest_os_build_num | int >= 22424
when: guest_os_product_type != "client"
- name: "Handle Windows 11 known issue"
include_tasks: win11_guest_info_exception.yml

- ansible.builtin.debug:
msg: "Expected guest fullname on ESXi '{{ esxi_version }}': {{ expected_guest_fullname }}"
- name: "Verify guest fullname in guest info is expected"
ansible.builtin.assert:
that:
- expected_guest_fullname != ""
- (guestinfo_guest_full_name == expected_guest_fullname) or (expected_guest_fullname is string and expected_guest_fullname in guestinfo_guest_full_name) or (expected_guest_fullname | type_debug == 'list' and guestinfo_guest_full_name in expected_guest_fullname)
fail_msg: "Guest fullname in guest info: {{ guestinfo_guest_full_name }}, is not the same as expected one: {{ expected_guest_fullname }}."
- name: "Check guest fullname in VM guest info"
include_tasks: check_vm_guest_info.yml
when: win11_70u3c_exception is undefined
rescue:
- include_tasks: ../../common/test_rescue.yml
- name: "Test case failure"
include_tasks: ../../common/test_rescue.yml
73 changes: 73 additions & 0 deletions windows/check_os_fullname/check_vm_guest_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Copyright 2025 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause
---
- name: "Initialize the facts of expected configured guest ID and guest fullname"
ansible.builtin.set_fact:
current_guest_id_expected: false
current_os_recognized: false

- name: "Get supported guest IDs on ESXi {{ esxi_version }} with hardware version {{ vm_hardware_version_num }}"
include_tasks: ../../common/esxi_get_guest_ids.yml
vars:
esxi_hardware_version: "{{ vm_hardware_version_num }}"

# Set expected guest ID corresponding to current OS
- name: "Set fact of expected guest ID of current {{ guest_os_ansible_architecture }} OS"
ansible.builtin.set_fact:
current_os_guest_id: "{{ (guest_os_ansible_architecture == '64-bit' | ternary(current_gos_info.win_guest_id | select('match', '.*64Guest'), current_gos_info.win_guest_id | reject('match', '.*64Guest')))[0] }}"

- name: "Get the previous OS info in the pre-defined guest OS info list"
include_tasks: get_previous_gos_info.yml

# Set expected guest ID corresponding to previous OS version
- name: "Set fact of expected guest ID of previous {{ guest_os_ansible_architecture }} OS"
ansible.builtin.set_fact:
previous_os_guest_id: "{{ (guest_os_ansible_architecture == '64-bit' | ternary(previous_gos_info.win_guest_id | select('match', '.*64Guest'), previous_gos_info.win_guest_id' | reject('match', '.*64Guest')))[0] }}"

# VM configured guest ID should be the current OS guest ID when it's defined
# and supported for create on ESXi
- name: "Set fact of the current guest ID is the expected configured VM guest ID"
ansible.builtin.set_fact:
current_guest_id_expected: true
when:
- esxi_version is version(current_gos_info.win_guest_creation_esxi, '>=')
- vm_hardware_version_num | int >= current_gos_info.win_guest_creation_hwv | int

# Guest OS can be recognized
- name: "Set fact of the current OS fullname is the expected guest OS fullname"
ansible.builtin.set_fact:
current_os_recognized: true
when: >
(esxi_version is version(current_gos_info.win_guest_creation_esxi, '>=')) or
(current_gos_info.win_guest_add_esxi is defined and
esxi_version is version(current_gos_info.win_guest_add_esxi, '>=') and
esxi_version is version(current_gos_info.win_guest_creation_esxi, '<')
vmtools_version is version(current_gos_info.win_guest_vmtools, '>='))

# Guest ID of previous OS version is configured
- name: "Check guest ID and fullname in VM guest info"
ansible.builtin.assert:
that:
- vm_guest_id == previous_os_guest_id
- guestinfo_guest_id == (current_os_recognized | ternary(current_os_guest_id, vm_guest_id))
- guestinfo_guest_full_name in (current_os_recognized | ternary(current_gos_info.win_guest_fullname, previous_gos_info.win_guest_fullname))
fail_msg:
- "VM guest ID configured '{{ vm_guest_id }}' should be the guest ID corresponding to previous OS version '{{ previous_os_guest_id }}',"
- "Guest ID in VM guest info '{{ guestinfo_guest_id }}' should be equal to '{{ current_os_recognized | ternary(current_os_guest_id, vm_guest_id) }}',"
- "Guest fullname in VM guest info '{{ guestinfo_guest_full_name }}' should be in '{{ current_os_recognized | ternary(current_gos_info.win_guest_fullname, previous_gos_info.win_guest_fullname) }}'."
when:
- not current_guest_id_expected

# Guest ID of current OS version is configured
- name: "Check guest ID and fullname in VM guest info"
ansible.builtin.assert:
that:
- vm_guest_id == current_os_guest_id
- guestinfo_guest_id == vm_guest_id
- guestinfo_guest_full_name in current_gos_info['win_guest_fullname']
fail_msg:
- "VM guest ID configured '{{ vm_guest_id }}' should be the guest ID corresponding to current OS version '{{ current_os_guest_id }}',"
- "Guest ID in VM guest info '{{ guestinfo_guest_id }}' should be equal to the configured guest ID '{{ vm_guest_id }}',"
- "Guest fullname in VM guest info '{{ guestinfo_guest_full_name }}' should be in the expected list '{{ current_gos_info['win_guest_fullname'] }}'."
when:
- current_guest_id_expected
42 changes: 42 additions & 0 deletions windows/check_os_fullname/get_previous_gos_info.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright 2025 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause
---
# Get the previous guest OS info in the pre-defined 'win_gos_info'
# before the current guest OS version
- name: "Initialize the previous guest OS info"
ansible.builtin.set_fact:
previous_gos_info: ""

- name: "Set fact of the Windows Server guest OS info"
ansible.builtin.set_fact:
gos_list: "{{ win_gos_info | selectattr('win_guest', 'search', 'Server') }}"

- name: "Set fact of the Windows Client guest OS info"
ansible.builtin.set_fact:
gos_list: "{{ win_gos_info | difference(gos_list) }}"
when: guest_os_product_type == "client"

- name: "Sort the guest OS info list"
ansible.builtin.set_fact:
gos_list: "{{ gos_list | sort(attribute='win_guest', reverse=true) }}"

- debug: var=gos_list

- name: "Set fact of the index of current guest OS in the list"
ansible.builtin.set_fact:
current_gos_index: "{{ (gos_list | map(attribute='win_guest') | list).index(current_gos) }}"

- debug: var=current_gos_index

- name: "No previous guest OS in the list"
ansible.builtin.debug:
msg: "Current guest OS '{{ current_gos }}' has no previous earlier version in the defeined guest OS info list."
when: current_gos_index | int == gos_list | length - 1

- name: "Set fact of the previous guest OS"
ansible.builtin.set_fact:
previous_gos_info: "{{ gos_list[current_gos_index | int + 1] }}"
when: current_gos_index | int < gos_list | length - 1

- name: "Print the previous guest OS info"
ansible.builtin.debug: var=previous_gos_info
12 changes: 0 additions & 12 deletions windows/check_os_fullname/win10_fullname.yml

This file was deleted.

41 changes: 0 additions & 41 deletions windows/check_os_fullname/win11_fullname.yml

This file was deleted.

27 changes: 27 additions & 0 deletions windows/check_os_fullname/win11_guest_info_exception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Copyright 2025 VMware, Inc.
# SPDX-License-Identifier: BSD-2-Clause
---
# On ESXi 7.0U3c, guest fullname is 'Windows 11 Enterprise, 64-bit (Build xxxxx)',
# guest ID is empty in VM guest info.
#
- name: "Set fact of the exception of Windows 11 guest fullname"
ansible.builtin.set_fact:
win11_70u3c_exception: true
when:
- guest_os_ansible_distribution is search('Windows 11')
- esxi_version is version('7.0.3', '=')
- esxi_build == "19193900"
- vmtools_version is version('12.0.0', '>=')
- guestinfo_guest_id == ''
- guestinfo_guest_full_name is search('Build')

- name: "Known issue - incorrect/empty guestID in guest info of Windows 11"
ansible.builtin.debug:
msg:
- "The guestID of Windows 11 guest in guestinfo is empty on ESXi 7.0U3c. Ignore this known issue."
- "Please refer to https://knowledge.broadcom.com/external/article?legacyId=86517."
tags:
- known_issue
when:
- win11_70u3c_exception is defined
- win11_70u3c_exception
Loading