bug 9087: destroy the source volume, after update the volume entry

status 9087: resolved fixed
This commit is contained in:
anthony 2011-03-22 11:23:36 -07:00
parent 8ac36a980c
commit 7f12876be1
1 changed files with 12 additions and 3 deletions

View File

@ -1373,15 +1373,24 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
String destPrimaryStorageVolumePath = cvAnswer.getVolumePath();
String destPrimaryStorageVolumeFolder = cvAnswer.getVolumeFolder();
expungeVolume(volume);
// Delete the volume on the source storage pool
final DestroyCommand cmd = new DestroyCommand(srcPool, volume, null);
volume.setPath(destPrimaryStorageVolumePath);
volume.setFolder(destPrimaryStorageVolumeFolder);
volume.setPodId(destPool.getPodId());
volume.setPoolId(destPool.getId());
_volsDao.update(volume.getId(), volume);
Answer destroyAnswer = null;
try {
destroyAnswer = sendToPool(srcPool, cmd);
} catch (StorageUnavailableException e1) {
throw new CloudRuntimeException("Failed to destroy the volume from the source primary storage pool to secondary storage.");
}
if (destroyAnswer == null || !destroyAnswer.getResult()) {
throw new CloudRuntimeException("Failed to destroy the volume from the source primary storage pool to secondary storage.");
}
return _volsDao.findById(volume.getId());
}