CLOUDSTACK-6934: don't try to detach volume from host when volume was never allocated to a primary storage

This commit is contained in:
Alena Prokharchyk 2014-06-18 09:59:23 -07:00
parent dbbc6d42fd
commit 3312394154

View File

@ -894,9 +894,11 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
if (volumesForVm != null) {
for (VolumeVO volumeForVm : volumesForVm) {
VolumeInfo volumeInfo = volFactory.getVolume(volumeForVm.getId());
DataStore dataStore = dataStoreMgr.getDataStore(volumeForVm.getPoolId(), DataStoreRole.Primary);
volService.disconnectVolumeFromHost(volumeInfo, host, dataStore);
// pool id can be null for the VM's volumes in Allocated state
if (volumeForVm.getPoolId() != null) {
DataStore dataStore = dataStoreMgr.getDataStore(volumeForVm.getPoolId(), DataStoreRole.Primary);
volService.disconnectVolumeFromHost(volumeInfo, host, dataStore);
}
}
}
}