Add sanity check to allow only adding the right hypervisor hosts to the matched cluster

This commit is contained in:
Kelven Yang 2011-01-04 22:09:52 -08:00
parent 8ec1a329bf
commit 4be13ee8a4
3 changed files with 2976 additions and 2472 deletions

File diff suppressed because it is too large Load Diff

View File

@ -185,6 +185,14 @@ public class KvmServerDiscoverer extends DiscovererBase implements Discoverer,
public Map<? extends ServerResource, Map<String, String>> find(long dcId,
Long podId, Long clusterId, URI uri, String username,
String password) throws DiscoveryException {
ClusterVO cluster = _clusterDao.findById(clusterId);
if(cluster == null || cluster.getHypervisorType() != HypervisorType.KVM) {
if(s_logger.isInfoEnabled())
s_logger.info("invalid cluster id or cluster is not for KVM hypervisors");
return null;
}
Map<KvmDummyResourceBase, Map<String, String>> resources = new HashMap<KvmDummyResourceBase, Map<String, String>>();
Map<String, String> details = new HashMap<String, String>();
if (!uri.getScheme().equals("http")) {

View File

@ -119,6 +119,13 @@ public class XcpServerDiscoverer extends DiscovererBase implements Discoverer, L
throw new RuntimeException(msg);
}
ClusterVO cluster = _clusterDao.findById(clusterId);
if(cluster == null || (cluster.getHypervisorType() != HypervisorType.XenServer && cluster.getHypervisorType() != HypervisorType.Xen)) {
if(s_logger.isInfoEnabled())
s_logger.info("invalid cluster id or cluster is not for Xen/XenServer hypervisors");
return null;
}
try {
List<HostVO> eHosts = _hostDao.listByCluster(clusterId);
if( eHosts.size() > 0 ) {