mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 8216: creating a vol from a snapshot will take in a priv disk offering id, which is used only for the tags; size is still taken from the original vol which the snapshot is based off of
This commit is contained in:
parent
d50ad65211
commit
1afc62e98f
@ -58,7 +58,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
||||
@Parameter(name=ApiConstants.SIZE, type=CommandType.LONG, description="Arbitrary volume size. Mutually exclusive with diskOfferingId")
|
||||
private Long size;
|
||||
|
||||
@Parameter(name=ApiConstants.SNAPSHOT_ID, type=CommandType.LONG, description="the snapshot ID for the disk volume. Either diskOfferingId or snapshotId must be passed in.")
|
||||
@Parameter(name=ApiConstants.SNAPSHOT_ID, type=CommandType.LONG, description="the snapshot ID for the disk volume. If snapshot id is passed in, a private disk offering id must be passed in as well (no disk size, only tags).")
|
||||
private Long snapshotId;
|
||||
|
||||
@Parameter(name=ApiConstants.ZONE_ID, type=CommandType.LONG, description="the ID of the availability zone")
|
||||
@ -145,7 +145,7 @@ public class CreateVolumeCmd extends BaseAsyncCreateCmd {
|
||||
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException{
|
||||
|
||||
|
||||
Volume volume = _storageService.allocVolume(this);
|
||||
if (volume != null) {
|
||||
this.setEntityId(volume.getId());
|
||||
|
||||
@ -518,7 +518,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
// Create an event
|
||||
Long templateId = originalVolume.getTemplateId();
|
||||
;
|
||||
Long diskOfferingId = originalVolume.getDiskOfferingId();
|
||||
Long diskOfferingId = volume.getDiskOfferingId();
|
||||
|
||||
if (createdVolume.getPath() != null) {
|
||||
Long offeringId = null;
|
||||
@ -1442,16 +1442,29 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
size = (size * 1024 * 1024 * 1024);// custom size entered is in GB, to be converted to bytes
|
||||
}
|
||||
} else {
|
||||
DiskOfferingVO privOffering = null;
|
||||
Long snapshotId = cmd.getSnapshotId();
|
||||
Snapshot snapshotCheck = _snapshotDao.findById(snapshotId);
|
||||
diskOfferingId = cmd.getDiskOfferingId();
|
||||
if (snapshotCheck == null) {
|
||||
throw new InvalidParameterValueException("unable to find a snapshot with id " + snapshotId);
|
||||
}
|
||||
|
||||
if(diskOfferingId == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid private disk offering");
|
||||
} else {
|
||||
privOffering = _diskOfferingDao.findById(diskOfferingId);
|
||||
if(privOffering == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid private disk offering");
|
||||
} else {
|
||||
if(!privOffering.isCustomized())
|
||||
throw new InvalidParameterValueException("Please specify a valid private disk offering");
|
||||
}
|
||||
}
|
||||
|
||||
VolumeVO vol = _volsDao.findByIdIncludingRemoved(snapshotCheck.getVolumeId());
|
||||
zoneId = vol.getDataCenterId();
|
||||
diskOfferingId = vol.getDiskOfferingId();
|
||||
size = vol.getSize();
|
||||
size = vol.getSize(); //we maintain size from org vol ; disk offering is used for tags purposes
|
||||
|
||||
if (account != null) {
|
||||
if (isAdmin(account.getType())) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user