bug 11428: Under VMware with current version, for snapshot related related operations,

1) if snapshot is originally created from root volume, allow only CreateTemplateCommand from snapshot 2) if snapshot is originally created from data volume, allow only CreateVolumeCommand from snapshot Reviewed by - Kishan
status 11428: resolved fixed
This commit is contained in:
Nitin 2011-11-09 16:33:09 +05:30
parent 507bc20c03
commit e2e7da3ff4
2 changed files with 17 additions and 2 deletions

View File

@ -107,6 +107,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;
@ -1674,6 +1675,12 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
//check snapshot permissions
_accountMgr.checkAccess(caller, null, snapshotCheck);
// bug #11428. Operation not supported if vmware and snapshots parent volume = ROOT
if(snapshotCheck.getHypervisorType() == HypervisorType.VMware
&& _volumeDao.findByIdIncludingRemoved(snapshotCheck.getVolumeId()).getVolumeType() == Type.ROOT){
throw new UnsupportedServiceException("operation not supported, snapshot with id " + snapshotId + " is created from ROOT volume");
}
}
// Verify that zone exists

View File

@ -108,6 +108,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;
@ -1357,6 +1358,9 @@ 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());
VolumeVO snapshotVolume = _volsDao.findByIdIncludingRemoved(snapshot.getVolumeId());
if (snapshot == null) {
throw new InvalidParameterValueException("Failed to create private template record, unable to find snapshot " + snapshotId);
}
@ -1367,11 +1371,15 @@ 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 && snapshotVolume.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());
hyperType = snapshot.getHypervisorType();
}
VMTemplateVO existingTemplate = _templateDao.findByTemplateNameAccountId(name, accountId);