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
Original file line number Diff line number Diff line change
Expand Up @@ -251,13 +251,29 @@
hostClusterPair = hostClusterNamesMap.get(hostMorValue);
} else {
HostMO hostMO = new HostMO(_context, hostMor);
ClusterMO clusterMO = new ClusterMO(_context, hostMO.getHyperHostCluster());
hostClusterPair = new Pair<>(hostMO.getHostName(), clusterMO.getName());
String hostName = hostMO.getHostName();
String clusterName = getClusterNameFromHostIncludingStandaloneHosts(hostMO, hostName);
hostClusterPair = new Pair<>(hostName, clusterName);

Check warning on line 256 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java#L254-L256

Added lines #L254 - L256 were not covered by tests
hostClusterNamesMap.put(hostMorValue, hostClusterPair);
}
vm.setHostName(hostClusterPair.first());
vm.setClusterName(hostClusterPair.second());
}
}

/**
* Return the cluster name of the host on the vCenter
* @return null in case the host is standalone (doesn't belong to a cluster), cluster name otherwise
*/
private String getClusterNameFromHostIncludingStandaloneHosts(HostMO hostMO, String hostName) {
try {
ClusterMO clusterMO = new ClusterMO(_context, hostMO.getHyperHostCluster());
return clusterMO.getName();
} catch (Exception e) {
String msg = String.format("Standalone host %s found, setting empty cluster field", hostName);
s_logger.debug(msg);
Copy link
Contributor

@DaanHoogland DaanHoogland Jun 26, 2025

Choose a reason for hiding this comment

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

Suggested change
String msg = String.format("Standalone host %s found, setting empty cluster field", hostName);
s_logger.debug(msg);
String msg = String.format(Host %s not found, assuming standalone host, setting cluster name as empty", hostName);
s_logger.info(msg);

Copy link
Contributor Author

@nvazquez nvazquez Jul 7, 2025

Choose a reason for hiding this comment

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

Hi @DaanHoogland the host is found, but not its cluster. Let me rephrase it a bit

return null;

Check warning on line 275 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java#L268-L275

Added lines #L268 - L275 were not covered by tests
}
}

Check warning on line 277 in vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java

View check run for this annotation

Codecov / codecov/patch

vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java#L277

Added line #L277 was not covered by tests

}