mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
[Vmware to KVM Migration] Fix issue with vCenter Standalone hosts for VM listing (#11091)
This commit is contained in:
parent
e47b78b2bb
commit
c782835f01
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user