|
29 | 29 | from module.sources.common.source_base import SourceBase |
30 | 30 | from module.sources.vmware.config import VMWareConfig |
31 | 31 | from module.common.logging import get_logger, DEBUG3 |
32 | | -from module.common.misc import grab, dump, get_string_or_none, plural |
| 32 | +from module.common.misc import grab, dump, get_string_or_none, plural, quoted_split |
33 | 33 | from module.common.support import normalize_mac_address |
34 | 34 | from module.netbox.inventory import NetBoxInventory |
35 | 35 | from module.netbox import * |
@@ -2162,7 +2162,14 @@ def add_virtual_machine(self, obj): |
2162 | 2162 | # first check against vm_platform_relation |
2163 | 2163 | platform = get_string_or_none(grab(obj, "config.guestFullName")) |
2164 | 2164 | platform = get_string_or_none(grab(obj, "guest.guestFullName", fallback=platform)) |
2165 | | - platform = get_string_or_none(grab(obj, "guest.guestDetailedData.prettyName", fallback=platform)) |
| 2165 | + |
| 2166 | + # extract prettyName from extraConfig exposed by guest tools |
| 2167 | + extra_config = [x.value for x in grab(obj, "config.extraConfig", fallback=[]) |
| 2168 | + if x.key == "guestOS.detailed.data"] |
| 2169 | + if len(extra_config) > 0: |
| 2170 | + pretty_name = [x for x in quoted_split(extra_config[0].replace("' ", "', ")) if x.startswith("prettyName")] |
| 2171 | + if len(pretty_name) > 0: |
| 2172 | + platform = pretty_name[0].replace("prettyName='","") |
2166 | 2173 |
|
2167 | 2174 | if platform is not None: |
2168 | 2175 | platform = self.get_object_relation(platform, "vm_platform_relation", fallback=platform) |
|
0 commit comments