Fixed NPE in deleteAccount code - when shutdown the network, always set reservation context with account/userCaller information

This commit is contained in:
alena 2011-02-11 12:05:24 -08:00
parent 3113ae4993
commit cb73c1e1fa
1 changed files with 14 additions and 1 deletions

View File

@ -1710,7 +1710,20 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (s_logger.isDebugEnabled()) {
s_logger.debug("Sending network shutdown to " + element);
}
element.shutdown(network, null);
User caller = null;
Account owner = _accountMgr.getAccount(network.getAccountId());
UserContext ctx = UserContext.current();
if (ctx == null) {
caller = _accountMgr.getSystemUser();
} else {
caller = _accountMgr.getActiveUser(ctx.getCallerUserId());
}
ReservationContext context = new ReservationContextImpl(null, null, caller, owner);
element.shutdown(network, context);
} catch (ResourceUnavailableException e) {
s_logger.warn("Unable to complete shutdown of the network due to element: " + element.getName(), e);
success = false;