Skip to content
Merged
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