CLOUDSTACK-7867: Delete network resulting in exception

Publish event was getting called from within a DB transaction which is not allowed.
This commit is contained in:
Koushik Das 2014-11-08 13:17:50 +05:30
parent e25de54b4c
commit 4d08bb8935

View File

@ -2278,10 +2278,6 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
NetworkAccountVO networkAccount = _networkAccountDao.getAccountNetworkMapByNetworkId(networkFinal.getId());
if (networkAccount != null)
_networkAccountDao.remove(networkAccount.getId());
// remove its related ACL permission
Pair<Class<?>, Long> networkMsg = new Pair<Class<?>, Long>(Network.class, networkFinal.getId());
_messageBus.publish(_name, EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, PublishScope.LOCAL, networkMsg);
}
NetworkOffering ntwkOff = _entityMgr.findById(NetworkOffering.class, networkFinal.getNetworkOfferingId());
@ -2292,6 +2288,11 @@ public class NetworkOrchestrator extends ManagerBase implements NetworkOrchestra
}
}
});
if (_networksDao.findById(network.getId()) == null) {
// remove its related ACL permission
Pair<Class<?>, Long> networkMsg = new Pair<Class<?>, Long>(Network.class, networkFinal.getId());
_messageBus.publish(_name, EntityManager.MESSAGE_REMOVE_ENTITY_EVENT, PublishScope.LOCAL, networkMsg);
}
return true;
} catch (CloudRuntimeException e) {
s_logger.error("Failed to delete network", e);