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

fix: Try to convert ESX VM UUID after hw upgrade #415

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
23 changes: 21 additions & 2 deletions virtwho/virt/esx/esx.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,23 @@ def getVmUuid(self, vm):
From: 78563412-AB90-EFCD-1234-567890ABCDEF
To: 12345678-90AB-CDEF-1234-567890ABCDEF
"""
smbios_version_27 = None
s = vm['config.uuid']

# Try to some crazy heuristics
if "config.extraConfig" in vm:
extra_config = vm["config.extraConfig"]
for item in extra_config.OptionValue:
if item.key == "acpi.smbiosVersion2.7":
if item.value == "TRUE":
smbios_version_27 = True
elif item.value == "FALSE":
smbios_version_27 = False

if 'config.version' not in vm:
return s
version = int(vm['config.version'].split('-')[1])
if (version >= 13):
if version >= 13 or smbios_version_27 is False:
return s[6:8] + s[4:6] + s[2:4] + s[0:2] + "-" + s[11:13] + s[9:11] + "-" + s[16:18] + s[14:16] + s[18:]
else:
return s
Expand Down Expand Up @@ -419,7 +431,14 @@ def createFilter(self):
pfs = self.propertyFilterSpec()
pfs.objectSet = [oSpec]
pfs.propSet = [
self.createPropertySpec("VirtualMachine", ["config.uuid", "config.version", "runtime.powerState"]),
self.createPropertySpec("VirtualMachine",
[
"config.uuid",
"config.version",
"runtime.powerState",
"config.extraConfig"
]
),
self.createPropertySpec("ClusterComputeResource", ["name"]),
self.createPropertySpec("HostSystem", ["name",
"vm",
Expand Down
Loading