nvazquez commented on code in PR #11091:
URL: https://github.com/apache/cloudstack/pull/11091#discussion_r2189590190
##########
vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java:
##########
@@ -251,13 +251,29 @@ private void
setUnmanagedInstanceTOHostAndCluster(UnmanagedInstanceTO vm, Manage
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);
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);
Review Comment:
Hi @DaanHoogland the host is found, but not its cluster. Let me rephrase it
a bit
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]