Skip to content

Commit e53a1ce

Browse files
committed
created a new column called previous_id in the table volumes to make it easier to track volumes after their migration
1 parent 9df783c commit e53a1ce

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed

engine/schema/src/main/java/com/cloud/storage/VolumeVO.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ public class VolumeVO implements Volume {
4848
@Column(name = "id")
4949
long id;
5050

51+
@Column(name = "previous_id")
52+
private long previousId;
53+
5154
@Column(name = "name")
5255
String name;
5356

@@ -677,4 +680,12 @@ public void setExternalUuid(String externalUuid) {
677680
public String getEncryptFormat() { return encryptFormat; }
678681

679682
public void setEncryptFormat(String encryptFormat) { this.encryptFormat = encryptFormat; }
683+
684+
public long getPreviousId() {
685+
return previousId;
686+
}
687+
688+
public void setPreviousId(long previousId) {
689+
this.previousId = previousId;
690+
}
680691
}

engine/schema/src/main/resources/META-INF/db/schema-41900to41910.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,5 @@ CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('cloud.user_data', 'removed', 'datetime COM
7070
UPDATE `cloud`.`configuration` SET
7171
`options` = 'FirstFitRouting,RandomAllocator,TestingAllocator,FirstFitAllocator,RecreateHostAllocator'
7272
WHERE `name` = 'host.allocators.order';
73+
74+
CALL `cloud`.`IDEMPOTENT_ADD_COLUMN`('volumes','previous_id', 'bigint(20) unsigned DEFAULT NULL');

engine/storage/datamotion/src/main/java/org/apache/cloudstack/storage/motion/StorageSystemDataMotionStrategy.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2283,6 +2283,8 @@ private void handlePostMigration(boolean success, Map<VolumeInfo, VolumeInfo> sr
22832283
if (success) {
22842284
VolumeVO volumeVO = _volumeDao.findById(destVolumeInfo.getId());
22852285
volumeVO.setFormat(ImageFormat.QCOW2);
2286+
volumeVO.setPreviousId(srcVolumeInfo.getId());
2287+
22862288
_volumeDao.update(volumeVO.getId(), volumeVO);
22872289

22882290
_volumeService.copyPoliciesBetweenVolumesAndDestroySourceVolumeAfterMigration(Event.OperationSuccessed, null, srcVolumeInfo, destVolumeInfo, false);

engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1720,6 +1720,7 @@ protected VolumeVO duplicateVolumeOnAnotherStorage(Volume volume, StoragePool po
17201720
newVol.setPassphraseId(volume.getPassphraseId());
17211721
newVol.setEncryptFormat(volume.getEncryptFormat());
17221722
}
1723+
newVol.setPreviousId(volume.getId());
17231724
return volDao.persist(newVol);
17241725
}
17251726

0 commit comments

Comments
 (0)