mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Fix detach volume on stopped Vms
This commit is contained in:
parent
d119a5d19f
commit
a831ad1252
@ -2054,31 +2054,35 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
if (!sendCommand || (answer != null && answer.getResult())) {
|
||||
// Mark the volume as detached
|
||||
_volsDao.detachVolume(volume.getId());
|
||||
String datastoreName = answer.getContextParam("datastoreName");
|
||||
if (datastoreName != null) {
|
||||
StoragePoolVO storagePoolVO = _storagePoolDao.findByUuid(datastoreName);
|
||||
if (storagePoolVO != null) {
|
||||
|
||||
if (answer != null) {
|
||||
String datastoreName = answer.getContextParam("datastoreName");
|
||||
if (datastoreName != null) {
|
||||
StoragePoolVO storagePoolVO = _storagePoolDao.findByUuid(datastoreName);
|
||||
if (storagePoolVO != null) {
|
||||
VolumeVO volumeVO = _volsDao.findById(volumeId);
|
||||
volumeVO.setPoolId(storagePoolVO.getId());
|
||||
_volsDao.update(volumeVO.getId(), volumeVO);
|
||||
} else {
|
||||
s_logger.warn(String.format("Unable to find datastore %s while updating the new datastore of the volume %d", datastoreName, volumeId));
|
||||
}
|
||||
}
|
||||
|
||||
String volumePath = answer.getContextParam("volumePath");
|
||||
if (volumePath != null) {
|
||||
VolumeVO volumeVO = _volsDao.findById(volumeId);
|
||||
volumeVO.setPoolId(storagePoolVO.getId());
|
||||
volumeVO.setPath(volumePath);
|
||||
_volsDao.update(volumeVO.getId(), volumeVO);
|
||||
}
|
||||
|
||||
String chainInfo = answer.getContextParam("chainInfo");
|
||||
if (chainInfo != null) {
|
||||
VolumeVO volumeVO = _volsDao.findById(volumeId);
|
||||
volumeVO.setChainInfo(chainInfo);
|
||||
_volsDao.update(volumeVO.getId(), volumeVO);
|
||||
} else {
|
||||
s_logger.warn(String.format("Unable to find datastore %s while updating the new datastore of the volume %d", datastoreName, volumeId));
|
||||
}
|
||||
}
|
||||
|
||||
String volumePath = answer.getContextParam("volumePath");
|
||||
if (volumePath != null) {
|
||||
VolumeVO volumeVO = _volsDao.findById(volumeId);
|
||||
volumeVO.setPath(volumePath);
|
||||
_volsDao.update(volumeVO.getId(), volumeVO);
|
||||
}
|
||||
|
||||
String chainInfo = answer.getContextParam("chainInfo");
|
||||
if (chainInfo != null) {
|
||||
VolumeVO volumeVO = _volsDao.findById(volumeId);
|
||||
volumeVO.setChainInfo(chainInfo);
|
||||
_volsDao.update(volumeVO.getId(), volumeVO);
|
||||
}
|
||||
// volume.getPoolId() should be null if the VM we are detaching the disk from has never been started before
|
||||
if (volume.getPoolId() != null) {
|
||||
DataStore dataStore = dataStoreMgr.getDataStore(volume.getPoolId(), DataStoreRole.Primary);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user