diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index af160abdf48..cdc431eb7a0 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -109,6 +109,7 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceInUseException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.StorageUnavailableException; +import com.cloud.exception.UnsupportedServiceException; import com.cloud.host.Host; import com.cloud.host.HostVO; import com.cloud.host.Status; @@ -1712,6 +1713,12 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag throw new InvalidParameterValueException("unable to find a snapshot with id " + snapshotId + " for this account"); } } + + // bug #11428. Operation not supported if vmware and snapshots parent volume = ROOT + if(snapshotCheck.getHypervisorType() == HypervisorType.VMware + && ApiDBUtils.findVolumeById(snapshotCheck.getVolumeId()).getVolumeType() == Type.ROOT){ + throw new UnsupportedServiceException("operation not supported, snapshot with id " + snapshotId + " is created from ROOT volume"); + } } // Verify that zone exists diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index ae85cb91c94..ce0427dffcf 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -105,6 +105,7 @@ import com.cloud.exception.PermissionDeniedException; import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.exception.StorageUnavailableException; +import com.cloud.exception.UnsupportedServiceException; import com.cloud.exception.VirtualMachineMigrationException; import com.cloud.ha.HighAvailabilityManager; import com.cloud.host.Host; @@ -1394,6 +1395,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager hyperType = _volsDao.getHypervisorType(volumeId); } else { // create template from snapshot SnapshotVO snapshot = _snapshotDao.findById(snapshotId); + volume = _volsDao.findById(snapshot.getVolumeId()); + if (snapshot == null) { throw new InvalidParameterValueException("Failed to create private template record, unable to find snapshot " + snapshotId); } @@ -1401,11 +1404,16 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (snapshot.getStatus() != Snapshot.Status.BackedUp) { throw new InvalidParameterValueException("Snapshot id=" + snapshotId + " is not in " + Snapshot.Status.BackedUp + " state yet and can't be used for template creation"); } + + // bug #11428. Operation not supported if vmware and snapshots parent volume = ROOT + if(snapshot.getHypervisorType() == HypervisorType.VMware && volume.getVolumeType() == Type.DATADISK){ + throw new UnsupportedServiceException("operation not supported, snapshot with id " + snapshotId + " is created from Data Disk"); + } domainId = snapshot.getDomainId(); accountId = snapshot.getAccountId(); hyperType = snapshot.getHypervisorType(); - volume = _volsDao.findById(snapshot.getVolumeId()); + } if (!isAdmin) {