Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
npe guard for get host info on vmware
  • Loading branch information
Daan Hoogland authored and DaanHoogland committed Jul 8, 2025
commit 8fbdf696b58c69dda9950838faa180ab67146725
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

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>();

Expand Down Expand Up @@ -320,6 +320,11 @@ public AboutInfo getHostAboutInfo() throws Exception {

public VmwareHostType getHostType() throws Exception {
AboutInfo aboutInfo = getHostAboutInfo();
if (aboutInfo == null) {
String msg = "no type info about host known"
s_logger.error(msg)
throw new Exception(msg);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can it be defaulted to VmwareHostType.ESXi ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does it mean if the host does not have this info? Is it in a valid state then?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I never face this issue before, but I know some users have faced the issue.

If we throw an Exception with message, instead of NPE, I think it does not help, as user will still get an exception.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but at least it will be clear they have an ill-configured host.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be honest, I do not know what is misconfigured and any other issues caused by the misconfiguration.
I think we could consider the host as an ESXi host if the about info is not found.

anyone uses ESX host or other type of host ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, if y’all insist ;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's get more opinions

@nvazquez @harikrishna-patnala @sureshanaparti @shwstppr @rohityadavcloud
what's your opinion on it ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what I meant @weizhouapache , is your argument makes sense, I yield. Please see my changed code fragment at #11054 (comment).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agreed, assuming ESXi seems to be a good option.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense

Comment thread
DaanHoogland marked this conversation as resolved.
Outdated
}
if ("VMware ESXi".equals(aboutInfo.getName()))
return VmwareHostType.ESXi;
else if ("VMware ESX".equals(aboutInfo.getName()))
Expand Down