mirror of https://github.com/apache/cloudstack.git
bug CS-14739: Check for the volume and vm hypervisor compatibility before attaching the volume to vm in case the volume is on secondary storage.
This commit is contained in:
parent
32085c960e
commit
8ac10c5941
|
|
@ -33,7 +33,7 @@ public interface Volume extends ControlledEntity, BasedOn, StateObject<Volume.St
|
|||
Expunging("The volume is being expunging"),
|
||||
Destroy("The volume is destroyed, and can't be recovered."),
|
||||
Uploading ("The volume upload is in progress"),
|
||||
Uploaded ("The volume is uploaded"),
|
||||
Uploaded ("The volume is uploaded and present on secondary storage"),
|
||||
UploadError ("The volume couldnt be uploaded");
|
||||
|
||||
String _description;
|
||||
|
|
|
|||
|
|
@ -226,4 +226,6 @@ public interface StorageManager extends StorageService, Manager {
|
|||
Long clusterId, ServiceOfferingVO offering,
|
||||
DiskOfferingVO diskOffering, List<StoragePoolVO> avoids, long size,
|
||||
HypervisorType hyperType) throws NoTransitionException;
|
||||
|
||||
String getSupportedImageFormatForCluster(Long clusterId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3802,4 +3802,21 @@ public class StorageManagerImpl implements StorageManager, Manager, ClusterManag
|
|||
return _volumeDao.search(sc, searchFilter);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSupportedImageFormatForCluster(Long clusterId) {
|
||||
ClusterVO cluster = ApiDBUtils.findClusterById(clusterId);
|
||||
|
||||
if (cluster.getHypervisorType() == HypervisorType.XenServer) {
|
||||
return "vhd";
|
||||
} else if (cluster.getHypervisorType() == HypervisorType.KVM) {
|
||||
return "qcow2";
|
||||
} else if (cluster.getHypervisorType() == HypervisorType.VMware) {
|
||||
return "ova";
|
||||
} else if (cluster.getHypervisorType() == HypervisorType.Ovm) {
|
||||
return "raw";
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -590,6 +590,11 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
volume = _storageMgr.createVolume(volume, vm, rootDiskTmplt, dcVO, pod, rootDiskPool.getClusterId(), svo, diskVO, new ArrayList<StoragePoolVO>(), volume.getSize(), rootDiskHyperType);
|
||||
}else {
|
||||
try {
|
||||
// Format of data disk should be the same as root disk
|
||||
if(_storageMgr.getSupportedImageFormatForCluster(rootDiskPool.getClusterId()) != volHostVO.getFormat().getFileExtension()){
|
||||
throw new InvalidParameterValueException("Failed to attach volume to VM since volumes format " +volHostVO.getFormat().getFileExtension()+
|
||||
" is not compatible with the vm hypervisor type" );
|
||||
}
|
||||
volume = _storageMgr.copyVolumeFromSecToPrimary(volume, vm, rootDiskTmplt, dcVO, pod, rootDiskPool.getClusterId(), svo, diskVO, new ArrayList<StoragePoolVO>(), volume.getSize(), rootDiskHyperType);
|
||||
} catch (NoTransitionException e) {
|
||||
e.printStackTrace();
|
||||
|
|
|
|||
Loading…
Reference in New Issue