npe guard for get host info on vmware (#11054)

Co-authored-by: Daan Hoogland <dahn@apache.org>
This commit is contained in:
dahn 2025-07-17 14:25:00 +02:00 committed by GitHub
parent bf46458578
commit 714b04e3a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -75,7 +75,7 @@ import com.cloud.utils.Pair;
public class HostMO extends BaseMO implements VmwareHypervisorHost {
private static final Logger s_logger = Logger.getLogger(HostMO.class);
Map<String, VirtualMachineMO> _vmCache = new HashMap<String, VirtualMachineMO>();
Map<String, VirtualMachineMO> _vmCache = new HashMap<>();
//Map<String, String> _vmInternalNameMapCache = new HashMap<String, String>();
@ -320,6 +320,11 @@ public class HostMO extends BaseMO implements VmwareHypervisorHost {
public VmwareHostType getHostType() throws Exception {
AboutInfo aboutInfo = getHostAboutInfo();
if (aboutInfo == null) {
String msg = "no type info about host known, assuming ESXi";
s_logger.warn(msg);
return VmwareHostType.ESXi;
}
if ("VMware ESXi".equals(aboutInfo.getName()))
return VmwareHostType.ESXi;
else if ("VMware ESX".equals(aboutInfo.getName()))