cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ahu...@apache.org
Subject [1/4] git commit: updated refs/heads/master to abbae2a
Date Tue, 27 Aug 2013 00:29:52 GMT
Updated Branches:
  refs/heads/master 89b54596f -> abbae2aa8


Removed getzone


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ff6b3fd1
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ff6b3fd1
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ff6b3fd1

Branch: refs/heads/master
Commit: ff6b3fd11a6b04f2be1d019661d4d254f93d7aff
Parents: 89b5459
Author: Alex Huang <alex.huang@citrix.com>
Authored: Mon Aug 26 15:04:40 2013 -0700
Committer: Alex Huang <alex.huang@citrix.com>
Committed: Mon Aug 26 17:31:08 2013 -0700

----------------------------------------------------------------------
 .../configuration/ConfigurationService.java     | 18 ++---
 .../user/address/AssociateIPAddrCmd.java        |  4 +-
 .../loadbalancer/CreateLoadBalancerRuleCmd.java |  2 +-
 .../api/command/user/vm/DeployVMCmd.java        |  2 +-
 .../com/cloud/vm/VirtualMachineManagerImpl.java |  8 +--
 .../cloud/network/element/CiscoVnmcElement.java |  5 +-
 .../network/element/CiscoVnmcElementTest.java   |  5 +-
 .../element/InternalLoadBalancerElement.java    | 58 ++++++++-------
 .../ElementChildTestConfiguration.java          |  5 ++
 .../InternalLbElementTest.java                  | 41 ++++++-----
 .../JuniperSRXExternalFirewallElement.java      | 76 ++++++++++++++------
 .../configuration/ConfigurationManagerImpl.java |  7 +-
 .../com/cloud/network/IpAddressManagerImpl.java | 12 ++--
 .../com/cloud/network/NetworkManagerImpl.java   | 11 +--
 .../com/cloud/network/NetworkServiceImpl.java   | 13 ++--
 .../cloud/network/as/AutoScaleManagerImpl.java  | 19 +++--
 .../cloud/network/guru/PrivateNetworkGuru.java  | 22 +++---
 .../lb/LoadBalancingRulesManagerImpl.java       |  5 +-
 .../VpcVirtualNetworkApplianceManagerImpl.java  |  5 +-
 .../com/cloud/network/vpc/VpcManagerImpl.java   |  7 +-
 .../cloud/vpc/MockConfigurationManagerImpl.java | 49 +------------
 21 files changed, 194 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/api/src/com/cloud/configuration/ConfigurationService.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/configuration/ConfigurationService.java b/api/src/com/cloud/configuration/ConfigurationService.java
index 1af4867..938b061 100644
--- a/api/src/com/cloud/configuration/ConfigurationService.java
+++ b/api/src/com/cloud/configuration/ConfigurationService.java
@@ -20,12 +20,6 @@ import java.util.List;
 
 import javax.naming.NamingException;
 
-import com.cloud.exception.InvalidParameterValueException;
-import com.cloud.exception.InsufficientCapacityException;
-import com.cloud.exception.ConcurrentOperationException;
-import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.exception.ResourceAllocationException;
-
 import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
 import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
 import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
@@ -52,19 +46,23 @@ import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
 import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
 import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
 import org.apache.cloudstack.config.Configuration;
+import org.apache.cloudstack.region.PortableIp;
+import org.apache.cloudstack.region.PortableIpRange;
 
 import com.cloud.dc.DataCenter;
 import com.cloud.dc.Pod;
 import com.cloud.dc.Vlan;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceAllocationException;
+import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.offering.DiskOffering;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.ServiceOffering;
 import com.cloud.user.Account;
 
-import org.apache.cloudstack.region.PortableIp;
-import org.apache.cloudstack.region.PortableIpRange;
-
 public interface ConfigurationService {
 
     /**
@@ -265,8 +263,6 @@ public interface ConfigurationService {
 
     List<? extends NetworkOffering> listNetworkOfferings(TrafficType trafficType, boolean systemOnly);
 
-    DataCenter getZone(long id);
-
     ServiceOffering getServiceOffering(long serviceOfferingId);
 
     Long getDefaultPageSize();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
index cb3da6b..fa1570e 100644
--- a/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/address/AssociateIPAddrCmd.java
@@ -164,7 +164,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
             return null;
         }
 
-        DataCenter zone = _configService.getZone(zoneId);
+        DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
         if (zone.getNetworkType() == NetworkType.Advanced) {
             List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(),
                     _accountService.getAccount(getEntityOwnerId()));
@@ -218,7 +218,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
 
             NetworkOffering offering = _configService.getNetworkOffering(network.getNetworkOfferingId());
 
-            DataCenter zone = _configService.getZone(network.getDataCenterId());
+            DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
             if (zone.getNetworkType() == NetworkType.Basic && offering.getElasticIp() && offering.getElasticLb()) {
                 // Since the basic zone network is owned by 'Root' domain, domain access checkers will fail for the
                 // accounts in non-root domains while acquiring public IP. So add an exception for the 'Basic' zone

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
index 281b129..157315f 100644
--- a/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/loadbalancer/CreateLoadBalancerRuleCmd.java
@@ -164,7 +164,7 @@ public class CreateLoadBalancerRuleCmd extends BaseAsyncCreateCmd  /*implements
         }
 
         if (zoneId != null) {
-            DataCenter zone = _configService.getZone(zoneId);
+            DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
             if (zone.getNetworkType() == NetworkType.Advanced) {
                 List<? extends Network> networks = _networkService.getIsolatedNetworksOwnedByAccountInZone(getZoneId(), _accountService.getAccount(getEntityOwnerId()));
                 if (networks.size() == 0) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
index 40ad8e0..75c1c79 100755
--- a/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/vm/DeployVMCmd.java
@@ -455,7 +455,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd {
             //Verify that all objects exist before passing them to the service
             Account owner = _accountService.getActiveAccountById(getEntityOwnerId());
 
-            DataCenter zone = _configService.getZone(zoneId);
+            DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
             if (zone == null) {
                 throw new InvalidParameterValueException("Unable to find zone by id=" + zoneId);
             }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
index 19ded96..26bcfa4 100755
--- a/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/engine/orchestration/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -1902,7 +1902,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
             ResourceUnavailableException {
         VMInstanceVO vm = _vmDao.findByUuid(vmUuid);
 
-        DataCenter dc = _configMgr.getZone(vm.getDataCenterId());
+        DataCenter dc = _entityMgr.findById(DataCenter.class, vm.getDataCenterId());
         Host host = _hostDao.findById(vm.getHostId());
         Cluster cluster = null;
         if (host != null) {
@@ -2771,7 +2771,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
 
         VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmVO, null, null, null, null);
 
-        DataCenter dc = _configMgr.getZone(network.getDataCenterId());
+        DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
         Host host = _hostDao.findById(vm.getHostId());
         DeployDestination dest = new DeployDestination(dc, null, null, host);
 
@@ -2840,7 +2840,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmVO, null,
                 null, null, null);
 
-        DataCenter dc = _configMgr.getZone(network.getDataCenterId());
+        DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
         Host host = _hostDao.findById(vm.getHostId());
         DeployDestination dest = new DeployDestination(dc, null, null, host);
         HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vmProfile.getVirtualMachine().getHypervisorType());
@@ -2904,7 +2904,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
         VirtualMachineProfileImpl vmProfile = new VirtualMachineProfileImpl(vmVO, null,
                 null, null, null);
 
-        DataCenter dc = _configMgr.getZone(network.getDataCenterId());
+        DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
         Host host = _hostDao.findById(vm.getHostId());
         DeployDestination dest = new DeployDestination(dc, null, null, host);
         HypervisorGuru hvGuru = _hvGuruMgr.getGuru(vmProfile.getVirtualMachine().getHypervisorType());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
index 3ae6a08..088bfae 100644
--- a/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
+++ b/plugins/network-elements/cisco-vnmc/src/com/cloud/network/element/CiscoVnmcElement.java
@@ -121,6 +121,7 @@ import com.cloud.resource.ServerResource;
 import com.cloud.resource.UnableDeleteHostException;
 import com.cloud.user.Account;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.NetUtils;
@@ -137,6 +138,8 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
     private static final Map<Service, Map<Capability, String>> capabilities = setCapabilities();
 
     @Inject
+    EntityManager _entityMgr;
+    @Inject
     AgentManager _agentMgr;
     @Inject
     ResourceManager _resourceMgr;
@@ -275,7 +278,7 @@ public class CiscoVnmcElement extends AdapterBase implements SourceNatServicePro
             DeployDestination dest, ReservationContext context)
             throws ConcurrentOperationException, ResourceUnavailableException,
             InsufficientCapacityException {
-        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+        DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
 
         if (zone.getNetworkType() == NetworkType.Basic) {
             s_logger.debug("Not handling network implement in zone of type " + NetworkType.Basic);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/plugins/network-elements/cisco-vnmc/test/com/cloud/network/element/CiscoVnmcElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/cisco-vnmc/test/com/cloud/network/element/CiscoVnmcElementTest.java b/plugins/network-elements/cisco-vnmc/test/com/cloud/network/element/CiscoVnmcElementTest.java
index 36460a8..4ef5ddd 100755
--- a/plugins/network-elements/cisco-vnmc/test/com/cloud/network/element/CiscoVnmcElementTest.java
+++ b/plugins/network-elements/cisco-vnmc/test/com/cloud/network/element/CiscoVnmcElementTest.java
@@ -83,6 +83,7 @@ import com.cloud.network.rules.StaticNat;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.resource.ResourceManager;
 import com.cloud.user.Account;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.net.Ip;
 import com.cloud.vm.ReservationContext;
 
@@ -102,6 +103,7 @@ public class CiscoVnmcElementTest {
     CiscoNexusVSMDeviceDao _vsmDeviceDao = mock(CiscoNexusVSMDeviceDao.class);
     VlanDao _vlanDao = mock(VlanDao.class);
     IpAddressManager _ipAddrMgr = mock(IpAddressManager.class);
+    EntityManager _entityMgr = mock(EntityManager.class);
 
     @Before
     public void setUp() throws ConfigurationException {
@@ -117,6 +119,7 @@ public class CiscoVnmcElementTest {
         _element._clusterVsmMapDao = _clusterVsmMapDao;
         _element._vsmDeviceDao = _vsmDeviceDao;
         _element._vlanDao = _vlanDao;
+        _element._entityMgr = _entityMgr;
 
         // Standard responses
         when(_networkModel.isProviderForNetwork(Provider.CiscoVnmc, 1L)).thenReturn(true);
@@ -164,7 +167,7 @@ public class CiscoVnmcElementTest {
 
         DataCenter dc = mock(DataCenter.class);
         when(dc.getNetworkType()).thenReturn(NetworkType.Advanced);
-        when(_configMgr.getZone(network.getDataCenterId())).thenReturn(dc);
+        when(_entityMgr.findById(DataCenter.class, network.getDataCenterId())).thenReturn(dc);
 
         List<CiscoVnmcControllerVO> devices = new ArrayList<CiscoVnmcControllerVO>();
         devices.add(mock(CiscoVnmcControllerVO.class));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
index 2376038..0b9a1b4 100644
--- a/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
+++ b/plugins/network-elements/internal-loadbalancer/src/org/apache/cloudstack/network/element/InternalLoadBalancerElement.java
@@ -11,7 +11,7 @@
 // Unless required by applicable law or agreed to in writing,
 // software distributed under the License is distributed on an
 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the 
+// KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
 
@@ -27,12 +27,13 @@ import java.util.Set;
 import javax.ejb.Local;
 import javax.inject.Inject;
 
+import org.apache.log4j.Logger;
+
 import org.apache.cloudstack.api.command.admin.internallb.ConfigureInternalLoadBalancerElementCmd;
 import org.apache.cloudstack.api.command.admin.internallb.CreateInternalLoadBalancerElementCmd;
 import org.apache.cloudstack.api.command.admin.internallb.ListInternalLoadBalancerElementsCmd;
 import org.apache.cloudstack.lb.dao.ApplicationLoadBalancerRuleDao;
 import org.apache.cloudstack.network.lb.InternalLoadBalancerVMManager;
-import org.apache.log4j.Logger;
 
 import com.cloud.agent.api.to.LoadBalancerTO;
 import com.cloud.configuration.ConfigurationManager;
@@ -71,6 +72,7 @@ import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
 import com.cloud.user.User;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.SearchCriteria2;
 import com.cloud.utils.db.SearchCriteriaService;
@@ -98,7 +100,9 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     @Inject ConfigurationManager _configMgr;
     @Inject AccountManager _accountMgr;
     @Inject ApplicationLoadBalancerRuleDao _appLbDao;
-    
+    @Inject
+    EntityManager _entityMgr;
+
     protected InternalLoadBalancerElement() {
     }
     
@@ -113,7 +117,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     
     private boolean canHandle(Network config, Scheme lbScheme) {
         //works in Advance zone only
-        DataCenter dc = _configMgr.getZone(config.getDataCenterId());
+        DataCenter dc = _entityMgr.findById(DataCenter.class, config.getDataCenterId());
         if (dc.getNetworkType() != NetworkType.Advanced) {
             s_logger.trace("Not hanling zone of network type " + dc.getNetworkType());
             return false;
@@ -123,12 +127,12 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
             return false;
         }
         
-        Map<Capability, String> lbCaps = this.getCapabilities().get(Service.Lb);
+        Map<Capability, String> lbCaps = getCapabilities().get(Service.Lb);
         if (!lbCaps.isEmpty()) {
             String schemeCaps = lbCaps.get(Capability.LbSchemes);
             if (schemeCaps != null && lbScheme != null) {
                 if (!schemeCaps.contains(lbScheme.toString())) {
-                    s_logger.debug("Scheme " + lbScheme.toString() + " is not supported by the provider " + this.getName());
+                    s_logger.debug("Scheme " + lbScheme.toString() + " is not supported by the provider " + getName());
                     return false;
                 }
             }
@@ -161,7 +165,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
             InsufficientCapacityException {
         
         if (!canHandle(network, null)) {
-            s_logger.trace("No need to implement " + this.getName());
+            s_logger.trace("No need to implement " + getName());
             return true;
         }
         
@@ -174,7 +178,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
             ResourceUnavailableException, InsufficientCapacityException {
         
         if (!canHandle(network, null)) {
-            s_logger.trace("No need to prepare " + this.getName());
+            s_logger.trace("No need to prepare " + getName());
             return true;
         }
         
@@ -200,18 +204,18 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
                 try {
                     internalLbVms = _internalLbMgr.deployInternalLbVm(network, sourceIp, dest, _accountMgr.getAccount(network.getAccountId()), null);
                 } catch (InsufficientCapacityException e) {
-                    s_logger.warn("Failed to deploy element " + this.getName() + " for ip " + sourceIp + " due to:", e);
+                    s_logger.warn("Failed to deploy element " + getName() + " for ip " + sourceIp + " due to:", e);
                     return false;
                 } catch (ConcurrentOperationException e) {
-                    s_logger.warn("Failed to deploy element " + this.getName() + " for ip " + sourceIp +  " due to:", e);
+                    s_logger.warn("Failed to deploy element " + getName() + " for ip " + sourceIp +  " due to:", e);
                     return false;
                 }
                 
                 if (internalLbVms == null || internalLbVms.isEmpty()) {
-                    throw new ResourceUnavailableException("Can't deploy " + this.getName() + " to handle LB rules",
+                    throw new ResourceUnavailableException("Can't deploy " + getName() + " to handle LB rules",
                             DataCenter.class, network.getDataCenterId());
                 }
-            }  
+            }
         }
         
         return true;
@@ -265,7 +269,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     
     @Override
     public boolean isReady(PhysicalNetworkServiceProvider provider) {
-        VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), 
+        VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(),
                 VirtualRouterProviderType.InternalLbVm);
         if (element == null) {
             return false;
@@ -277,7 +281,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     @Override
     public boolean shutdownProviderInstances(PhysicalNetworkServiceProvider provider, ReservationContext context)
             throws ConcurrentOperationException, ResourceUnavailableException {
-        VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(), 
+        VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(provider.getId(),
                 VirtualRouterProviderType.InternalLbVm);
         if (element == null) {
             return true;
@@ -320,7 +324,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
         
         //2) Get rules to apply
         Map<Ip, List<LoadBalancingRule>> rulesToApply = getLbRulesToApply(rules);
-        s_logger.debug("Applying " + rulesToApply.size() + " on element " + this.getName());
+        s_logger.debug("Applying " + rulesToApply.size() + " on element " + getName());
 
  
         for (Ip sourceIp : rulesToApply.keySet()) {
@@ -334,7 +338,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
                         return _internalLbMgr.destroyInternalLbVm(vms.get(0).getId(), _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM),
                                 _accountMgr.getUserIncludingRemoved(User.UID_SYSTEM).getId());
                     } catch (ConcurrentOperationException e) {
-                        s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr() + " on the element " + this.getName() + " due to:", e);
+                        s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr() + " on the element " + getName() + " due to:", e);
                         return false;
                     }
                 }
@@ -342,13 +346,13 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
                 //2.2 Start Internal LB vm per IP address
                 List<? extends VirtualRouter> internalLbVms;
                 try {
-                    DeployDestination dest = new DeployDestination(_configMgr.getZone(network.getDataCenterId()), null, null, null); 
+                    DeployDestination dest = new DeployDestination(_entityMgr.findById(DataCenter.class, network.getDataCenterId()), null, null, null);
                     internalLbVms = _internalLbMgr.deployInternalLbVm(network, sourceIp, dest, _accountMgr.getAccount(network.getAccountId()), null);
                 } catch (InsufficientCapacityException e) {
-                    s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr() + "on the element " + this.getName() + " due to:", e);
+                    s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr() + "on the element " + getName() + " due to:", e);
                     return false;
                 } catch (ConcurrentOperationException e) {
-                    s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr() + "on the element " + this.getName() + " due to:", e);
+                    s_logger.warn("Failed to apply lb rule(s) for ip " + sourceIp.addr() + "on the element " + getName() + " due to:", e);
                     return false;
                 }
                 
@@ -359,13 +363,13 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
                  
                 //2.3 Apply Internal LB rules on the VM
                 if (!_internalLbMgr.applyLoadBalancingRules(network, rulesToApply.get(sourceIp), internalLbVms)) {
-                    throw new CloudRuntimeException("Failed to apply load balancing rules for ip " + sourceIp.addr() + 
-                            " in network " + network.getId() + " on element " + this.getName());
+                    throw new CloudRuntimeException("Failed to apply load balancing rules for ip " + sourceIp.addr() +
+                            " in network " + network.getId() + " on element " + getName());
                 }
             }
         }
 
-        return true;    
+        return true;
     }
 
     
@@ -464,8 +468,8 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     public VirtualRouterProvider configureInternalLoadBalancerElement(long id, boolean enable) {
         VirtualRouterProviderVO element = _vrProviderDao.findById(id);
         if (element == null || element.getType() != VirtualRouterProviderType.InternalLbVm) {
-            throw new InvalidParameterValueException("Can't find " + this.getName() + " element with network service provider id " + id +
-                    " to be used as a provider for " + this.getName());
+            throw new InvalidParameterValueException("Can't find " + getName() + " element with network service provider id " + id +
+                    " to be used as a provider for " + getName());
         }
 
         element.setEnabled(enable);
@@ -478,12 +482,12 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     public VirtualRouterProvider addInternalLoadBalancerElement(long ntwkSvcProviderId) {
         VirtualRouterProviderVO element = _vrProviderDao.findByNspIdAndType(ntwkSvcProviderId, VirtualRouterProviderType.InternalLbVm);
         if (element != null) {
-            s_logger.debug("There is already an " + this.getName() + " with service provider id " + ntwkSvcProviderId);
+            s_logger.debug("There is already an " + getName() + " with service provider id " + ntwkSvcProviderId);
             return null;
         }
         
         PhysicalNetworkServiceProvider provider = _pNtwkSvcProviderDao.findById(ntwkSvcProviderId);
-        if (provider == null || !provider.getProviderName().equalsIgnoreCase(this.getName())) {
+        if (provider == null || !provider.getProviderName().equalsIgnoreCase(getName())) {
             throw new InvalidParameterValueException("Invalid network service provider is specified");
         }
         
@@ -497,7 +501,7 @@ public class InternalLoadBalancerElement extends AdapterBase implements LoadBala
     public VirtualRouterProvider getInternalLoadBalancerElement(long id) {
         VirtualRouterProvider provider = _vrProviderDao.findById(id);
         if (provider == null || provider.getType() != VirtualRouterProviderType.InternalLbVm) {
-            throw new InvalidParameterValueException("Unable to find " + this.getName() + " by id");
+            throw new InvalidParameterValueException("Unable to find " + getName() + " by id");
         }
         return provider;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/ElementChildTestConfiguration.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/ElementChildTestConfiguration.java b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/ElementChildTestConfiguration.java
index 7c23104..8d6366b 100644
--- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/ElementChildTestConfiguration.java
+++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/ElementChildTestConfiguration.java
@@ -41,6 +41,7 @@ import com.cloud.network.dao.NetworkServiceMapDao;
 import com.cloud.network.dao.PhysicalNetworkServiceProviderDao;
 import com.cloud.network.dao.VirtualRouterProviderDao;
 import com.cloud.user.AccountManager;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.dao.DomainRouterDao;
 
@@ -107,6 +108,10 @@ public class ElementChildTestConfiguration {
             return Mockito.mock(ConfigurationManager.class);
         }
         
+        @Bean
+        public EntityManager entityManager() {
+            return Mockito.mock(EntityManager.class);
+        }
         
         @Bean
         public ApplicationLoadBalancerRuleDao applicationLoadBalancerRuleDao() {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementTest.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementTest.java b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementTest.java
index f19612f..7af6796 100644
--- a/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementTest.java
+++ b/plugins/network-elements/internal-loadbalancer/test/org/apache/cloudstack/internallbelement/InternalLbElementTest.java
@@ -5,7 +5,7 @@
 // to you under the Apache License, Version 2.0 (the
 // "License"); you may not use this file except in compliance
 // with the License.  You may obtain a copy of the License at
-// 
+//
 //   http://www.apache.org/licenses/LICENSE-2.0
 //
 // Unless required by applicable law or agreed to in writing,
@@ -28,9 +28,6 @@ import java.util.List;
 
 import javax.inject.Inject;
 
-import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
-import org.apache.cloudstack.network.element.InternalLoadBalancerElement;
-import org.apache.cloudstack.network.lb.InternalLoadBalancerVMManager;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -38,8 +35,13 @@ import org.mockito.Mockito;
 import org.springframework.test.context.ContextConfiguration;
 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
+import org.apache.cloudstack.lb.ApplicationLoadBalancerRuleVO;
+import org.apache.cloudstack.network.element.InternalLoadBalancerElement;
+import org.apache.cloudstack.network.lb.InternalLoadBalancerVMManager;
+
 import com.cloud.agent.api.to.LoadBalancerTO;
 import com.cloud.configuration.ConfigurationManager;
+import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.DataCenterVO;
 import com.cloud.exception.ResourceUnavailableException;
@@ -57,6 +59,7 @@ import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.user.AccountManager;
 import com.cloud.utils.component.ComponentContext;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.net.Ip;
 
 @RunWith(SpringJUnit4ClassRunner.class)
@@ -71,6 +74,8 @@ public class InternalLbElementTest {
     @Inject PhysicalNetworkServiceProviderDao _pNtwkProviderDao;
     @Inject InternalLoadBalancerVMManager _internalLbMgr;
     @Inject ConfigurationManager _configMgr;
+    @Inject
+    EntityManager _entityMgr;
     
     long validElId = 1L;
     long nonExistingElId = 2L;
@@ -109,20 +114,20 @@ public class InternalLbElementTest {
         
         DataCenterVO dc = new DataCenterVO
                 (1L, null, null, null, null, null, null, null, null, null, NetworkType.Advanced, null, null);
-        Mockito.when(_configMgr.getZone(Mockito.anyLong())).thenReturn(dc);
+        Mockito.when(_entityMgr.findById(Mockito.eq(DataCenter.class), Mockito.anyLong())).thenReturn(dc);
     }
     
     //TEST FOR getProvider() method
     
-    @Test 
-    public void verifyProviderName() {  
+    @Test
+    public void verifyProviderName() {
        Provider pr = _lbEl.getProvider();
        assertEquals("Wrong provider is returned", pr.getName(), Provider.InternalLbVm.getName());
     }
     
     //TEST FOR isReady() METHOD
     
-    @Test 
+    @Test
     public void verifyValidProviderState() {
        PhysicalNetworkServiceProviderVO provider = new PhysicalNetworkServiceProviderVO();
        provider = setId(provider, validElId);
@@ -131,7 +136,7 @@ public class InternalLbElementTest {
     }
     
     
-    @Test 
+    @Test
     public void verifyNonExistingProviderState() {
        PhysicalNetworkServiceProviderVO provider = new PhysicalNetworkServiceProviderVO();
        provider = setId(provider, nonExistingElId);
@@ -140,7 +145,7 @@ public class InternalLbElementTest {
     }
     
     
-    @Test 
+    @Test
     public void verifyInvalidProviderState() {
        PhysicalNetworkServiceProviderVO provider = new PhysicalNetworkServiceProviderVO();
        provider = setId(provider, invalidElId);
@@ -148,7 +153,7 @@ public class InternalLbElementTest {
        assertFalse("Not valid provider is returned as ready", isReady);
     }
     
-    @Test 
+    @Test
     public void verifyNotEnabledProviderState() {
        PhysicalNetworkServiceProviderVO provider = new PhysicalNetworkServiceProviderVO();
        provider = setId(provider, notEnabledElId);
@@ -157,22 +162,22 @@ public class InternalLbElementTest {
     }
     
     //TEST FOR canEnableIndividualServices METHOD
-    @Test 
-    public void verifyCanEnableIndividualSvc() {  
+    @Test
+    public void verifyCanEnableIndividualSvc() {
        boolean result = _lbEl.canEnableIndividualServices();
        assertTrue("Wrong value is returned by canEnableIndividualSvc", result);
     }
     
     //TEST FOR verifyServicesCombination METHOD
-    @Test 
-    public void verifyServicesCombination() {  
+    @Test
+    public void verifyServicesCombination() {
        boolean result = _lbEl.verifyServicesCombination(new HashSet<Service>());
        assertTrue("Wrong value is returned by verifyServicesCombination", result);
     }
     
     
     //TEST FOR applyIps METHOD
-    @Test 
+    @Test
     public void verifyApplyIps() throws ResourceUnavailableException {
        List<PublicIp> ips = new ArrayList<PublicIp>();
        boolean result = _lbEl.applyIps(new NetworkVO(), ips, new HashSet<Service>());
@@ -181,14 +186,14 @@ public class InternalLbElementTest {
     
     
     //TEST FOR updateHealthChecks METHOD
-    @Test 
+    @Test
     public void verifyUpdateHealthChecks() throws ResourceUnavailableException {
        List<LoadBalancerTO> check = _lbEl.updateHealthChecks(new NetworkVO(), new ArrayList<LoadBalancingRule>());
        assertNull("Wrong value is returned by updateHealthChecks method", check);
     }
     
     //TEST FOR validateLBRule METHOD
-    @Test 
+    @Test
     public void verifyValidateLBRule() throws ResourceUnavailableException {
         ApplicationLoadBalancerRuleVO lb = new ApplicationLoadBalancerRuleVO(null, null, 22, 22, "roundrobin",
                 1L, 1L, 1L, new Ip("10.10.10.1"), 1L, Scheme.Internal);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
----------------------------------------------------------------------
diff --git a/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java b/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
index 7d99d4b..af67b02 100644
--- a/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
+++ b/plugins/network-elements/juniper-srx/src/com/cloud/network/element/JuniperSRXExternalFirewallElement.java
@@ -11,13 +11,35 @@
 // Unless required by applicable law or agreed to in writing,
 // software distributed under the License is distributed on an
 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the 
+// KIND, either express or implied.  See the License for the
 // specific language governing permissions and limitations
 // under the License.
 package com.cloud.network.element;
 
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import javax.ejb.Local;
+import javax.inject.Inject;
+
+import org.apache.log4j.Logger;
+
+import org.apache.cloudstack.api.response.ExternalFirewallResponse;
+import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
+import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
+
 import com.cloud.api.ApiDBUtils;
-import com.cloud.api.commands.*;
+import com.cloud.api.commands.AddExternalFirewallCmd;
+import com.cloud.api.commands.AddSrxFirewallCmd;
+import com.cloud.api.commands.ConfigureSrxFirewallCmd;
+import com.cloud.api.commands.DeleteExternalFirewallCmd;
+import com.cloud.api.commands.DeleteSrxFirewallCmd;
+import com.cloud.api.commands.ListExternalFirewallsCmd;
+import com.cloud.api.commands.ListSrxFirewallNetworksCmd;
+import com.cloud.api.commands.ListSrxFirewallsCmd;
 import com.cloud.api.response.SrxFirewallResponse;
 import com.cloud.configuration.Config;
 import com.cloud.configuration.ConfigurationManager;
@@ -26,17 +48,36 @@ import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.*;
+import com.cloud.exception.ConcurrentOperationException;
+import com.cloud.exception.InsufficientCapacityException;
+import com.cloud.exception.InsufficientNetworkCapacityException;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.host.Host;
 import com.cloud.host.HostVO;
 import com.cloud.host.dao.HostDao;
 import com.cloud.host.dao.HostDetailsDao;
-import com.cloud.network.*;
+import com.cloud.network.ExternalFirewallDeviceManagerImpl;
+import com.cloud.network.Network;
 import com.cloud.network.Network.Capability;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
-import com.cloud.network.dao.*;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.PhysicalNetwork;
+import com.cloud.network.PhysicalNetworkServiceProvider;
+import com.cloud.network.PublicIpAddress;
+import com.cloud.network.RemoteAccessVpn;
+import com.cloud.network.VpnUser;
+import com.cloud.network.dao.ExternalFirewallDeviceDao;
+import com.cloud.network.dao.ExternalFirewallDeviceVO;
 import com.cloud.network.dao.ExternalFirewallDeviceVO.FirewallDeviceState;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.dao.NetworkExternalFirewallDao;
+import com.cloud.network.dao.NetworkExternalFirewallVO;
+import com.cloud.network.dao.NetworkServiceMapDao;
+import com.cloud.network.dao.NetworkVO;
+import com.cloud.network.dao.PhysicalNetworkDao;
+import com.cloud.network.dao.PhysicalNetworkVO;
 import com.cloud.network.resource.JuniperSrxResource;
 import com.cloud.network.rules.FirewallRule;
 import com.cloud.network.rules.PortForwardingRule;
@@ -44,25 +85,14 @@ import com.cloud.network.rules.StaticNat;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offerings.dao.NetworkOfferingDao;
 import com.cloud.utils.NumbersUtil;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
-import org.apache.cloudstack.api.response.ExternalFirewallResponse;
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-import org.apache.cloudstack.network.ExternalNetworkDeviceManager.NetworkDevice;
-
-import org.apache.log4j.Logger;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-
-import java.util.*;
-
-@Local(value = {NetworkElement.class, FirewallServiceProvider.class, 
-        PortForwardingServiceProvider.class, IpDeployer.class, 
+@Local(value = {NetworkElement.class, FirewallServiceProvider.class,
+        PortForwardingServiceProvider.class, IpDeployer.class,
         SourceNatServiceProvider.class, RemoteAccessVPNServiceProvider.class})
 public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceManagerImpl implements SourceNatServiceProvider, FirewallServiceProvider,
 PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer, JuniperSRXFirewallElementService, StaticNatServiceProvider {
@@ -97,9 +127,11 @@ PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer, Junip
     HostDetailsDao _hostDetailDao;
     @Inject
     ConfigurationDao _configDao;
+    @Inject
+    EntityManager _entityMgr;
 
     private boolean canHandle(Network network, Service service) {
-        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+        DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
         if ((zone.getNetworkType() == NetworkType.Advanced && !(network.getGuestType() == Network.GuestType.Isolated ||
                 network.getGuestType() == Network.GuestType.Shared )) ||
                 (zone.getNetworkType() == NetworkType.Basic && network.getGuestType() != Network.GuestType.Shared)) {
@@ -125,7 +157,7 @@ PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer, Junip
     @Override
     public boolean implement(Network network, NetworkOffering offering, DeployDestination dest, ReservationContext context) throws ResourceUnavailableException, ConcurrentOperationException,
     InsufficientNetworkCapacityException {
-        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+        DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
 
         // don't have to implement network is Basic zone
         if (zone.getNetworkType() == NetworkType.Basic) {
@@ -160,7 +192,7 @@ PortForwardingServiceProvider, RemoteAccessVPNServiceProvider, IpDeployer, Junip
 
     @Override
     public boolean shutdown(Network network, ReservationContext context, boolean cleanup) throws ResourceUnavailableException, ConcurrentOperationException {
-        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+        DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
 
         // don't have to implement network is Basic zone
         if (zone.getNetworkType() == NetworkType.Basic) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 57dc0b3..b31dfe3 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -4379,7 +4379,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
         Boolean forVpc = cmd.getForVpc();
 
         if (zoneId != null) {
-            zone = getZone(zoneId);
+            zone = _entityMgr.findById(DataCenter.class, zoneId);
             if (zone == null) {
                 throw new InvalidParameterValueException("Unable to find the zone by id=" + zoneId);
             }
@@ -4768,11 +4768,6 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
     }
 
     @Override
-    public DataCenterVO getZone(long id) {
-        return _zoneDao.findById(id);
-    }
-
-    @Override
     public NetworkOffering getNetworkOffering(long id) {
         return _networkOfferingDao.findById(id);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/server/src/com/cloud/network/IpAddressManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/IpAddressManagerImpl.java b/server/src/com/cloud/network/IpAddressManagerImpl.java
index 1ac9c4f..74d9150 100644
--- a/server/src/com/cloud/network/IpAddressManagerImpl.java
+++ b/server/src/com/cloud/network/IpAddressManagerImpl.java
@@ -409,7 +409,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
         // check permissions
         _accountMgr.checkAccess(caller, null, false, ipOwner);
 
-        DataCenter zone = _configMgr.getZone(zoneId);
+        DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
 
         return allocateIp(ipOwner, isSystem, caller, callerUserId, zone);
     }
@@ -702,7 +702,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
 
         sc.setParameters("dc", dcId);
 
-        DataCenter zone = _configMgr.getZone(dcId);
+        DataCenter zone = _entityMgr.findById(DataCenter.class, dcId);
 
         // for direct network take ip addresses only from the vlans belonging to the network
         if (vlanUse == VlanType.DirectAttached) {
@@ -1153,7 +1153,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
                 throw new InvalidParameterValueException("Invalid network id is given");
             }
 
-            DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+            DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
             if (zone.getNetworkType() == NetworkType.Advanced) {
                 if (network.getGuestType() == Network.GuestType.Shared) {
                     if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) {
@@ -1185,7 +1185,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
             return null;
         }
 
-        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+        DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
 
         // allow associating IP addresses to guest network only
         if (network.getTrafficType() != TrafficType.Guest) {
@@ -1300,7 +1300,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
                 throw new InvalidParameterValueException("IP " + ipToAssoc + " is not associated with network id" + networkId);
             }
 
-            DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+            DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
             if (zone.getNetworkType() == NetworkType.Advanced) {
                 if (network.getGuestType() == Network.GuestType.Shared) {
                     assert (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()));
@@ -1315,7 +1315,7 @@ public class IpAddressManagerImpl extends ManagerBase implements IpAddressManage
             return null;
         }
 
-        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+        DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
 
         // Check that network belongs to IP owner - skip this check
         //     - if zone is basic zone as there is just one guest network,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/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 00103e3..09e48df 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -37,7 +37,6 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 
 import org.apache.cloudstack.acl.ControlledEntity.ACLType;
 import org.apache.cloudstack.context.CallContext;
@@ -162,6 +161,7 @@ import com.cloud.utils.component.AdapterBase;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.GlobalLock;
 import com.cloud.utils.db.JoinBuilder.JoinType;
 import com.cloud.utils.db.SearchBuilder;
@@ -194,10 +194,11 @@ import com.cloud.vm.dao.VMInstanceDao;
 /**
  * NetworkManagerImpl implements NetworkManager.
  */
-@Component
 @Local(value = { NetworkManager.class})
 public class NetworkManagerImpl extends ManagerBase implements NetworkManager, Listener {
     static final Logger s_logger = Logger.getLogger(NetworkManagerImpl.class);
+    @Inject
+    EntityManager _entityMgr;
 
     @Inject
     DataCenterDao _dcDao = null;
@@ -2124,7 +2125,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
         }
 
         //In Basic zone, make sure that there are no non-removed console proxies and SSVMs using the network
-        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+        DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
         if (zone.getNetworkType() == NetworkType.Basic) {
             List<VMInstanceVO> systemVms = _vmDao.listNonRemovedVmsByTypeAndNetwork(network.getId(),
                     Type.ConsoleProxy, Type.SecondaryStorageVm);
@@ -2454,7 +2455,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
 
     protected boolean isSharedNetworkWithServices(Network network) {
         assert(network != null);
-        DataCenter zone = _configMgr.getZone(network.getDataCenterId());
+        DataCenter zone = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
         if (network.getGuestType() == Network.GuestType.Shared &&
                 zone.getNetworkType() == NetworkType.Advanced &&
                 isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) {
@@ -2973,7 +2974,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L
             ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
                 
                 VirtualMachine vm = vmProfile.getVirtualMachine();
-                DataCenter dc = _configMgr.getZone(network.getDataCenterId());
+                DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
                 Host host = _hostDao.findById(vm.getHostId());
                 DeployDestination dest = new DeployDestination(dc, null, null, host);
                 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/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 eadd7bc..5984a14 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -152,6 +152,7 @@ import com.cloud.utils.NumbersUtil;
 import com.cloud.utils.Pair;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.JoinBuilder;
 import com.cloud.utils.db.SearchBuilder;
@@ -188,6 +189,8 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
     private static final long MIN_GRE_KEY = 0L;
     private static final long MAX_GRE_KEY = 4294967295L; // 2^32 -1
 
+    @Inject
+    EntityManager _entityMgr;
 
     @Inject
     DataCenterDao _dcDao = null;
@@ -507,7 +510,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
 
         Account caller = CallContext.current().getCallingAccount();
         long callerUserId = CallContext.current().getCallingUserId();
-        DataCenter zone = _configMgr.getZone(zoneId);
+        DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
 
         if (networkId != null) {
             Network network = _networksDao.findById(networkId);
@@ -546,7 +549,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
             throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
         Account caller = CallContext.current().getCallingAccount();
         long callerUserId = CallContext.current().getCallingUserId();
-        DataCenter zone = _configMgr.getZone(zoneId);
+        DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
 
         if ((networkId == null && vpcId == null) || (networkId != null && vpcId != null)) {
             throw new InvalidParameterValueException("One of Network id or VPC is should be passed");
@@ -672,7 +675,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
 
         DataCenter dc = _dcDao.findById(network.getDataCenterId());
 
-        DataCenter zone = _configMgr.getZone(zoneId);
+        DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
         if (zone == null) {
             throw new InvalidParameterValueException("Invalid zone Id is given");
         }
@@ -3860,7 +3863,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
             //Do not allow multiple private gateways with same Vlan within a VPC
             if(vpcId.equals(privateNetwork.getVpcId())){
                 throw new InvalidParameterValueException("Private network for the vlan: " + vlan + " and cidr  "+ cidr +"  already exists " +
-                        "for Vpc "+vpcId+" in zone " + _configMgr.getZone(pNtwk.getDataCenterId()).getName());
+                        "for Vpc "+vpcId+" in zone " + _entityMgr.findById(DataCenter.class, pNtwk.getDataCenterId()).getName());
             }
         }
 
@@ -3868,7 +3871,7 @@ public class NetworkServiceImpl extends ManagerBase implements  NetworkService {
         PrivateIpVO privateIp = _privateIpDao.findByIpAndSourceNetworkIdAndVpcId(privateNetwork.getId(), startIp, vpcId);
         if (privateIp != null) {
             throw new InvalidParameterValueException("Private ip address " + startIp + " already used for private gateway" +
-                    " in zone " + _configMgr.getZone(pNtwk.getDataCenterId()).getName());
+                    " in zone " + _entityMgr.findById(DataCenter.class, pNtwk.getDataCenterId()).getName());
         }
 
         Long mac = dc.getMacAddress();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/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 97c4127..fc237b0 100644
--- a/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
+++ b/server/src/com/cloud/network/as/AutoScaleManagerImpl.java
@@ -24,7 +24,11 @@ import java.util.Map;
 
 import javax.ejb.Local;
 import javax.inject.Inject;
-import javax.naming.ConfigurationException;
+
+import org.apache.log4j.Logger;
+
+import com.google.gson.Gson;
+import com.google.gson.reflect.TypeToken;
 
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.api.ApiConstants;
@@ -46,9 +50,6 @@ import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
 import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 
-import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
-
 import com.cloud.api.ApiDBUtils;
 import com.cloud.api.ApiDispatcher;
 import com.cloud.configuration.Config;
@@ -86,9 +87,9 @@ import com.cloud.user.dao.AccountDao;
 import com.cloud.user.dao.UserDao;
 import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
-import com.cloud.utils.component.Manager;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.GenericDao;
 import com.cloud.utils.db.JoinBuilder;
@@ -98,15 +99,13 @@ import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.Transaction;
 import com.cloud.utils.net.NetUtils;
 
-import com.google.gson.Gson;
-import com.google.gson.reflect.TypeToken;
-
-@Component
 @Local(value = { AutoScaleService.class, AutoScaleManager.class })
 public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScaleManager, AutoScaleService {
     private static final Logger s_logger = Logger.getLogger(AutoScaleManagerImpl.class);
 
     @Inject
+    EntityManager _entityMgr;
+    @Inject
     AccountDao _accountDao;
     @Inject
     AccountManager _accountMgr;
@@ -315,7 +314,7 @@ public class AutoScaleManagerImpl<Type> extends ManagerBase implements AutoScale
         long serviceOfferingId = cmd.getServiceOfferingId();
         long autoscaleUserId = cmd.getAutoscaleUserId();
 
-        DataCenter zone = _configMgr.getZone(zoneId);
+        DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
 
         if (zone == null) {
             throw new InvalidParameterValueException("Unable to find zone by id");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/server/src/com/cloud/network/guru/PrivateNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/PrivateNetworkGuru.java b/server/src/com/cloud/network/guru/PrivateNetworkGuru.java
index 6521cf4..1fa1e5b 100644
--- a/server/src/com/cloud/network/guru/PrivateNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/PrivateNetworkGuru.java
@@ -46,12 +46,12 @@ import com.cloud.network.vpc.dao.PrivateIpDao;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.user.Account;
 import com.cloud.utils.component.AdapterBase;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.Nic.ReservationStrategy;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.ReservationContext;
-import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
 
 @Local(value = NetworkGuru.class)
@@ -63,6 +63,8 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
     protected PrivateIpDao _privateIpDao;
     @Inject
     protected NetworkModel _networkMgr;
+    @Inject
+    EntityManager _entityMgr;
     
     private static final TrafficType[] _trafficTypes = {TrafficType.Guest};
 
@@ -87,7 +89,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
 
     protected boolean canHandle(NetworkOffering offering, DataCenter dc) {
         // This guru handles only system Guest network
-        if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType()) 
+        if (dc.getNetworkType() == NetworkType.Advanced && isMyTrafficType(offering.getTrafficType())
                 && offering.getGuestType() == Network.GuestType.Isolated && offering.isSystemOnly()) {
             return true;
         } else {
@@ -99,7 +101,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
 
     @Override
     public Network design(NetworkOffering offering, DeploymentPlan plan, Network userSpecified, Account owner) {
-        DataCenter dc = _configMgr.getZone(plan.getDataCenterId());
+        DataCenter dc = _entityMgr.findById(DataCenter.class, plan.getDataCenterId());
         if (!canHandle(offering, dc)) {
             return null;
         }
@@ -107,7 +109,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
         NetworkVO network = new NetworkVO(offering.getTrafficType(), Mode.Static, BroadcastDomainType.Vlan, offering.getId(),
                 State.Allocated, plan.getDataCenterId(), plan.getPhysicalNetworkId());
         if (userSpecified != null) {
-            if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) || 
+            if ((userSpecified.getCidr() == null && userSpecified.getGateway() != null) ||
                     (userSpecified.getCidr() != null && userSpecified.getGateway() == null)) {
                 throw new InvalidParameterValueException("cidr and gateway must be specified together.");
             }
@@ -146,7 +148,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
     
     
     @Override
-    public Network implement(Network network, NetworkOffering offering, DeployDestination dest, 
+    public Network implement(Network network, NetworkOffering offering, DeployDestination dest,
             ReservationContext context) throws InsufficientVirtualNetworkCapcityException {
         
         return network;
@@ -155,7 +157,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
     @Override
     public NicProfile allocate(Network network, NicProfile nic, VirtualMachineProfile vm)
             throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
-        DataCenter dc = _configMgr.getZone(network.getDataCenterId());
+        DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
         NetworkOffering offering = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
         if (!canHandle(offering, dc)) {
             return null;
@@ -183,7 +185,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
             PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(network.getDataCenterId(), network.getId(), null);
             String vlanTag = network.getBroadcastUri().getHost();
             String netmask = NetUtils.getCidrNetmask(network.getCidr());
-            PrivateIpAddress ip = new PrivateIpAddress(ipVO, vlanTag, network.getGateway(), netmask, 
+            PrivateIpAddress ip = new PrivateIpAddress(ipVO, vlanTag, network.getGateway(), netmask,
                     NetUtils.long2Mac(NetUtils.createSequenceBasedMacAddress(ipVO.getMacAddress())));
 
             nic.setIp4Address(ip.getIpAddress());
@@ -204,7 +206,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
 
     @Override
     public void updateNicProfile(NicProfile profile, Network network) {
-        DataCenter dc = _configMgr.getZone(network.getDataCenterId());
+        DataCenter dc = _entityMgr.findById(DataCenter.class, network.getDataCenterId());
         if (profile != null) {
             profile.setDns1(dc.getDns1());
             profile.setDns2(dc.getDns2());
@@ -216,7 +218,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
             DeployDestination dest, ReservationContext context)
             throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException {
         if (nic.getIp4Address() == null) {
-            getIp(nic, _configMgr.getZone(network.getDataCenterId()), network);
+            getIp(nic, _entityMgr.findById(DataCenter.class, network.getDataCenterId()), network);
             nic.setStrategy(ReservationStrategy.Create);
         }
     }
@@ -238,7 +240,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
 
     @Override
     public void updateNetworkProfile(NetworkProfile networkProfile) {
-        DataCenter dc = _configMgr.getZone(networkProfile.getDataCenterId());
+        DataCenter dc = _entityMgr.findById(DataCenter.class, networkProfile.getDataCenterId());
         networkProfile.setDns1(dc.getDns1());
         networkProfile.setDns2(dc.getDns2());
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/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 e97fd56..9e14fd0 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -147,6 +147,7 @@ import com.cloud.utils.Pair;
 import com.cloud.utils.Ternary;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.JoinBuilder;
 import com.cloud.utils.db.SearchBuilder;
@@ -249,6 +250,8 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
     @Inject ApplicationLoadBalancerRuleDao _appLbRuleDao;
     @Inject
     IpAddressManager _ipAddrMgr;
+    @Inject
+    EntityManager _entityMgr;
 
     // Will return a string. For LB Stickiness this will be a json, for
     // autoscale this will be "," separated values
@@ -305,7 +308,7 @@ public class LoadBalancingRulesManagerImpl<Type> extends ManagerBase implements
         String vmName = "AutoScale-LB-" + lbName;
         String lbNetworkUuid = null;
 
-        DataCenter zone = _configMgr.getZone(vmGroup.getZoneId());
+        DataCenter zone = _entityMgr.findById(DataCenter.class, vmGroup.getZoneId());
         if (zone == null) {
             // This should never happen, but still a cautious check
             s_logger.warn("Unable to find zone while packaging AutoScale Vm Group, zoneid: " + vmGroup.getZoneId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index ee0d058..82cad0b 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -107,6 +107,7 @@ import com.cloud.user.Account;
 import com.cloud.user.UserStatisticsVO;
 import com.cloud.utils.Pair;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.utils.net.NetUtils;
 import com.cloud.vm.DomainRouterVO;
@@ -124,6 +125,8 @@ import com.cloud.vm.dao.VMInstanceDao;
 @Local(value = {VpcVirtualNetworkApplianceManager.class, VpcVirtualNetworkApplianceService.class})
 public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplianceManagerImpl implements VpcVirtualNetworkApplianceManager{
     private static final Logger s_logger = Logger.getLogger(VpcVirtualNetworkApplianceManagerImpl.class);
+    @Inject
+    EntityManager _entityMgr;
 
     String _name;
     @Inject
@@ -374,7 +377,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         
         Nic nic = _nicDao.findByNtwkIdAndInstanceId(network.getId(), router.getId());
         String networkDomain = network.getNetworkDomain();
-        String dhcpRange = getGuestDhcpRange(guestNic, network, _configMgr.getZone(network.getDataCenterId()));
+        String dhcpRange = getGuestDhcpRange(guestNic, network, _entityMgr.findById(DataCenter.class, network.getDataCenterId()));
         
         NicProfile nicProfile = _networkModel.getNicProfile(router, nic.getNetworkId(), null);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/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 3a7b69b..1e543cb 100644
--- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java
@@ -111,6 +111,7 @@ import com.cloud.utils.Ternary;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.utils.concurrency.NamedThreadFactory;
 import com.cloud.utils.db.DB;
+import com.cloud.utils.db.EntityManager;
 import com.cloud.utils.db.Filter;
 import com.cloud.utils.db.GlobalLock;
 import com.cloud.utils.db.JoinBuilder;
@@ -130,6 +131,8 @@ import com.cloud.vm.dao.DomainRouterDao;
 public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvisioningService{
     private static final Logger s_logger = Logger.getLogger(VpcManagerImpl.class);
     @Inject
+    EntityManager _entityMgr;
+    @Inject
     VpcOfferingDao _vpcOffDao;
     @Inject
     VpcOfferingServiceMapDao _vpcOffSvcMapDao;
@@ -599,7 +602,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
         }
        
         //Validate zone
-        DataCenter zone = _configMgr.getZone(zoneId);
+        DataCenter zone = _entityMgr.findById(DataCenter.class, zoneId);
         if (zone == null) {
             throw new InvalidParameterValueException("Can't find zone by id specified");
         }
@@ -961,7 +964,7 @@ public class VpcManagerImpl extends ManagerBase implements VpcManager, VpcProvis
         //permission check
         _accountMgr.checkAccess(caller, null, false, vpc);
         
-        DataCenter dc = _configMgr.getZone(vpc.getZoneId());
+        DataCenter dc = _entityMgr.findById(DataCenter.class, vpc.getZoneId());
      
         DeployDestination dest = new DeployDestination(dc, null, null, null);
         ReservationContext context = new ReservationContextImpl(null, null, callerUser,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ff6b3fd1/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
index 840f539..3f75625 100755
--- a/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
+++ b/server/test/com/cloud/vpc/MockConfigurationManagerImpl.java
@@ -25,6 +25,8 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 import javax.naming.NamingException;
 
+import org.springframework.stereotype.Component;
+
 import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
 import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
 import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
@@ -50,11 +52,10 @@ import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
 import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
 import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
 import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
+import org.apache.cloudstack.config.Configuration;
 import org.apache.cloudstack.region.PortableIp;
 import org.apache.cloudstack.region.PortableIpRange;
 
-import org.springframework.stereotype.Component;
-
 import com.cloud.configuration.ConfigurationManager;
 import com.cloud.configuration.ConfigurationService;
 import com.cloud.dc.ClusterVO;
@@ -87,41 +88,6 @@ import com.cloud.user.Account;
 import com.cloud.utils.component.ManagerBase;
 import com.cloud.vm.VirtualMachine.Type;
 
-import org.apache.cloudstack.api.command.admin.config.UpdateCfgCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPConfigCmd;
-import org.apache.cloudstack.api.command.admin.ldap.LDAPRemoveCmd;
-import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
-import org.apache.cloudstack.api.command.admin.network.DeleteNetworkOfferingCmd;
-import org.apache.cloudstack.api.command.admin.network.UpdateNetworkOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.CreateDiskOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.CreateServiceOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.DeleteDiskOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.DeleteServiceOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.UpdateDiskOfferingCmd;
-import org.apache.cloudstack.api.command.admin.offering.UpdateServiceOfferingCmd;
-import org.apache.cloudstack.api.command.admin.pod.DeletePodCmd;
-import org.apache.cloudstack.api.command.admin.pod.UpdatePodCmd;
-import org.apache.cloudstack.api.command.admin.vlan.CreateVlanIpRangeCmd;
-import org.apache.cloudstack.api.command.admin.vlan.DedicatePublicIpRangeCmd;
-import org.apache.cloudstack.api.command.admin.vlan.DeleteVlanIpRangeCmd;
-import org.apache.cloudstack.api.command.admin.vlan.ReleasePublicIpRangeCmd;
-import org.apache.cloudstack.api.command.admin.zone.CreateZoneCmd;
-import org.apache.cloudstack.api.command.admin.zone.DeleteZoneCmd;
-import org.apache.cloudstack.api.command.admin.zone.UpdateZoneCmd;
-import org.apache.cloudstack.api.command.user.network.ListNetworkOfferingsCmd;
-import org.apache.cloudstack.config.Configuration;
-
-import org.springframework.stereotype.Component;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-import javax.naming.NamingException;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 @Component
 @Local(value = { ConfigurationManager.class, ConfigurationService.class })
 public class MockConfigurationManagerImpl extends ManagerBase implements ConfigurationManager, ConfigurationService {
@@ -344,15 +310,6 @@ public class MockConfigurationManagerImpl extends ManagerBase implements Configu
     }
 
     /* (non-Javadoc)
-     * @see com.cloud.configuration.ConfigurationService#getZone(long)
-     */
-    @Override
-    public DataCenter getZone(long id) {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
      * @see com.cloud.configuration.ConfigurationService#getServiceOffering(long)
      */
     @Override


Mime
View raw message