Skip to content

Commit 714b04e

Browse files
DaanHooglandDaan Hoogland
andauthored
npe guard for get host info on vmware (#11054)
Co-authored-by: Daan Hoogland <[email protected]>
1 parent bf46458 commit 714b04e

File tree

1 file changed

+6
-1
lines changed
  • vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo

1 file changed

+6
-1
lines changed

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/HostMO.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
public class HostMO extends BaseMO implements VmwareHypervisorHost {
7777
private static final Logger s_logger = Logger.getLogger(HostMO.class);
78-
Map<String, VirtualMachineMO> _vmCache = new HashMap<String, VirtualMachineMO>();
78+
Map<String, VirtualMachineMO> _vmCache = new HashMap<>();
7979

8080
//Map<String, String> _vmInternalNameMapCache = new HashMap<String, String>();
8181

@@ -320,6 +320,11 @@ public AboutInfo getHostAboutInfo() throws Exception {
320320

321321
public VmwareHostType getHostType() throws Exception {
322322
AboutInfo aboutInfo = getHostAboutInfo();
323+
if (aboutInfo == null) {
324+
String msg = "no type info about host known, assuming ESXi";
325+
s_logger.warn(msg);
326+
return VmwareHostType.ESXi;
327+
}
323328
if ("VMware ESXi".equals(aboutInfo.getName()))
324329
return VmwareHostType.ESXi;
325330
else if ("VMware ESX".equals(aboutInfo.getName()))

0 commit comments

Comments
 (0)