This is an automated email from the ASF dual-hosted git repository. dahn pushed a commit to branch 4.19 in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.19 by this push: new c782835f012 [Vmware to KVM Migration] Fix issue with vCenter Standalone hosts for VM listing (#11091) c782835f012 is described below commit c782835f01241be8ffdca4d6afa9896990e994e6 Author: Nicolas Vazquez <nicovazque...@gmail.com> AuthorDate: Wed Jul 9 04:41:34 2025 -0300 [Vmware to KVM Migration] Fix issue with vCenter Standalone hosts for VM listing (#11091) --- .../java/com/cloud/hypervisor/vmware/mo/BaseMO.java | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java index 0d380bd7ff7..3f27f6c80fe 100644 --- a/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java +++ b/vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/BaseMO.java @@ -251,8 +251,9 @@ public class BaseMO { 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()); @@ -260,4 +261,20 @@ public class BaseMO { } } + /** + * 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("Cannot find a cluster for host %s, assuming standalone host, " + + "setting its cluster name as empty", hostName); + s_logger.info(msg); + return null; + } + } + }