Skip to content

[Vmware to KVM Migration] Fix issue with vCenter Standalone hosts for VM listing #11091

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: 4.19
Choose a base branch
from
Open
Changes from all commits
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,30 @@
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("Cannot find a cluster for host %s, assuming standalone host, " +

Check warning on line 273 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-L273

Added lines #L268 - L273 were not covered by tests
"setting its cluster name as empty", hostName);
s_logger.info(msg);
return null;

Check warning on line 276 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#L275-L276

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

Check warning on line 278 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#L278

Added line #L278 was not covered by tests

}
Loading