mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 8216: create volume from snapshot can take a disk_offering_id, if disk_offering_id is not specified, use the one from original volume
status 8216: resolved fixed
This commit is contained in:
parent
8571d04034
commit
cd27202a26
@ -52,7 +52,10 @@ public class SnapshotVO implements Snapshot {
|
||||
long domainId;
|
||||
|
||||
@Column(name="volume_id")
|
||||
Long volumeId;
|
||||
Long volumeId;
|
||||
|
||||
@Column(name="disk_offering_id")
|
||||
Long diskOfferingId;
|
||||
|
||||
@Expose
|
||||
@Column(name="path")
|
||||
@ -94,11 +97,12 @@ public class SnapshotVO implements Snapshot {
|
||||
|
||||
public SnapshotVO() { }
|
||||
|
||||
public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, String path, String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType) {
|
||||
public SnapshotVO(long dcId, long accountId, long domainId, Long volumeId, Long diskOfferingId, String path, String name, short snapshotType, String typeDescription, long size, HypervisorType hypervisorType) {
|
||||
this.dataCenterId = dcId;
|
||||
this.accountId = accountId;
|
||||
this.domainId = domainId;
|
||||
this.volumeId = volumeId;
|
||||
this.volumeId = volumeId;
|
||||
this.diskOfferingId = diskOfferingId;
|
||||
this.path = path;
|
||||
this.name = name;
|
||||
this.snapshotType = snapshotType;
|
||||
@ -132,6 +136,10 @@ public class SnapshotVO implements Snapshot {
|
||||
return volumeId;
|
||||
}
|
||||
|
||||
public long getDiskOfferingId() {
|
||||
return diskOfferingId;
|
||||
}
|
||||
|
||||
public void setVolumeId(Long volumeId) {
|
||||
this.volumeId = volumeId;
|
||||
}
|
||||
|
||||
@ -1395,7 +1395,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
throw new InvalidParameterValueException("Either disk Offering Id or snapshot Id must be passed whilst creating volume");
|
||||
}
|
||||
|
||||
if (cmd.getSnapshotId() == null) {
|
||||
if (cmd.getSnapshotId() == null) {// create a new volume
|
||||
zoneId = cmd.getZoneId();
|
||||
if ((zoneId == null)) {
|
||||
throw new InvalidParameterValueException("Missing parameter, zoneid must be specified.");
|
||||
@ -1441,15 +1441,15 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
|
||||
}
|
||||
size = (size * 1024 * 1024 * 1024);// custom size entered is in GB, to be converted to bytes
|
||||
}
|
||||
} else {
|
||||
} else { // create volume from snapshot
|
||||
Long snapshotId = cmd.getSnapshotId();
|
||||
SnapshotVO snapshotCheck = _snapshotDao.findById(snapshotId);
|
||||
diskOfferingId = cmd.getDiskOfferingId();
|
||||
diskOfferingId = (cmd.getDiskOfferingId() != null) ? cmd.getDiskOfferingId() : snapshotCheck.getDiskOfferingId();
|
||||
if (snapshotCheck == null) {
|
||||
throw new InvalidParameterValueException("unable to find a snapshot with id " + snapshotId);
|
||||
}
|
||||
zoneId = snapshotCheck.getDataCenterId();
|
||||
size = snapshotCheck.getSize(); //we maintain size from org vol ; disk offering is used for tags purposes
|
||||
size = snapshotCheck.getSize(); //; disk offering is used for tags purposes
|
||||
|
||||
if (account != null) {
|
||||
if (isAdmin(account.getType())) {
|
||||
|
||||
@ -1191,7 +1191,7 @@ public class SnapshotManagerImpl implements SnapshotManager, SnapshotService, Ma
|
||||
// user
|
||||
Type snapshotType = getSnapshotType(policyId);
|
||||
HypervisorType hypervisorType = this._volsDao.getHypervisorType(volumeId);
|
||||
SnapshotVO snapshotVO = new SnapshotVO(volume.getDataCenterId(), volume.getAccountId(), volume.getDomainId(), volume.getId(), null, snapshotName,
|
||||
SnapshotVO snapshotVO = new SnapshotVO(volume.getDataCenterId(), volume.getAccountId(), volume.getDomainId(), volume.getId(), volume.getDiskOfferingId(), null, snapshotName,
|
||||
(short) snapshotType.ordinal(), snapshotType.name(), volume.getSize(), hypervisorType);
|
||||
return _snapshotDao.persist(snapshotVO);
|
||||
}
|
||||
|
||||
@ -401,6 +401,7 @@ CREATE TABLE `cloud`.`snapshots` (
|
||||
`account_id` bigint unsigned NOT NULL COMMENT 'owner. foreign key to account table',
|
||||
`domain_id` bigint unsigned NOT NULL COMMENT 'the domain that the owner belongs to',
|
||||
`volume_id` bigint unsigned NOT NULL COMMENT 'volume it belongs to. foreign key to volume table',
|
||||
`disk_offering_id` bigint unsigned NOT NULL COMMENT ,
|
||||
`status` varchar(32) COMMENT 'snapshot creation status',
|
||||
`path` varchar(255) COMMENT 'Path',
|
||||
`name` varchar(255) NOT NULL COMMENT 'snapshot name',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user