@@ -2186,22 +2186,30 @@ def add_virtual_machine(self, obj):
21862186
21872187 # first try 'guestInfo.detailed.data' and then 'guestOS.detailed.data'
21882188 detailed_data = extra_config .get ("guestInfo.detailed.data" ) or extra_config .get ("guestOS.detailed.data" )
2189+
2190+ # if guestOS tools ar installed but are not able to determine the os-release
2191+ # then check against this pattern to guess if a correct os string has been returned
2192+ invalid_patterns = ["Usage:" , "Error:" , "command not found" , "No such file" ]
2193+
21892194 if isinstance (detailed_data , str ):
21902195 detailed_data_dict = dict ()
2196+ pretty_name = None
21912197 for detailed_data_item in quoted_split (detailed_data .replace ("' " , "', " )):
21922198 if "=" not in detailed_data_item :
21932199 continue
21942200
21952201 detailed_data_key , detailed_data_value = detailed_data_item .split ("=" )
21962202 detailed_data_dict [detailed_data_key ] = detailed_data_value .strip ("'" )
21972203 if len (detailed_data_dict .get ("prettyName" , "" )) > 0 :
2198- platform = detailed_data_dict .get ("prettyName" )
2199-
2200- distro_version = detailed_data_dict .get ("distroVersion" )
2201- if detailed_data_dict .get ("familyName" , "" ).lower () == "linux" and \
2202- distro_version is not None and \
2203- distro_version not in platform :
2204- platform = f'{ platform } { distro_version } '
2204+ pretty_name = detailed_data_dict .get ("prettyName" )
2205+
2206+ if pretty_name and not any (pretty_name .startswith (p ) for p in invalid_patterns ):
2207+ platform = pretty_name
2208+ distro_version = detailed_data_dict .get ("distroVersion" )
2209+ if detailed_data_dict .get ("familyName" , "" ).lower () == "linux" and \
2210+ distro_version is not None and \
2211+ distro_version not in platform :
2212+ platform = f'{ platform } { distro_version } '
22052213
22062214 if platform is not None :
22072215 platform = self .get_object_relation (platform , "vm_platform_relation" , fallback = platform )
0 commit comments