bug 10100 : if there are more than one hypervisor type in one zone, create_template_from_snapshot may be sent to host with diferent hypervisor type

status 10100 : resolved fixed

Conflicts:

	server/src/com/cloud/storage/StorageManager.java
	server/src/com/cloud/vm/UserVmManagerImpl.java
This commit is contained in:
anthony 2011-06-01 15:37:54 -07:00
parent 36a04e4343
commit 1fb75c57e7
3 changed files with 21 additions and 3 deletions

View File

@ -186,4 +186,5 @@ public interface StorageManager extends Manager {
boolean createStoragePool(long hostId, StoragePoolVO pool);
boolean delPoolFromHost(long hostId);
List<StoragePoolVO> ListByDataCenterHypervisor(long datacenterId, HypervisorType type);
}

View File

@ -350,6 +350,23 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
return true;
}
}
@Override
public List<StoragePoolVO> ListByDataCenterHypervisor(long datacenterId, HypervisorType type) {
List<StoragePoolVO> pools = _storagePoolDao.listByDataCenterId(datacenterId);
List<StoragePoolVO> retPools = new ArrayList<StoragePoolVO>();
for (StoragePoolVO pool : pools ) {
if( pool.getStatus() != StoragePoolStatus.Up) {
continue;
}
ClusterVO cluster = _clusterDao.findById(pool.getClusterId());
if( type == cluster.getHypervisorType()) {
retPools.add(pool);
}
}
Collections.shuffle(retPools);
return retPools;
}
@Override
public boolean isLocalStorageActiveOnHost(Host host) {

View File

@ -1406,11 +1406,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
volumeId = snapshot.getVolumeId();
String origTemplateInstallPath = null;
List<StoragePoolVO> storagePools = _storagePoolDao.listByDataCenterId(zoneId);
if( storagePools == null || storagePools.size() == 0) {
List<StoragePoolVO> pools = _storageMgr.ListByDataCenterHypervisor(zoneId, snapshot.getHypervisorType());
if (pools == null || pools.size() == 0 ) {
throw new CloudRuntimeException("Unable to find storage pools in zone " + zoneId);
}
pool = storagePools.get(0);
pool = pools.get(0);
if (snapshot.getVersion() != null && snapshot.getVersion().equalsIgnoreCase("2.1")) {
VolumeVO volume = _volsDao.findByIdIncludingRemoved(volumeId);
if ( volume == null ) {