cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [03/14] Revamped UserContext
Date Fri, 31 May 2013 12:06:43 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/event/ActionEventInterceptor.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/ActionEventInterceptor.java b/server/src/com/cloud/event/ActionEventInterceptor.java
index 01eefcd..24f704a 100644
--- a/server/src/com/cloud/event/ActionEventInterceptor.java
+++ b/server/src/com/cloud/event/ActionEventInterceptor.java
@@ -37,8 +37,8 @@ public class ActionEventInterceptor implements ComponentMethodInterceptor {
             boolean async = actionEvent.async();
             if(async){
                 UserContext ctx = UserContext.current();
-                long userId = ctx.getCallerUserId();
-                long accountId = ctx.getAccountId();
+                long userId = ctx.getCallingUserId();
+                long accountId = ctx.getCallingAccountId();
                 long startEventId = ctx.getStartEventId();
                 String eventDescription = actionEvent.eventDescription();
                 if(ctx.getEventDetails() != null){
@@ -55,8 +55,8 @@ public class ActionEventInterceptor implements ComponentMethodInterceptor {
         ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
         if (actionEvent != null) {
             UserContext ctx = UserContext.current();
-            long userId = ctx.getCallerUserId();
-            long accountId = ctx.getAccountId();
+            long userId = ctx.getCallingUserId();
+            long accountId = ctx.getCallingAccountId();
             long startEventId = ctx.getStartEventId();
             String eventDescription = actionEvent.eventDescription();
             if(ctx.getEventDetails() != null){
@@ -77,8 +77,8 @@ public class ActionEventInterceptor implements ComponentMethodInterceptor {
         ActionEvent actionEvent = method.getAnnotation(ActionEvent.class);
         if (actionEvent != null) {
             UserContext ctx = UserContext.current();
-            long userId = ctx.getCallerUserId();
-            long accountId = ctx.getAccountId();
+            long userId = ctx.getCallingUserId();
+            long accountId = ctx.getCallingAccountId();
             long startEventId = ctx.getStartEventId();
             String eventDescription = actionEvent.eventDescription();
             if(ctx.getEventDetails() != null){

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 13a93f0..32d2e9c 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -715,8 +715,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
 
     private IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId)
             throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
-        Account caller = UserContext.current().getCaller();
-        long callerUserId = UserContext.current().getCallerUserId();
+        Account caller = UserContext.current().getCallingAccount();
+        long callerUserId = UserContext.current().getCallingUserId();
         // check permissions
         _accountMgr.checkAccess(caller, null, false, ipOwner);
 
@@ -873,7 +873,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
     public IPAddressVO associateIPToGuestNetwork(long ipId, long networkId, boolean releaseOnFailure)
             throws ResourceAllocationException, ResourceUnavailableException,
     InsufficientAddressCapacityException, ConcurrentOperationException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Account owner = null;
 
         IPAddressVO ipToAssoc = _ipAddressDao.findById(ipId);
@@ -887,7 +887,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
             if (zone.getNetworkType() == NetworkType.Advanced) {
                 if (network.getGuestType() == Network.GuestType.Shared) {
                 if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) {
-                    _accountMgr.checkAccess(UserContext.current().getCaller(), AccessType.UseNetwork, false, network);
+                    _accountMgr.checkAccess(UserContext.current().getCallingAccount(), AccessType.UseNetwork, false, network);
                 } else {
                     throw new InvalidParameterValueException("IP can be associated with guest network of 'shared' type only if " +
                         "network services Source Nat, Static Nat, Port Forwarding, Load balancing, firewall are enabled in the network");
@@ -1001,7 +1001,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
             throws ResourceAllocationException, ResourceUnavailableException,
             InsufficientAddressCapacityException, ConcurrentOperationException {
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Account owner = null;
 
         Network network = _networksDao.findById(networkId);
@@ -1024,7 +1024,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
             if (zone.getNetworkType() == NetworkType.Advanced) {
                 if (network.getGuestType() == Network.GuestType.Shared) {
                     assert (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()));
-                    _accountMgr.checkAccess(UserContext.current().getCaller(), AccessType.UseNetwork, false, network);
+                    _accountMgr.checkAccess(UserContext.current().getCallingAccount(), AccessType.UseNetwork, false, network);
                 }
             } else {
                 _accountMgr.checkAccess(caller, null, true, ipToAssoc);
@@ -1941,7 +1941,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
 
         // reapply all the firewall/staticNat/lb rules
         s_logger.debug("Reprogramming network " + network + " as a part of network implement");
-        if (!reprogramNetworkRules(network.getId(), UserContext.current().getCaller(), network)) {
+        if (!reprogramNetworkRules(network.getId(), UserContext.current().getCallingAccount(), network)) {
             s_logger.warn("Failed to re-program the network as a part of network " + network + " implement");
             // see DataCenterVO.java
             ResourceUnavailableException ex = new ResourceUnavailableException("Unable to apply network rules as a part of network " + network + " implement", DataCenter.class, network.getDataCenterId());
@@ -3225,8 +3225,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
         if ( createNetwork && requiredOfferings.get(0).getIsPersistent() ) {
             DataCenter zone = _dcDao.findById(zoneId);
             DeployDestination dest = new DeployDestination(zone, null, null, null);
-            Account callerAccount = UserContext.current().getCaller();
-            UserVO callerUser = _userDao.findById(UserContext.current().getCallerUserId());
+            Account callerAccount = UserContext.current().getCallingAccount();
+            UserVO callerUser = _userDao.findById(UserContext.current().getCallingUserId());
             Journal journal = new Journal.LogJournal("Implementing " + guestNetwork, s_logger);
             ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), journal, callerUser, callerAccount);
             s_logger.debug("Implementing network " + guestNetwork + " as a part of network provision for persistent network");
@@ -3428,7 +3428,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
     public String allocateGuestIP(Account ipOwner, boolean isSystem, long zoneId, Long networkId, String requestedIp)
     throws InsufficientAddressCapacityException {
         String ipaddr = null;
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         // check permissions
         Network network = _networksDao.findById(networkId);
 
@@ -4017,7 +4017,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
         if (networkId != null) {
             if (ip.getSystem()) {
                 UserContext ctx = UserContext.current();
-                if (!disassociatePublicIpAddress(ip.getId(), ctx.getCallerUserId(), ctx.getCaller())) {
+                if (!disassociatePublicIpAddress(ip.getId(), ctx.getCallingUserId(), ctx.getCallingAccount())) {
                     s_logger.warn("Unable to release system ip address id=" + ip.getId());
                     success = false;
                 } else {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/NetworkServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkServiceImpl.java b/server/src/com/cloud/network/NetworkServiceImpl.java
index 9899284..910f66f 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -18,8 +18,6 @@ package com.cloud.network;
 
 import java.net.Inet6Address;
 import java.net.InetAddress;
-import java.net.InetAddress;
-import java.net.Inet6Address;
 import java.net.UnknownHostException;
 import java.security.InvalidParameterException;
 import java.sql.PreparedStatement;
@@ -39,31 +37,19 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
-import com.cloud.network.vpc.dao.VpcDao;
+import org.apache.log4j.Logger;
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
-import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
 import org.apache.cloudstack.api.command.admin.network.DedicateGuestVlanRangeCmd;
 import org.apache.cloudstack.api.command.admin.network.ListDedicatedGuestVlanRangesCmd;
 import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
-import org.apache.cloudstack.api.command.user.network.*;
-import com.cloud.network.vpc.NetworkACL;
-import com.cloud.network.vpc.dao.NetworkACLDao;
-import org.apache.cloudstack.acl.ControlledEntity.ACLType;
-import org.apache.cloudstack.acl.SecurityChecker.AccessType;
-import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
 import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
 import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
 import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
 import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
 import org.apache.cloudstack.network.element.InternalLoadBalancerElementService;
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-import org.apache.cloudstack.api.command.user.vm.ListNicsCmd;
-import org.bouncycastle.util.IPAddress;
 
 import com.cloud.api.ApiDBUtils;
 import com.cloud.configuration.Config;
@@ -134,10 +120,13 @@ import com.cloud.network.rules.FirewallRuleVO;
 import com.cloud.network.rules.PortForwardingRuleVO;
 import com.cloud.network.rules.RulesManager;
 import com.cloud.network.rules.dao.PortForwardingRulesDao;
+import com.cloud.network.vpc.NetworkACL;
 import com.cloud.network.vpc.PrivateIpVO;
 import com.cloud.network.vpc.Vpc;
 import com.cloud.network.vpc.VpcManager;
+import com.cloud.network.vpc.dao.NetworkACLDao;
 import com.cloud.network.vpc.dao.PrivateIpDao;
+import com.cloud.network.vpc.dao.VpcDao;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.NetworkOfferingVO;
 import com.cloud.offerings.dao.NetworkOfferingDao;
@@ -158,7 +147,6 @@ import com.cloud.user.UserContext;
 import com.cloud.user.UserVO;
 import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserDao;
-import com.cloud.utils.AnnotationHelper;
 import com.cloud.utils.Journal;
 import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
@@ -510,8 +498,8 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
     public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId)
              throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
 
-        Account caller = UserContext.current().getCaller();
-        long callerUserId = UserContext.current().getCallerUserId();
+        Account caller = UserContext.current().getCallingAccount();
+        long callerUserId = UserContext.current().getCallingUserId();
         DataCenter zone = _configMgr.getZone(zoneId);
 
         if (networkId != null) {
@@ -549,8 +537,8 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
     @ActionEvent(eventType = EventTypes.EVENT_PORTABLE_IP_ASSIGN, eventDescription = "allocating portable public Ip", create = true)
     public IpAddress allocatePortableIP(Account ipOwner, int regionId, Long zoneId, Long networkId, Long vpcId)
             throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
-        Account caller = UserContext.current().getCaller();
-        long callerUserId = UserContext.current().getCallerUserId();
+        Account caller = UserContext.current().getCallingAccount();
+        long callerUserId = UserContext.current().getCallingUserId();
         DataCenter zone = _configMgr.getZone(zoneId);
 
         if ((networkId == null && vpcId == null) && (networkId != null && vpcId != null)) {
@@ -645,7 +633,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
             throw new InvalidParameterValueException("Invalid network id is given");
         }
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         //check whether the nic belongs to user vm.
         NicVO nicVO = _nicDao.findById(nicId);
@@ -745,7 +733,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
     @Override
     @DB
     public boolean releaseSecondaryIpFromNic (long ipAddressId) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         boolean success = false;
 
         // Verify input parameters
@@ -852,8 +840,8 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
 
     @DB
     private boolean releaseIpAddressInternal(long ipAddressId) throws InsufficientAddressCapacityException {
-        Long userId = UserContext.current().getCallerUserId();
-        Account caller = UserContext.current().getCaller();
+        Long userId = UserContext.current().getCallingUserId();
+        Account caller = UserContext.current().getCallingAccount();
 
         // Verify input parameters
         IPAddressVO ipVO = _ipAddressDao.findById(ipAddressId);
@@ -979,7 +967,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
         String vlanId = cmd.getVlan();
         String name = cmd.getNetworkName();
         String displayText = cmd.getDisplayText();
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long physicalNetworkId = cmd.getPhysicalNetworkId();
         Long zoneId = cmd.getZoneId();
         String aclTypeStr = cmd.getAclType();
@@ -1108,8 +1096,6 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
             owner = caller;
         }
 
-        UserContext.current().setAccountId(owner.getAccountId());
-
         boolean ipv4 = true, ipv6 = false;
         if (startIP != null) {
         	ipv4 = true;
@@ -1329,7 +1315,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
                     return network;
                 }
                 DeployDestination dest = new DeployDestination(zone, null, null, null);
-                UserVO callerUser = _userDao.findById(UserContext.current().getCallerUserId());
+                UserVO callerUser = _userDao.findById(UserContext.current().getCallingUserId());
                 Journal journal = new Journal.LogJournal("Implementing " + network, s_logger);
                 ReservationContext context = new ReservationContextImpl(UUID.randomUUID().toString(), journal, callerUser, caller);
                 s_logger.debug("Implementing network " + network + " as a part of network provision for persistent network");
@@ -1354,7 +1340,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
         String keyword = cmd.getKeyword();
         Long zoneId = cmd.getZoneId();
         String zoneType = cmd.getZoneType();
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long domainId = cmd.getDomainId();
         String accountName = cmd.getAccountName();
         String guestIpType = cmd.getGuestIpType();
@@ -1744,7 +1730,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
     @ActionEvent(eventType = EventTypes.EVENT_NETWORK_DELETE, eventDescription = "deleting network", async = true)
     public boolean deleteNetwork(long networkId) {
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         // Verify network id
         NetworkVO network = _networksDao.findById(networkId);
@@ -1768,7 +1754,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
         // Perform permission check
         _accountMgr.checkAccess(caller, null, true, network);
 
-        User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
+        User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallingUserId());
         ReservationContext context = new ReservationContextImpl(null, null, callerUser, owner);
 
         return _networkMgr.destroyNetwork(networkId, context);
@@ -1781,7 +1767,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
         // This method restarts all network elements belonging to the network and re-applies all the rules
         Long networkId = cmd.getNetworkId();
 
-        User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
+        User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallingUserId());
         Account callerAccount = _accountMgr.getActiveAccountById(callerUser.getAccountId());
 
         // Check if network exists
@@ -3412,7 +3398,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
             throw new CloudRuntimeException("Provider is not deletable because there are active networks using this provider, please upgrade these networks to new network offerings");
         }
 
-        User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
+        User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallingUserId());
         Account callerAccount = _accountMgr.getActiveAccountById(callerUser.getAccountId());
         // shutdown the provider instances
         ReservationContext context = new ReservationContextImpl(null, null, callerUser, callerAccount);
@@ -3904,7 +3890,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
 
     @Override
     public List<? extends Nic> listNics(ListNicsCmd cmd) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long nicId = cmd.getNicId();
         Long vmId = cmd.getVmId();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/NetworkUsageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkUsageManagerImpl.java b/server/src/com/cloud/network/NetworkUsageManagerImpl.java
index 80f898b..437bdf5 100755
--- a/server/src/com/cloud/network/NetworkUsageManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkUsageManagerImpl.java
@@ -188,7 +188,7 @@ public class NetworkUsageManagerImpl extends ManagerBase implements NetworkUsage
     @Override
     public boolean deleteTrafficMonitor(DeleteTrafficMonitorCmd cmd) {
         long hostId = cmd.getId();
-        User caller = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
+        User caller = _accountMgr.getActiveUser(UserContext.current().getCallingUserId());
         HostVO trafficMonitor = _hostDao.findById(hostId);
         if (trafficMonitor == null) {
             throw new InvalidParameterValueException("Could not find an traffic monitor with ID: " + hostId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
index 247441e..5dfbc45 100644
--- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
+++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
@@ -306,7 +306,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     public AutoScaleVmProfile createAutoScaleVmProfile(CreateAutoScaleVmProfileCmd cmd) {
 
         Account owner = _accountDao.findById(cmd.getAccountId());
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         _accountMgr.checkAccess(caller, null, true, owner);
 
         long zoneId = cmd.getZoneId();
@@ -337,7 +337,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         ApiDispatcher.processParameters(new DeployVMCmd(), deployParams);
 
         if (autoscaleUserId == null) {
-            autoscaleUserId = UserContext.current().getCallerUserId();
+            autoscaleUserId = UserContext.current().getCallingUserId();
         }
 
         AutoScaleVmProfileVO profileVO = new AutoScaleVmProfileVO(cmd.getZoneId(), cmd.getDomainId(), cmd.getAccountId(), cmd.getServiceOfferingId(), cmd.getTemplateId(), cmd.getOtherDeployParams(),
@@ -358,7 +358,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
         Integer destroyVmGraceperiod = cmd.getDestroyVmGraceperiod();
 
-        AutoScaleVmProfileVO vmProfile = getEntityInDatabase(UserContext.current().getCaller(), "Auto Scale Vm Profile", profileId, _autoScaleVmProfileDao);
+        AutoScaleVmProfileVO vmProfile = getEntityInDatabase(UserContext.current().getCallingAccount(), "Auto Scale Vm Profile", profileId, _autoScaleVmProfileDao);
 
         if (templateId != null) {
             vmProfile.setTemplateId(templateId);
@@ -393,7 +393,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMPROFILE_DELETE, eventDescription = "deleting autoscale vm profile")
     public boolean deleteAutoScaleVmProfile(long id) {
         /* Check if entity is in database */
-        getEntityInDatabase(UserContext.current().getCaller(), "AutoScale Vm Profile", id, _autoScaleVmProfileDao);
+        getEntityInDatabase(UserContext.current().getCallingAccount(), "AutoScale Vm Profile", id, _autoScaleVmProfileDao);
         if (_autoScaleVmGroupDao.isProfileInUse(id)) {
             throw new InvalidParameterValueException("Cannot delete AutoScale Vm Profile when it is in use by one more vm groups");
         }
@@ -459,7 +459,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
             ControlledEntity[] sameOwnerEntities = conditions.toArray(new ControlledEntity[conditions.size() + 1]);
             sameOwnerEntities[sameOwnerEntities.length - 1] = autoScalePolicyVO;
-            _accountMgr.checkAccess(UserContext.current().getCaller(), null, true, sameOwnerEntities);
+            _accountMgr.checkAccess(UserContext.current().getCallingAccount(), null, true, sameOwnerEntities);
 
             if (conditionIds.size() != conditions.size()) {
                 // TODO report the condition id which could not be found
@@ -516,7 +516,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEPOLICY_DELETE, eventDescription = "deleting autoscale policy")
     public boolean deleteAutoScalePolicy(long id) {
         /* Check if entity is in database */
-        getEntityInDatabase(UserContext.current().getCaller(), "AutoScale Policy", id, _autoScalePolicyDao);
+        getEntityInDatabase(UserContext.current().getCallingAccount(), "AutoScale Policy", id, _autoScalePolicyDao);
 
         if (_autoScaleVmGroupPolicyMapDao.isAutoScalePolicyInUse(id)) {
             throw new InvalidParameterValueException("Cannot delete AutoScale Policy when it is in use by one or more AutoScale Vm Groups");
@@ -543,7 +543,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
 
     public void checkCallerAccess(String accountName, Long domainId)
     {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Account owner = _accountDao.findActiveAccount(accountName, domainId);
         if (owner == null) {
             List<String> idList = new ArrayList<String>();
@@ -573,7 +573,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             boolean listAll = cmd.listAll();
             long startIndex = cmd.getStartIndex();
             long pageSizeVal = cmd.getPageSizeVal();
-            Account caller = UserContext.current().getCaller();
+            Account caller = UserContext.current().getCallingAccount();
 
             Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean,
                     ListProjectResourcesCriteria>(domainId, isRecursive, null);
@@ -654,7 +654,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         Integer duration = cmd.getDuration();
         Integer quietTime = cmd.getQuietTime();
         List<Long> conditionIds = cmd.getConditionIds();
-        AutoScalePolicyVO policy = getEntityInDatabase(UserContext.current().getCaller(), "Auto Scale Policy", policyId, _autoScalePolicyDao);
+        AutoScalePolicyVO policy = getEntityInDatabase(UserContext.current().getCallingAccount(), "Auto Scale Policy", policyId, _autoScalePolicyDao);
 
         if (duration != null) {
             policy.setDuration(duration);
@@ -697,7 +697,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             interval = NetUtils.DEFAULT_AUTOSCALE_POLICY_INTERVAL_TIME;
         }
 
-        LoadBalancerVO loadBalancer = getEntityInDatabase(UserContext.current().getCaller(), ApiConstants.LBID, cmd.getLbRuleId(), _lbDao);
+        LoadBalancerVO loadBalancer = getEntityInDatabase(UserContext.current().getCallingAccount(), ApiConstants.LBID, cmd.getLbRuleId(), _lbDao);
 
         Long zoneId = _ipAddressDao.findById(loadBalancer.getSourceIpAddressId()).getDataCenterId();
 
@@ -749,7 +749,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_DELETE, eventDescription = "deleting autoscale vm group")
     public boolean deleteAutoScaleVmGroup(long id) {
-        AutoScaleVmGroupVO autoScaleVmGroupVO = getEntityInDatabase(UserContext.current().getCaller(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
+        AutoScaleVmGroupVO autoScaleVmGroupVO = getEntityInDatabase(UserContext.current().getCallingAccount(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
 
         if (autoScaleVmGroupVO.getState().equals(AutoScaleVmGroup.State_New)) {
             /* This condition is for handling failures during creation command */
@@ -880,15 +880,15 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
             getAutoScalePolicies("scaledownpolicyid", currentScaleDownPolicyIds, counters, interval, false);
             policyIds.addAll(currentScaleDownPolicyIds);
         }
-        AutoScaleVmProfileVO profileVO = getEntityInDatabase(UserContext.current().getCaller(), ApiConstants.VMPROFILE_ID, vmGroup.getProfileId(), _autoScaleVmProfileDao);
+        AutoScaleVmProfileVO profileVO = getEntityInDatabase(UserContext.current().getCallingAccount(), ApiConstants.VMPROFILE_ID, vmGroup.getProfileId(), _autoScaleVmProfileDao);
 
-        LoadBalancerVO loadBalancer = getEntityInDatabase(UserContext.current().getCaller(), ApiConstants.LBID, vmGroup.getLoadBalancerId(), _lbDao);
+        LoadBalancerVO loadBalancer = getEntityInDatabase(UserContext.current().getCallingAccount(), ApiConstants.LBID, vmGroup.getLoadBalancerId(), _lbDao);
         validateAutoScaleCounters(loadBalancer.getNetworkId(), counters, profileVO.getCounterParams());
 
         ControlledEntity[] sameOwnerEntities = policies.toArray(new ControlledEntity[policies.size() + 2]);
         sameOwnerEntities[sameOwnerEntities.length - 2] = loadBalancer;
         sameOwnerEntities[sameOwnerEntities.length - 1] = profileVO;
-        _accountMgr.checkAccess(UserContext.current().getCaller(), null, true, sameOwnerEntities);
+        _accountMgr.checkAccess(UserContext.current().getCallingAccount(), null, true, sameOwnerEntities);
 
         final Transaction txn = Transaction.currentTxn();
         txn.start();
@@ -917,7 +917,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         List<Long> scaleUpPolicyIds = cmd.getScaleUpPolicyIds();
         List<Long> scaleDownPolicyIds = cmd.getScaleDownPolicyIds();
 
-        AutoScaleVmGroupVO vmGroupVO = getEntityInDatabase(UserContext.current().getCaller(), "AutoScale Vm Group", vmGroupId, _autoScaleVmGroupDao);
+        AutoScaleVmGroupVO vmGroupVO = getEntityInDatabase(UserContext.current().getCallingAccount(), "AutoScale Vm Group", vmGroupId, _autoScaleVmGroupDao);
 
         if (!vmGroupVO.getState().equals(AutoScaleVmGroup.State_Disabled)) {
             throw new InvalidParameterValueException("An AutoScale Vm Group can be updated only when it is in disabled state");
@@ -947,7 +947,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_ENABLE, eventDescription = "enabling autoscale vm group")
     public AutoScaleVmGroup enableAutoScaleVmGroup(Long id) {
-        AutoScaleVmGroupVO vmGroup = getEntityInDatabase(UserContext.current().getCaller(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
+        AutoScaleVmGroupVO vmGroup = getEntityInDatabase(UserContext.current().getCallingAccount(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
         boolean success = false;
         if (!vmGroup.getState().equals(AutoScaleVmGroup.State_Disabled)) {
             throw new InvalidParameterValueException("Only a AutoScale Vm Group which is in Disabled state can be enabled.");
@@ -974,7 +974,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @ActionEvent(eventType = EventTypes.EVENT_AUTOSCALEVMGROUP_DISABLE, eventDescription = "disabling autoscale vm group")
     @DB
     public AutoScaleVmGroup disableAutoScaleVmGroup(Long id) {
-        AutoScaleVmGroupVO vmGroup = getEntityInDatabase(UserContext.current().getCaller(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
+        AutoScaleVmGroupVO vmGroup = getEntityInDatabase(UserContext.current().getCallingAccount(), "AutoScale Vm Group", id, _autoScaleVmGroupDao);
         boolean success = false;
         if (!vmGroup.getState().equals(AutoScaleVmGroup.State_Enabled)) {
             throw new InvalidParameterValueException("Only a AutoScale Vm Group which is in Enabled state can be disabled.");
@@ -1128,7 +1128,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
     @ActionEvent(eventType = EventTypes.EVENT_CONDITION_DELETE, eventDescription = "condition")
     public boolean deleteCondition(long conditionId) throws ResourceInUseException {
         /* Check if entity is in database */
-        ConditionVO condition = getEntityInDatabase(UserContext.current().getCaller(), "Condition", conditionId, _conditionDao);
+        ConditionVO condition = getEntityInDatabase(UserContext.current().getCallingAccount(), "Condition", conditionId, _conditionDao);
         if (condition == null) {
             throw new InvalidParameterValueException("Unable to find Condition");
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
index 334a5a1..c059572 100644
--- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
+++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
@@ -147,7 +147,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
 
     @Override
     public FirewallRule createEgressFirewallRule(FirewallRule rule) throws NetworkRuleConflictException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         Network network = _networkDao.findById(rule.getNetworkId());
         if (network.getGuestType() == Network.GuestType.Shared) {
@@ -160,7 +160,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
     }
 
     public FirewallRule createIngressFirewallRule(FirewallRule rule) throws NetworkRuleConflictException {
-         Account caller = UserContext.current().getCaller();
+         Account caller = UserContext.current().getCallingAccount();
         Long sourceIpAddressId = rule.getSourceIpAddressId();
  
         return createFirewallRule(sourceIpAddressId, caller, rule.getXid(), rule.getSourcePortStart(), 
@@ -241,7 +241,7 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
         Map<String, String> tags = cmd.getTags();
         FirewallRule.TrafficType trafficType = cmd.getTrafficType();
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         if (ipId != null) {
@@ -687,8 +687,8 @@ public class FirewallManagerImpl extends ManagerBase implements FirewallService,
 
     @Override
     public boolean revokeFirewallRule(long ruleId, boolean apply) {
-        Account caller = UserContext.current().getCaller();
-        long userId = UserContext.current().getCallerUserId();
+        Account caller = UserContext.current().getCallingAccount();
+        long userId = UserContext.current().getCallingUserId();
         return revokeFirewallRule(ruleId, apply, caller, userId);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
index 79f85a6..862bcc8 100644
--- a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
@@ -139,7 +139,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
             }
 
             implemented.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vlanTag));
-            ActionEventUtils.onCompletedActionEvent(UserContext.current().getCallerUserId(), config.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: " + vnet + " Network Id: " + config.getId(), 0);
+            ActionEventUtils.onCompletedActionEvent(UserContext.current().getCallingUserId(), config.getAccountId(), EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: " + vnet + " Network Id: " + config.getId(), 0);
         } else {
             vlanTag = Integer.parseInt(config.getBroadcastUri().getHost());
             implemented.setBroadcastUri(config.getBroadcastUri());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/guru/GuestNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/GuestNetworkGuru.java b/server/src/com/cloud/network/guru/GuestNetworkGuru.java
index dde562e..7fca152 100755
--- a/server/src/com/cloud/network/guru/GuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/GuestNetworkGuru.java
@@ -266,7 +266,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
                 		"part of network " + network + " implement ", DataCenter.class, dcId);
             }
             implemented.setBroadcastUri(BroadcastDomainType.Vlan.toUri(vnet));
-            ActionEventUtils.onCompletedActionEvent(UserContext.current().getCallerUserId(), network.getAccountId(),
+            ActionEventUtils.onCompletedActionEvent(UserContext.current().getCallingUserId(), network.getAccountId(),
                     EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_ASSIGN, "Assigned Zone Vlan: " + vnet + " Network Id: " + network.getId(), 0);
         } else {
             implemented.setBroadcastUri(network.getBroadcastUri());
@@ -406,7 +406,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
         s_logger.debug("Releasing vnet for the network id=" + profile.getId());
             _dcDao.releaseVnet(profile.getBroadcastUri().getHost(), profile.getDataCenterId(), 
                     profile.getPhysicalNetworkId(), profile.getAccountId(), profile.getReservationId());
-            ActionEventUtils.onCompletedActionEvent(UserContext.current().getCallerUserId(), profile.getAccountId(),
+            ActionEventUtils.onCompletedActionEvent(UserContext.current().getCallingUserId(), profile.getAccountId(),
                     EventVO.LEVEL_INFO, EventTypes.EVENT_ZONE_VLAN_RELEASE, "Released Zone Vlan: "
                     + profile.getBroadcastUri().getHost() + " for Network: " + profile.getId(), 0);
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
index f9bbf1f..a091a9e 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -526,7 +526,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
             throw new InvalidParameterValueException("Failed: LB rule id: " + cmd.getLbRuleId() + " not present ");
         }
 
-        _accountMgr.checkAccess(caller.getCaller(), null, true, loadBalancer);
+        _accountMgr.checkAccess(caller.getCallingAccount(), null, true, loadBalancer);
         if (loadBalancer.getState() == FirewallRule.State.Revoke) {
             throw new InvalidParameterValueException("Failed:  LB rule id: " + cmd.getLbRuleId()
                     + " is in deleting state: ");
@@ -586,7 +586,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
             throw new InvalidParameterValueException("Failed: LB rule id: " + cmd.getLbRuleId() + " not present ");
         }
 
-        _accountMgr.checkAccess(caller.getCaller(), null, true, loadBalancer);
+        _accountMgr.checkAccess(caller.getCallingAccount(), null, true, loadBalancer);
 
         if (loadBalancer.getState() == FirewallRule.State.Revoke) {
             throw new InvalidParameterValueException("Failed:  LB rule id: " + cmd.getLbRuleId()
@@ -727,7 +727,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
         }
         long loadBalancerId = loadBalancer.getId();
         FirewallRule.State backupState = loadBalancer.getState();
-        _accountMgr.checkAccess(caller.getCaller(), null, true, loadBalancer);
+        _accountMgr.checkAccess(caller.getCallingAccount(), null, true, loadBalancer);
 
         if (apply) {
             if (loadBalancer.getState() == FirewallRule.State.Active) {
@@ -785,7 +785,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
         }
         long loadBalancerId = loadBalancer.getId();
         FirewallRule.State backupState = loadBalancer.getState();
-        _accountMgr.checkAccess(caller.getCaller(), null, true, loadBalancer);
+        _accountMgr.checkAccess(caller.getCallingAccount(), null, true, loadBalancer);
 
         if (apply) {
             if (loadBalancer.getState() == FirewallRule.State.Active) {
@@ -925,7 +925,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
     @ActionEvent(eventType = EventTypes.EVENT_ASSIGN_TO_LOAD_BALANCER_RULE, eventDescription = "assigning to load balancer", async = true)
     public boolean assignToLoadBalancer(long loadBalancerId, List<Long> instanceIds) {
         UserContext ctx = UserContext.current();
-        Account caller = ctx.getCaller();
+        Account caller = ctx.getCallingAccount();
 
         LoadBalancerVO loadBalancer = _lbDao.findById(loadBalancerId);
         if (loadBalancer == null) {
@@ -1053,7 +1053,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
             throw new InvalidParameterException("Invalid load balancer value: " + loadBalancerId);
         }
 
-        _accountMgr.checkAccess(caller.getCaller(), null, true, loadBalancer);
+        _accountMgr.checkAccess(caller.getCallingAccount(), null, true, loadBalancer);
 
         boolean success = false;
         FirewallRule.State backupState = loadBalancer.getState();
@@ -1151,7 +1151,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
     @ActionEvent(eventType = EventTypes.EVENT_LOAD_BALANCER_DELETE, eventDescription = "deleting load balancer", async = true)
     public boolean deleteLoadBalancerRule(long loadBalancerId, boolean apply) {
         UserContext ctx = UserContext.current();
-        Account caller = ctx.getCaller();
+        Account caller = ctx.getCallingAccount();
 
         LoadBalancerVO rule = _lbDao.findById(loadBalancerId);
 
@@ -1160,7 +1160,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
         }
         _accountMgr.checkAccess(caller, null, true, rule);
 
-        boolean result = deleteLoadBalancerRule(loadBalancerId, apply, caller, ctx.getCallerUserId(), true);
+        boolean result = deleteLoadBalancerRule(loadBalancerId, apply, caller, ctx.getCallingUserId(), true);
         if (!result) {
             throw new CloudRuntimeException("Unable to remove load balancer rule " + loadBalancerId);
         }
@@ -1388,7 +1388,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
             throw ex;
         }
         
-        _accountMgr.checkAccess(caller.getCaller(), null, true, ipAddr);
+        _accountMgr.checkAccess(caller.getCallingAccount(), null, true, ipAddr);
 
 
         Long networkId = ipAddr.getAssociatedWithNetworkId();
@@ -1402,7 +1402,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
         // verify that lb service is supported by the network
         isLbServiceSupportedInNetwork(networkId, Scheme.Public);
 
-        _firewallMgr.validateFirewallRule(caller.getCaller(), ipAddr, srcPort, srcPort, protocol,
+        _firewallMgr.validateFirewallRule(caller.getCallingAccount(), ipAddr, srcPort, srcPort, protocol,
                 Purpose.LoadBalancing, FirewallRuleType.User, networkId, null);
 
         LoadBalancerVO newRule = new LoadBalancerVO(xId, name, description,
@@ -1424,7 +1424,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
 
         //create rule for all CIDRs
         if (openFirewall) {
-            _firewallMgr.createRuleForAllCidrs(sourceIpId, caller.getCaller(), srcPort,
+            _firewallMgr.createRuleForAllCidrs(sourceIpId, caller.getCallingAccount(), srcPort,
                     srcPort, protocol, null, null, newRule.getId(), networkId);
         }
 
@@ -1646,7 +1646,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
         if (ip.getSystem()) {
             s_logger.debug("Releasing system ip address " + lb.getSourceIpAddressId() + " as a part of delete lb rule");
             if (!_networkMgr.disassociatePublicIpAddress(lb.getSourceIpAddressId(), UserContext.current()
-                    .getCallerUserId(), UserContext.current().getCaller())) {
+                    .getCallingUserId(), UserContext.current().getCallingAccount())) {
                 s_logger.warn("Unable to release system ip address id=" + lb.getSourceIpAddressId()
                         + " as a part of delete lb rule");
                 success = false;
@@ -1738,7 +1738,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_LOAD_BALANCER_UPDATE, eventDescription = "updating load balancer", async = true)
     public LoadBalancer updateLoadBalancerRule(UpdateLoadBalancerRuleCmd cmd) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long lbRuleId = cmd.getId();
         String name = cmd.getLoadBalancerName();
         String description = cmd.getDescription();
@@ -1810,7 +1810,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
     @Override
     public List<UserVmVO> listLoadBalancerInstances(ListLoadBalancerRuleInstancesCmd cmd)
             throws PermissionDeniedException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long loadBalancerId = cmd.getId();
         Boolean applied = cmd.isApplied();
 
@@ -1876,7 +1876,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
     @Override
     public List<LBStickinessPolicyVO> searchForLBStickinessPolicies(ListLBStickinessPoliciesCmd cmd)
             throws PermissionDeniedException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long loadBalancerId = cmd.getLbRuleId();
         LoadBalancerVO loadBalancer = _lbDao.findById(loadBalancerId);
         if (loadBalancer == null) {
@@ -1893,7 +1893,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
     @Override
     public List<LBHealthCheckPolicyVO> searchForLBHealthCheckPolicies(ListLBHealthCheckPoliciesCmd cmd)
             throws PermissionDeniedException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long loadBalancerId = cmd.getLbRuleId();
         LoadBalancerVO loadBalancer = _lbDao.findById(loadBalancerId);
         if (loadBalancer == null) {
@@ -1915,7 +1915,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
         Long networkId = cmd.getNetworkId();
         Map<String, String> tags = cmd.getTags();
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index fd11e80..0f5eff5 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -432,7 +432,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
     public VirtualRouter upgradeRouter(UpgradeRouterCmd cmd) {
         Long routerId = cmd.getId();
         Long serviceOfferingId = cmd.getServiceOfferingId();
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         DomainRouterVO router = _routerDao.findById(routerId);
         if (router == null) {
@@ -542,7 +542,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
     @ActionEvent(eventType = EventTypes.EVENT_ROUTER_STOP, eventDescription = "stopping router Vm", async = true)
     public VirtualRouter stopRouter(long routerId, boolean forced) throws ResourceUnavailableException, ConcurrentOperationException {
         UserContext context = UserContext.current();
-        Account account = context.getCaller();
+        Account account = context.getCallingAccount();
 
         // verify parameters
         DomainRouterVO router = _routerDao.findById(routerId);
@@ -552,7 +552,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
 
         _accountMgr.checkAccess(account, null, true, router);
 
-        UserVO user = _userDao.findById(UserContext.current().getCallerUserId());
+        UserVO user = _userDao.findById(UserContext.current().getCallingUserId());
 
         VirtualRouter virtualRouter = stop(router, forced, user, account);
         if (virtualRouter == null) {
@@ -605,7 +605,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
     @ActionEvent(eventType = EventTypes.EVENT_ROUTER_REBOOT, eventDescription = "rebooting router Vm", async = true)
     public VirtualRouter rebootRouter(long routerId, boolean reprogramNetwork) throws ConcurrentOperationException,
             ResourceUnavailableException, InsufficientCapacityException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         // verify parameters
         DomainRouterVO router = _routerDao.findById(routerId);
@@ -622,7 +622,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                     DataCenter.class, router.getDataCenterId());
         }
 
-        UserVO user = _userDao.findById(UserContext.current().getCallerUserId());
+        UserVO user = _userDao.findById(UserContext.current().getCallingUserId());
         s_logger.debug("Stopping and starting router " + router + " as a part of router reboot");
 
         if (stop(router, false, user, caller) != null) {
@@ -1170,8 +1170,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
 
     //Ensure router status is update to date before execute this function. The function would try best to recover all routers except MASTER
     protected void recoverRedundantNetwork(DomainRouterVO masterRouter, DomainRouterVO backupRouter) {
-        UserContext context = UserContext.current();
-        context.setAccountId(1);
         if (masterRouter.getState() == State.Running && backupRouter.getState() == State.Running) {
             HostVO masterHost = _hostDao.findById(masterRouter.getHostId());
             HostVO backupHost = _hostDao.findById(backupRouter.getHostId());
@@ -1283,42 +1281,49 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
 
         @Override
         public void run() {
-            while (true) {
-                try {
-                    Long networkId = _vrUpdateQueue.take();
-                    List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(networkId, Role.VIRTUAL_ROUTER);
+            try {
+                UserContext.register(User.UID_SYSTEM, Account.ACCOUNT_ID_SYSTEM, null);
+                while (true) {
+                    try {
+                        Long networkId = _vrUpdateQueue.take();
+                        List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(networkId, Role.VIRTUAL_ROUTER);
 
-                    if (routers.size() != 2) {
-                        continue;
-                    }
-                    /*
-                     * We update the router pair which the lower id router owned by this mgmt server, in order
-                     * to prevent duplicate update of router status from cluster mgmt servers
-                     */
-                    DomainRouterVO router0 = routers.get(0);
-                    DomainRouterVO router1 = routers.get(1);
-                    DomainRouterVO router = router0;
-                    if ((router0.getId() < router1.getId()) && router0.getHostId() != null) {
-                        router = router0;
-                    } else {
-                        router = router1;
-                    }
-                    if (router.getHostId() == null) {
-                        s_logger.debug("Skip router pair (" + router0.getInstanceName() + "," + router1.getInstanceName() + ") due to can't find host");
-                        continue;
-                    }
-                    HostVO host = _hostDao.findById(router.getHostId());
-                    if (host == null || host.getManagementServerId() == null ||
-                            host.getManagementServerId() != ManagementServerNode.getManagementServerId()) {
-                        s_logger.debug("Skip router pair (" + router0.getInstanceName() + "," + router1.getInstanceName() + ") due to not belong to this mgmt server");
-                        continue;
+                        if (routers.size() != 2) {
+                            continue;
+                        }
+                        /*
+                         * We update the router pair which the lower id router owned by this mgmt server, in order
+                         * to prevent duplicate update of router status from cluster mgmt servers
+                         */
+                        DomainRouterVO router0 = routers.get(0);
+                        DomainRouterVO router1 = routers.get(1);
+                        DomainRouterVO router = router0;
+                        if ((router0.getId() < router1.getId()) && router0.getHostId() != null) {
+                            router = router0;
+                        } else {
+                            router = router1;
+                        }
+                        if (router.getHostId() == null) {
+                            s_logger.debug("Skip router pair (" + router0.getInstanceName() + "," + router1.getInstanceName() + ") due to can't find host");
+                            continue;
+                        }
+                        HostVO host = _hostDao.findById(router.getHostId());
+                        if (host == null || host.getManagementServerId() == null ||
+                                host.getManagementServerId() != ManagementServerNode.getManagementServerId()) {
+                            s_logger.debug("Skip router pair (" + router0.getInstanceName() + "," + router1.getInstanceName() + ") due to not belong to this mgmt server");
+                            continue;
+                        }
+                        updateRoutersRedundantState(routers);
+                        checkDuplicateMaster(routers);
+                        checkSanity(routers);
+                    } catch (Exception ex) {
+                        s_logger.error("Fail to complete the RvRStatusUpdateTask! ", ex);
                     }
-                    updateRoutersRedundantState(routers);
-                    checkDuplicateMaster(routers);
-                    checkSanity(routers);
-                } catch (Exception ex) {
-                    s_logger.error("Fail to complete the RvRStatusUpdateTask! ", ex);
                 }
+            } catch (Exception e) {
+                s_logger.error("Unable to setup the calling context", e);
+            } finally {
+                UserContext.unregister();
             }
         }
 
@@ -2778,7 +2783,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                 try {
                     if (network.getTrafficType() == TrafficType.Guest && network.getGuestType() == GuestType.Shared) {
                         Pod pod = _podDao.findById(vm.getPodIdToDeployIn());
-                        Account caller = UserContext.current().getCaller();
+                        Account caller = UserContext.current().getCallingAccount();
                         List<VlanVO> vlanList = _vlanDao.listVlansByNetworkIdAndGateway(network.getId(), nic.getGateway());
                         List<Long>   vlanDbIdList = new ArrayList<Long>();
                         for (VlanVO vlan : vlanList) {
@@ -2794,7 +2799,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
                     return false;
                 }
                 //this means we did not create a ip alis on the router.
-                NicIpAliasVO alias = new NicIpAliasVO(domr_guest_nic.getId(), routerAliasIp, router.getId(), UserContext.current().getAccountId(), network.getDomainId(), nic.getNetworkId(),nic.getGateway(), nic.getNetmask());
+                NicIpAliasVO alias = new NicIpAliasVO(domr_guest_nic.getId(), routerAliasIp, router.getId(), UserContext.current().getCallingAccountId(), network.getDomainId(), nic.getNetworkId(),nic.getGateway(), nic.getNetmask());
                 alias.setAliasCount((routerPublicIP.getIpMacAddress()));
                 _nicIpAliasDao.persist(alias);
                 List<IpAliasTO> ipaliasTo = new ArrayList<IpAliasTO>();
@@ -3053,8 +3058,8 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
     @Override
     public VirtualRouter startRouter(long routerId, boolean reprogramNetwork) throws ResourceUnavailableException,
             InsufficientCapacityException, ConcurrentOperationException {
-        Account caller = UserContext.current().getCaller();
-        User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
+        Account caller = UserContext.current().getCallingAccount();
+        User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallingUserId());
 
         // verify parameters
         DomainRouterVO router = _routerDao.findById(routerId);
@@ -3090,7 +3095,7 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
             return router;
         }
 
-        UserVO user = _userDao.findById(UserContext.current().getCallerUserId());
+        UserVO user = _userDao.findById(UserContext.current().getCallingUserId());
         Map<Param, Object> params = new HashMap<Param, Object>();
         if (reprogramNetwork) {
             params.put(Param.ReProgramGuestNetworks, true);
@@ -3832,8 +3837,6 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V
 
     @Override
     public void processConnect(HostVO host, StartupCommand cmd, boolean forRebalance) throws ConnectionException {
-        UserContext context = UserContext.current();
-        context.setAccountId(1);
         List<DomainRouterVO> routers = _routerDao.listIsolatedByHostId(host.getId());
         for (DomainRouterVO router : routers) {
             if (router.isStopPending()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/rules/RulesManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RulesManagerImpl.java b/server/src/com/cloud/network/rules/RulesManagerImpl.java
index dd5f99b..3455e9c 100755
--- a/server/src/com/cloud/network/rules/RulesManagerImpl.java
+++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java
@@ -190,7 +190,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
     public PortForwardingRule createPortForwardingRule(PortForwardingRule rule, Long vmId, Ip vmIp, boolean openFirewall)
             throws NetworkRuleConflictException {
         UserContext ctx = UserContext.current();
-        Account caller = ctx.getCaller();
+        Account caller = ctx.getCallingAccount();
 
         Long ipAddrId = rule.getSourceIpAddressId();
 
@@ -352,7 +352,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_NET_RULE_ADD, eventDescription = "creating static nat rule", create = true)
     public StaticNatRule createStaticNatRule(StaticNatRule rule, boolean openFirewall) throws NetworkRuleConflictException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         Long ipAddrId = rule.getSourceIpAddressId();
 
@@ -434,7 +434,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
     private boolean enableStaticNat(long ipId, long vmId, long networkId, boolean isSystemVm, String vmGuestIp)
             throws NetworkRuleConflictException, ResourceUnavailableException {
         UserContext ctx = UserContext.current();
-        Account caller = ctx.getCaller();
+        Account caller = ctx.getCallingAccount();
         UserContext.current().setEventDetails("Ip Id: " + ipId);
 
         // Verify input parameters
@@ -569,7 +569,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
 
                 // Verify ip address parameter
                 // checking vm id is not sufficient, check for the vm ip
-                isIpReadyForStaticNat(vmId, ipAddress, dstIp, caller, ctx.getCallerUserId());
+                isIpReadyForStaticNat(vmId, ipAddress, dstIp, caller, ctx.getCallingUserId());
             }
 
             ipAddress.setOneToOneNat(true);
@@ -656,7 +656,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
     @ActionEvent(eventType = EventTypes.EVENT_NET_RULE_DELETE, eventDescription = "revoking forwarding rule", async = true)
     public boolean revokePortForwardingRule(long ruleId, boolean apply) {
         UserContext ctx = UserContext.current();
-        Account caller = ctx.getCaller();
+        Account caller = ctx.getCallingAccount();
 
         PortForwardingRuleVO rule = _portForwardingDao.findById(ruleId);
         if (rule == null) {
@@ -665,7 +665,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
 
         _accountMgr.checkAccess(caller, null, true, rule);
 
-        if (!revokePortForwardingRuleInternal(ruleId, caller, ctx.getCallerUserId(), apply)) {
+        if (!revokePortForwardingRuleInternal(ruleId, caller, ctx.getCallingUserId(), apply)) {
             throw new CloudRuntimeException("Failed to delete port forwarding rule");
         }
         return true;
@@ -691,7 +691,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
     @ActionEvent(eventType = EventTypes.EVENT_NET_RULE_DELETE, eventDescription = "revoking forwarding rule", async = true)
     public boolean revokeStaticNatRule(long ruleId, boolean apply) {
         UserContext ctx = UserContext.current();
-        Account caller = ctx.getCaller();
+        Account caller = ctx.getCallingAccount();
 
         FirewallRuleVO rule = _firewallDao.findById(ruleId);
         if (rule == null) {
@@ -700,7 +700,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
 
         _accountMgr.checkAccess(caller, null, true, rule);
 
-        if (!revokeStaticNatRuleInternal(ruleId, caller, ctx.getCallerUserId(), apply)) {
+        if (!revokeStaticNatRuleInternal(ruleId, caller, ctx.getCallingUserId(), apply)) {
             throw new CloudRuntimeException("Failed to revoke forwarding rule");
         }
         return true;
@@ -802,7 +802,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
         Long id = cmd.getId();
         Map<String, String> tags = cmd.getTags();
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         if (ipId != null) {
@@ -1015,7 +1015,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
 
     @Override
     public Pair<List<? extends FirewallRule>, Integer> searchStaticNatRules(Long ipId, Long id, Long vmId, Long start, Long size, String accountName, Long domainId, Long projectId, boolean isRecursive, boolean listAll) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         if (ipId != null) {
@@ -1251,7 +1251,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
     @ActionEvent(eventType = EventTypes.EVENT_DISABLE_STATIC_NAT, eventDescription = "disabling static nat", async=true)
     public boolean disableStaticNat(long ipId) throws ResourceUnavailableException, NetworkRuleConflictException, InsufficientAddressCapacityException {
         UserContext ctx = UserContext.current();
-        Account caller = ctx.getCaller();
+        Account caller = ctx.getCallingAccount();
         IPAddressVO ipAddress = _ipAddressDao.findById(ipId);
         checkIpAndUserVm(ipAddress, null, caller);
 
@@ -1279,7 +1279,7 @@ public class RulesManagerImpl extends ManagerBase implements RulesManager, Rules
             }
         }
 
-        return disableStaticNat(ipId, caller, ctx.getCallerUserId(), false);
+        return disableStaticNat(ipId, caller, ctx.getCallingUserId(), false);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
index 1c189c4..1cc6f8d 100755
--- a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
+++ b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
@@ -585,7 +585,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
             throw new InvalidParameterValueException("At least one cidr or at least one security group needs to be specified");
         }
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Account owner = _accountMgr.getAccount(securityGroup.getAccountId());
 
         if (owner == null) {
@@ -762,7 +762,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
 
     private boolean revokeSecurityGroupRule(Long id, SecurityRuleType type) {
         // input validation
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         SecurityGroupRuleVO rule = _securityGroupRuleDao.findById(id);
         if (rule == null) {
@@ -816,7 +816,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
     @ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_CREATE, eventDescription = "creating security group")
     public SecurityGroupVO createSecurityGroup(CreateSecurityGroupCmd cmd) throws PermissionDeniedException, InvalidParameterValueException {
         String name = cmd.getSecurityGroupName();
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Account owner = _accountMgr.finalizeOwner(caller, cmd.getAccountName(), cmd.getDomainId(), cmd.getProjectId());
 
         if (_securityGroupDao.isNameInUse(owner.getId(), owner.getDomainId(), cmd.getSecurityGroupName())) {
@@ -1055,7 +1055,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
     @ActionEvent(eventType = EventTypes.EVENT_SECURITY_GROUP_DELETE, eventDescription = "deleting security group")
     public boolean deleteSecurityGroup(DeleteSecurityGroupCmd cmd) throws ResourceInUseException {
         Long groupId = cmd.getId();
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         SecurityGroupVO group = _securityGroupDao.findById(groupId);
         if (group == null) {
@@ -1307,7 +1307,7 @@ public class SecurityGroupManagerImpl extends ManagerBase implements SecurityGro
             return true;
         }
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         for (SecurityGroupVO securityGroup: vmSgGrps) {
             Account owner = _accountMgr.getAccount(securityGroup.getAccountId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
index 2b02a88..c228326 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLServiceImpl.java
@@ -84,7 +84,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
 
     @Override
     public NetworkACL createNetworkACL(String name, String description, long vpcId) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Vpc vpc = _vpcMgr.getVpc(vpcId);
         if(vpc == null){
             throw new InvalidParameterValueException("Unable to find VPC");
@@ -135,7 +135,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
 
     @Override
     public boolean deleteNetworkACL(long id) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         NetworkACL acl = _networkACLDao.findById(id);
         if(acl == null) {
             throw new InvalidParameterValueException("Unable to find specified ACL");
@@ -155,7 +155,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
     }
     @Override
     public boolean replaceNetworkACLonPrivateGw(long aclId, long privateGatewayId) throws ResourceUnavailableException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         VpcGateway gateway = _vpcGatewayDao.findById(privateGatewayId);
         if (gateway == null) {
             throw new InvalidParameterValueException("Unable to find specified private gateway");
@@ -196,7 +196,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
 
     @Override
     public boolean replaceNetworkACL(long aclId, long networkId) throws ResourceUnavailableException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         NetworkVO network = _networkDao.findById(networkId);
         if(network == null){
@@ -235,7 +235,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
 
     @Override
     public NetworkACLItem createNetworkACLItem(CreateNetworkACLCmd aclItemCmd){
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long aclId = aclItemCmd.getACLId();
         if(aclId == null){
             //ACL id is not specified. Get the ACL details from network
@@ -368,7 +368,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
         String action = cmd.getAction();
         Map<String, String> tags = cmd.getTags();
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject =
@@ -471,7 +471,7 @@ public class NetworkACLServiceImpl extends ManagerBase implements NetworkACLServ
 
         Vpc vpc = _vpcMgr.getVpc(acl.getVpcId());
 
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         _accountMgr.checkAccess(caller, null, true, vpc);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/vpc/VpcManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
index 380a95e..379980e 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -573,7 +573,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     @ActionEvent(eventType = EventTypes.EVENT_VPC_CREATE, eventDescription = "creating vpc", create=true)
     public Vpc createVpc(long zoneId, long vpcOffId, long vpcOwnerId, String vpcName, String displayText, String cidr, 
             String networkDomain) throws ResourceAllocationException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Account owner = _accountMgr.getAccount(vpcOwnerId);
         
         //Verify that caller can perform actions in behalf of vpc owner
@@ -705,9 +705,9 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
         }
         
         //verify permissions
-        _accountMgr.checkAccess(ctx.getCaller(), null, false, vpc);
+        _accountMgr.checkAccess(ctx.getCallingAccount(), null, false, vpc);
         
-        return destroyVpc(vpc, ctx.getCaller(), ctx.getCallerUserId());
+        return destroyVpc(vpc, ctx.getCallingAccount(), ctx.getCallingUserId());
     }
 
     @Override
@@ -763,7 +763,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     @ActionEvent(eventType = EventTypes.EVENT_VPC_UPDATE, eventDescription = "updating vpc")
     public Vpc updateVpc(long vpcId, String vpcName, String displayText) {
         UserContext.current().setEventDetails(" Id: " + vpcId);
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         // Verify input parameters
         VpcVO vpcToUpdate = _vpcDao.findById(vpcId);
@@ -796,7 +796,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     public List<? extends Vpc> listVpcs(Long id, String vpcName, String displayText, List<String> supportedServicesStr, 
             String cidr, Long vpcOffId, String state, String accountName, Long domainId, String keyword,
             Long startIndex, Long pageSizeVal, Long zoneId, Boolean isRecursive, Boolean listAll, Boolean restartRequired, Map<String, String> tags, Long projectId) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
         
         Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, 
@@ -940,8 +940,8 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     public boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException, 
     InsufficientCapacityException {
         UserContext ctx = UserContext.current();
-        Account caller = ctx.getCaller();
-        User callerUser = _accountMgr.getActiveUser(ctx.getCallerUserId());
+        Account caller = ctx.getCallingAccount();
+        User callerUser = _accountMgr.getActiveUser(ctx.getCallingUserId());
         
         //check if vpc exists
         Vpc vpc = getActiveVpc(vpcId);
@@ -1004,7 +1004,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     @Override
     public boolean shutdownVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException {
         UserContext ctx = UserContext.current();
-        Account caller = ctx.getCaller();
+        Account caller = ctx.getCallingAccount();
         
         //check if vpc exists
         Vpc vpc = getVpc(vpcId);
@@ -1021,7 +1021,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
 
         boolean success = true;
         List<Provider> providersToImplement = getVpcProviders(vpc.getId());
-        ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(ctx.getCallerUserId()), caller);
+        ReservationContext context = new ReservationContextImpl(null, null, _accountMgr.getActiveUser(ctx.getCallingUserId()), caller);
         for (VpcProvider element: getVpcElements()){
             if(providersToImplement.contains(element.getProvider())){
                 if (element.shutdownVpc(vpc, context)) {
@@ -1273,7 +1273,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     @ActionEvent(eventType = EventTypes.EVENT_VPC_RESTART, eventDescription = "restarting vpc")
     public boolean restartVpc(long vpcId) throws ConcurrentOperationException, ResourceUnavailableException, 
                                         InsufficientCapacityException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         // Verify input parameters
         Vpc vpc = getActiveVpc(vpcId);
@@ -1508,7 +1508,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
         }
         
         if (deleteNetwork) {
-            User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallerUserId());
+            User callerUser = _accountMgr.getActiveUser(UserContext.current().getCallingUserId());
             Account owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
             ReservationContext context = new ReservationContextImpl(null, null, callerUser, owner);
             _ntwkMgr.destroyNetwork(networkId, context);
@@ -1532,7 +1532,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
         Boolean listAll = cmd.listAll();
         Long domainId = cmd.getDomainId();
         String accountName = cmd.getAccountName();
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
         String state = cmd.getState();
         Long projectId = cmd.getProjectId();
@@ -1594,7 +1594,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
 
     @Override
     public boolean applyStaticRoutes(long vpcId) throws ResourceUnavailableException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<? extends StaticRoute> routes = _staticRouteDao.listByVpcId(vpcId);
         return applyStaticRoutes(routes, caller, true);
     }
@@ -1662,7 +1662,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     @Override
     @ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_DELETE, eventDescription = "deleting static route")
     public boolean revokeStaticRoute(long routeId) throws ResourceUnavailableException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         
         StaticRouteVO route = _staticRouteDao.findById(routeId);
         if (route == null) {
@@ -1699,7 +1699,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     @DB
     @ActionEvent(eventType = EventTypes.EVENT_STATIC_ROUTE_CREATE, eventDescription = "creating static route", create=true)
     public StaticRoute createStaticRoute(long gatewayId, String cidr) throws NetworkRuleConflictException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         
         //parameters validation
         VpcGateway gateway = _vpcGatewayDao.findById(gatewayId);
@@ -1782,7 +1782,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
         Boolean isRecursive = cmd.isRecursive();
         Boolean listAll = cmd.listAll();
         String accountName = cmd.getAccountName();
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
         Map<String, String> tags = cmd.getTags();
         Long projectId = cmd.getProjectId();
@@ -1924,7 +1924,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
     @ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "associating Ip", async = true)
     public IpAddress associateIPToVpc(long ipId, long vpcId) throws ResourceAllocationException, ResourceUnavailableException, 
     InsufficientAddressCapacityException, ConcurrentOperationException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Account owner = null;
 
         IpAddress ipToAssoc = _ntwkModel.getIp(ipId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/54de6b48/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
index 9e7bb13..472281b 100755
--- a/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
+++ b/server/src/com/cloud/network/vpn/RemoteAccessVpnManagerImpl.java
@@ -114,7 +114,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
     public RemoteAccessVpn createRemoteAccessVpn(long publicIpId, String ipRange, boolean openFirewall, long networkId) 
             throws NetworkRuleConflictException {
         UserContext ctx = UserContext.current();
-        Account caller = ctx.getCaller();
+        Account caller = ctx.getCallingAccount();
 
         // make sure ip address exists
         PublicIpAddress ipAddr = _networkMgr.getPublicIpAddress(publicIpId);
@@ -312,7 +312,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
     @Override
     @DB
     public VpnUser addVpnUser(long vpnOwnerId, String username, String password) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         if (!username.matches("^[a-zA-Z0-9][a-zA-Z0-9@._-]{2,63}$")) {
             throw new InvalidParameterValueException(
@@ -366,7 +366,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
 
     @Override
     public List<? extends VpnUser> listVpnUsers(long vpnOwnerId, String userName) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Account owner = _accountDao.findById(vpnOwnerId);
         _accountMgr.checkAccess(caller, null, true, owner);
         return _vpnUsersDao.listByAccount(vpnOwnerId);
@@ -374,7 +374,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
 
     @Override @DB
     public RemoteAccessVpnVO startRemoteAccessVpn(long ipAddressId, boolean openFirewall) throws ResourceUnavailableException {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
 
         RemoteAccessVpnVO vpn = _remoteAccessVpnDao.findByPublicIpAddress(ipAddressId);
         if (vpn == null) {
@@ -425,7 +425,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
     @DB
     @Override
     public boolean applyVpnUsers(long vpnOwnerId, String userName) {
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Account owner = _accountDao.findById(vpnOwnerId);
         _accountMgr.checkAccess(caller, null, true, owner);
 
@@ -504,7 +504,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
     public Pair<List<? extends VpnUser>, Integer> searchForVpnUsers(ListVpnUsersCmd cmd) {
         String username = cmd.getUsername();
         Long id = cmd.getId();
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         List<Long> permittedAccounts = new ArrayList<Long>();
 
         Ternary<Long, Boolean, ListProjectResourcesCriteria> domainIdRecursiveListProject = new Ternary<Long, Boolean, ListProjectResourcesCriteria>(cmd.getDomainId(), cmd.isRecursive(), null);
@@ -542,7 +542,7 @@ public class RemoteAccessVpnManagerImpl extends ManagerBase implements RemoteAcc
     @Override
     public Pair<List<? extends RemoteAccessVpn>, Integer> searchForRemoteAccessVpns(ListRemoteAccessVpnsCmd cmd) {
         // do some parameter validation
-        Account caller = UserContext.current().getCaller();
+        Account caller = UserContext.current().getCallingAccount();
         Long ipAddressId = cmd.getPublicIpId();
         List<Long> permittedAccounts = new ArrayList<Long>();
 


Mime
View raw message