mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
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
This commit is contained in:
parent
61ce75e901
commit
42b89278e9
@ -51,4 +51,6 @@ public interface VolumeDataStoreDao extends GenericDao<VolumeDataStoreVO, Long>,
|
||||
List<VolumeDataStoreVO> listUploadedVolumesByStoreId(long id);
|
||||
|
||||
List<VolumeDataStoreVO> listByVolumeState(Volume.State... states);
|
||||
|
||||
boolean updateVolumeId(long srcVolId, long destVolId);
|
||||
}
|
||||
|
||||
@ -25,6 +25,7 @@ import java.util.Map;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.apache.cloudstack.engine.subsystem.api.storage.DataObjectInStore;
|
||||
@ -350,4 +351,20 @@ public class VolumeDataStoreDaoImpl extends GenericDaoBase<VolumeDataStoreVO, Lo
|
||||
return listIncludingRemovedBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateVolumeId(long srcVolId, long destVolId) {
|
||||
TransactionLegacy txn = TransactionLegacy.currentTxn();
|
||||
try {
|
||||
VolumeDataStoreVO volumeDataStoreVO = findByVolume(srcVolId);
|
||||
if(volumeDataStoreVO != null) {
|
||||
txn.start();
|
||||
volumeDataStoreVO.setVolumeId(destVolId);
|
||||
update(volumeDataStoreVO.getId(), volumeDataStoreVO);
|
||||
txn.commit();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new CloudRuntimeException("Unable to update the volume id for volume store ref", e);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1428,6 +1428,7 @@ public class VolumeServiceImpl implements VolumeService {
|
||||
srcVolume.processEvent(Event.OperationSuccessed);
|
||||
destVolume.processEvent(Event.MigrationCopySucceeded, result.getAnswer());
|
||||
volDao.updateUuid(srcVolume.getId(), destVolume.getId());
|
||||
_volumeStoreDao.updateVolumeId(srcVolume.getId(), destVolume.getId());
|
||||
try {
|
||||
destroyVolume(srcVolume.getId());
|
||||
srcVolume = volFactory.getVolume(srcVolume.getId());
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user