From 7c1fa010cb2325fb95456bb110a2e41860a95209 Mon Sep 17 00:00:00 2001 From: Ricardo Bartels Date: Mon, 9 Mar 2026 08:27:37 +0100 Subject: [PATCH] adds detecction of missing os tools to report os-release #495 --- .github/workflows/docker-image.yml | 2 +- module/sources/vmware/connection.py | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 8931bfb..5f25ff6 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -71,7 +71,7 @@ jobs: id: meta_dhub uses: docker/metadata-action@v5 with: - images: docker.io/bbricardo/${{ steps.docker_image.outputs.lowercase }} + images: docker.io/bbricardo/netbox-sync:${{ github.ref.name }} tags: | type=semver,pattern={{version}} type=ref,event=branch diff --git a/module/sources/vmware/connection.py b/module/sources/vmware/connection.py index fe416a7..0d5c945 100644 --- a/module/sources/vmware/connection.py +++ b/module/sources/vmware/connection.py @@ -2186,8 +2186,14 @@ class VMWareHandler(SourceBase): # first try 'guestInfo.detailed.data' and then 'guestOS.detailed.data' detailed_data = extra_config.get("guestInfo.detailed.data") or extra_config.get("guestOS.detailed.data") + + # if guestOS tools ar installed but are not able to determine the os-release + # then check against this pattern to guess if a correct os string has been returned + invalid_patterns = ["Usage:", "Error:", "command not found", "No such file"] + if isinstance(detailed_data, str): detailed_data_dict = dict() + pretty_name = None for detailed_data_item in quoted_split(detailed_data.replace("' ", "', ")): if "=" not in detailed_data_item: continue @@ -2195,13 +2201,15 @@ class VMWareHandler(SourceBase): detailed_data_key, detailed_data_value = detailed_data_item.split("=") detailed_data_dict[detailed_data_key] = detailed_data_value.strip("'") if len(detailed_data_dict.get("prettyName", "")) > 0: - platform = detailed_data_dict.get("prettyName") - - distro_version = detailed_data_dict.get("distroVersion") - if detailed_data_dict.get("familyName", "").lower() == "linux" and \ - distro_version is not None and \ - distro_version not in platform: - platform = f'{platform} {distro_version}' + pretty_name = detailed_data_dict.get("prettyName") + + if pretty_name and not any(pretty_name.startswith(p) for p in invalid_patterns): + platform = pretty_name + distro_version = detailed_data_dict.get("distroVersion") + if detailed_data_dict.get("familyName", "").lower() == "linux" and \ + distro_version is not None and \ + distro_version not in platform: + platform = f'{platform} {distro_version}' if platform is not None: platform = self.get_object_relation(platform, "vm_platform_relation", fallback=platform)