mirror of https://github.com/apache/cloudstack.git
Merge pull request #803 from anshul1886/CLOUDSTACK-8833
CLOUDSTACK-8833: Fixed Generating url and migrate volume to another storage , resulting two entry in UI and listvolume is not working for that volume
This commit is contained in:
commit
503c803ba0
|
|
@ -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…
Reference in New Issue