Skip to content

Commit b653ca8

Browse files
anshulgangwaranshul-gangwar
authored andcommitted
CLOUDSTACK-8833: Fixed Generating url and migrate volume to another storage , resulting two entry in UI and listvolume is not working for that volume
Update the volume id in volume_store_ref table to newly created volume for migration
1 parent bb274a1 commit b653ca8

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

engine/schema/src/org/apache/cloudstack/storage/datastore/db/VolumeDataStoreDao.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,6 @@ public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
5151
List<VolumeDataStoreVO> listUploadedVolumesByStoreId(long id);
5252

5353
List<VolumeDataStoreVO> listByVolumeState(Volume.State... states);
54+
55+
boolean updateVolumeId(long srcVolId, long destVolId);
5456
}

engine/storage/src/org/apache/cloudstack/storage/image/db/VolumeDataStoreDaoImpl.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import javax.inject.Inject;
2626
import javax.naming.ConfigurationException;
2727

28+
import com.cloud.utils.exception.CloudRuntimeException;
2829
import org.apache.log4j.Logger;
2930
import org.springframework.stereotype.Component;
3031
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
@@ -350,4 +351,20 @@ public List<VolumeDataStoreVO> listByVolumeState(Volume.State... states) {
350351
return listIncludingRemovedBy(sc);
351352
}
352353

354+
@Override
355+
public boolean updateVolumeId(long srcVolId, long destVolId) {
356+
TransactionLegacy txn = TransactionLegacy.currentTxn();
357+
try {
358+
VolumeDataStoreVO volumeDataStoreVO = findByVolume(srcVolId);
359+
if(volumeDataStoreVO != null) {
360+
txn.start();
361+
volumeDataStoreVO.setVolumeId(destVolId);
362+
update(volumeDataStoreVO.getId(), volumeDataStoreVO);
363+
txn.commit();
364+
}
365+
} catch (Exception e) {
366+
throw new CloudRuntimeException("Unable to update the volume id for volume store ref", e);
367+
}
368+
return true;
369+
}
353370
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,7 @@ protected Void copyVolumeCallBack(AsyncCallbackDispatcher<VolumeServiceImpl, Cop
14231423
srcVolume.processEvent(Event.OperationSuccessed);
14241424
destVolume.processEvent(Event.MigrationCopySucceeded, result.getAnswer());
14251425
volDao.updateUuid(srcVolume.getId(), destVolume.getId());
1426+
_volumeStoreDao.updateVolumeId(srcVolume.getId(), destVolume.getId());
14261427
try {
14271428
destroyVolume(srcVolume.getId());
14281429
srcVolume = volFactory.getVolume(srcVolume.getId());

0 commit comments

Comments
 (0)