Repository navigation
Closed
Description
Hello,
I have a Linux virtual machine that netbox-sync reports with the wrong OS.
These are OS details from VMware:
- OS according to the configuration file: Red Hat Enterprise Linux 7 (64-bit)
- OS according to the VMware Tools: Red Hat Enterprise Linux 8 (64-bit)
This is vm_platform_relation specified in settings.yaml:
Red Hat Enterprise Linux = Red Hat Enterprise Linux 7, Red Hat Enterprise Linux 7.* = Red Hat Enterprise Linux 7, Red Hat Enterprise Linux 8.* = Red Hat Enterprise Linux 8
netbox-sync sets Red Hat Enterprise Linux 7 as platform instead of Red Hat Enterprise Linux 8.
This is the log content (DEBUG3 enabled):
obj.config = (vim.vm.ConfigInfo) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
changeVersion = '2025-03-13T01:25:35.881082Z',
modified = 1970-01-01T00:00:00Z,
name = 'LINUX01',
guestFullName = 'Red Hat Enterprise Linux 7 (64-bit)',
...
(vim.option.OptionValue) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'guestOS.detailed.data',
value = "bitness='64' distroName='Red Hat Enterprise Linux Server' distroVersion='7.9' familyName='Linux' kernelVersion='3.10.0-1160.81.1.el7.x86_64' prettyName='Red Hat Enterprise Linux'"
},
...
(vim.option.OptionValue) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
key = 'guestInfo.detailed.data',
value = "architecture='X86' bitness='64' cpeString='cpe:/o:redhat:enterprise_linux:8::baseos' distroAddlVersion='8.10 (Ootpa)' distroName='Red Hat Enterprise Linux' distroVersion='8.10' familyName='Linux' kernelVersion='4.18.0-553.8.1.el8_10.x86_64' prettyName='Red Hat Enterprise Linux 8.10 (Ootpa)'"
},
...
obj.guest = (vim.vm.GuestInfo) {
dynamicType = <unset>,
dynamicProperty = (vmodl.DynamicProperty) [],
toolsStatus = 'toolsOk',
toolsVersionStatus = 'guestToolsUnmanaged',
toolsVersionStatus2 = 'guestToolsUnmanaged',
toolsRunningStatus = 'guestToolsRunning',
toolsVersion = '12389',
toolsInstallType = 'guestToolsTypeOpenVMTools',
guestId = 'rhel8_64Guest',
guestFamily = 'linuxGuest',
guestFullName = 'Red Hat Enterprise Linux 8 (64-bit)',
guestDetailedData = "architecture='X86' bitness='64' cpeString='cpe:/o:redhat:enterprise_linux:8::baseos' distroAddlVersion='8.10 (Ootpa)' distroName='Red Hat Enterprise Linux' distroVersion='8.10' familyName='Linux' kernelVersion='4.18.0-553.8.1.el8_10.x86_64' prettyName='Red Hat Enterprise Linux 8.10 (Ootpa)'",
...
As I understand, the function add_virtual_machine (connection.py) handles OS evaluation:
- The function first tries to extract the platform from
obj.config.guestFullName- platform = "Red Hat Enterprise Linux 7 (64-bit)" - If available, the function then attempts to retrieve a more accurate OS name from
obj.guest.guestFullName- platform = "Red Hat Enterprise Linux 8 (64-bit)" - Next, the function checks
obj.config.extraConfigfor the key "guestOS.detailed.data" - platform = "Red Hat Enterprise Linux"
Regarding the last point, instead of retrieving data from obj.config.extraConfig, wouldn't it be more appropriate to obtain detailed information from VMware Tools (if installed and running) via obj.guest.guestDetailedData ?
Activity
bb-Ricardo commentedon Mar 20, 2025
Hi,
this is very strange. The VM contains two
guestInfo.detailed.datain obj.config.extraConfig?lukedaemon commentedon Mar 20, 2025
Hello @bb-Ricardo,
the
obj.config.extraConfigcontains two different keys:guestOS.detailed.dataguestInfo.detailed.dataHere is the code inside
connection.pyresponsible for platform evaluation:Summary of OS Calculation Steps
config.guestFullNameguest.guestFullNameextraConfig(guestOS.detailed.data) forprettyName, if availableSo the
prettyNamecomes fromguestOS.detailed.dataand, in my case, is equal to Red Hat Enterprise Linux leading to an "incorrect" platform evaluation (the server has Red Hat Enterprise Linux 8.10).I suggest referring to
prettyNamefromguestInfo.detailed.data(if available), which, if I'm not mistaken, is retrieved from VMware Tools.According to this blog article New detailed GuestOS data in vSphere 8.0 Update 2, written by VMware person, in vSphere 8.0 Update 2 VMware enhanced the available GuestOS data using VMware Tools:
fixes issue with retrieving platform name for newer guest tools #448
bb-Ricardo commentedon Mar 21, 2025
Hi @lucafabbri365,
Thank you for doing all the research. I reworked the approach a bit. I pushed a change to the
developmentbranch. would you be able to test it?thank you
lukedaemon commentedon Mar 21, 2025
Hello @bb-Ricardo,
Yes, it works correctly. However, I suggest one more improvement.
In some cases, depending on the installed version of VMware Tools, the
prettyNamefield for Linux systems may not include the OS version.See the example below:
netbox-sync sets the
platformas Red Hat Enterprise Linux which is correct but the version is missing. I underestand this is quite specific to this particular case, but for Linux systems (familyName='Linux'), would it make sense to set theplatformasdistroName + " " + distroVersion?What's your thought ?
rblase2 commentedon Jun 16, 2025
Hi ! Any update on this ?
adds distroVersion to VM linux platform #448
bb-Ricardo commentedon Jun 17, 2025
Hi @lucafabbri365 , @rblase2 ,
I just pushed another commit. Would you be able to test it and see if this solves the linux distort version issue?
rblase2 commentedon Jun 17, 2025
Ok, first i got error :
But I have around 1,000 virtual machines, so I tried adding this.
Instead of this :
And I got the correct version for all my Ubuntu machines (plus some extra info about my Windows Server — I didn’t ask for it, but I needed it, so that was perfect!).
I got a second error later on with another vCenter :
And i fix it with:
But for this one, I’m pretty sure it depends on my vCenters, not your script.
So, thanks for reacting so quickly and providing a great solution — and of course, thanks for your work on this amazing script!
bb-Ricardo commentedon Jun 17, 2025
Hey, thank you so much for testing. I was on the bus and couldn't test it. I will fix the missing parts tomorrow and let you know.
fixes issue with parsing of vm guest data #448
bb-Ricardo commentedon Jun 18, 2025
Hi,
I just pushed another commit. Would you be able to test it? Thank you.
rblase2 commentedon Jun 18, 2025
Hey! I just gave it a try — first I synced with the MAIN commit, then I tested your new commit, and everything worked perfectly, no errors at all. Now I’m going to test it with my other vCenters. If I run into any bugs, I’ll get back to you.
fixes issue with retrieving platform name for newer guest tools #448
adds distroVersion to VM linux platform #448
fixes issue with parsing of vm guest data #448
fixes issue with retrieving platform name for newer guest tools #448
adds distroVersion to VM linux platform #448
fixes issue with parsing of vm guest data #448
Lense: port upstream fix for wrong platform evaluation (bb-Ricardo#448/…