cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chirad...@apache.org
Subject [6/16] Network-refactor: Refactor NetworkManager into NetworkModel and NetworkManager. NetworkManager's exclusive focus is now - handling plugins during orchestration, and - to deal with ip address allocation. Those classes that used to refer to Networ
Date Wed, 09 Jan 2013 23:50:01 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/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 edd53e2..1d2db3e 100755
--- a/server/src/com/cloud/network/NetworkServiceImpl.java
+++ b/server/src/com/cloud/network/NetworkServiceImpl.java
@@ -226,6 +226,8 @@ public class NetworkServiceImpl implements  NetworkService, Manager {
     ResourceTagDao _resourceTagDao;
     @Inject
     NetworkManager _networkMgr;
+    @Inject
+    NetworkModel _networkModel;
 
     private final HashMap<String, NetworkOfferingVO> _systemNetworks = new HashMap<String, NetworkOfferingVO>(5);
 
@@ -364,7 +366,7 @@ public class NetworkServiceImpl implements  NetworkService, Manager {
 
     private boolean canIpsUseOffering(List<PublicIp> publicIps, long offeringId) {
         Map<PublicIp, Set<Service>> ipToServices = getIpToServices(publicIps, false, true);
-        Map<Service, Set<Provider>> serviceToProviders = _networkMgr.getNetworkOfferingServiceProvidersMap(offeringId);
+        Map<Service, Set<Provider>> serviceToProviders = _networkModel.getNetworkOfferingServiceProvidersMap(offeringId);
         for (PublicIp ip : ipToServices.keySet()) {
             Set<Service> services = ipToServices.get(ip);
             Provider provider = null;
@@ -1146,7 +1148,7 @@ public class NetworkServiceImpl implements  NetworkService, Manager {
         if (canUseForDeploy != null) {
             List<NetworkVO> networksForDeploy = new ArrayList<NetworkVO>();
             for (NetworkVO network : networksToReturn) {
-                if (_networkMgr.canUseForDeploy(network) == canUseForDeploy) {
+                if (_networkModel.canUseForDeploy(network) == canUseForDeploy) {
                     networksForDeploy.add(network);
                 }
             }
@@ -1429,7 +1431,7 @@ public class NetworkServiceImpl implements  NetworkService, Manager {
 
         // FIXME we return the capabilities of the first provider of the service - what if we have multiple providers
         // for same Service?
-        NetworkElement element = _networkMgr.getElementImplementingProvider(provider);
+        NetworkElement element = _networkModel.getElementImplementingProvider(provider);
         if (element != null) {
             Map<Service, Map<Capability, String>> elementCapabilities = element.getCapabilities();
             ;
@@ -2301,7 +2303,7 @@ public class NetworkServiceImpl implements  NetworkService, Manager {
         }
 
         if (provider != null) {
-            NetworkElement element = _networkMgr.getElementImplementingProvider(providerName);
+            NetworkElement element = _networkModel.getElementImplementingProvider(providerName);
             if (element == null) {
                 throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + providerName + "'");
             }
@@ -2348,7 +2350,7 @@ public class NetworkServiceImpl implements  NetworkService, Manager {
         }
 
         // check if services can be turned off
-        NetworkElement element = _networkMgr.getElementImplementingProvider(providerName);
+        NetworkElement element = _networkModel.getElementImplementingProvider(providerName);
         if (element == null) {
             throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + providerName + "'");
         }
@@ -2441,7 +2443,7 @@ public class NetworkServiceImpl implements  NetworkService, Manager {
             throw new InvalidParameterValueException("Network Service Provider id=" + id + "doesn't exist in the system");
         }
 
-        NetworkElement element = _networkMgr.getElementImplementingProvider(provider.getProviderName());
+        NetworkElement element = _networkModel.getElementImplementingProvider(provider.getProviderName());
         if (element == null) {
             throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + provider.getProviderName() + "'");
         }
@@ -2530,7 +2532,7 @@ public class NetworkServiceImpl implements  NetworkService, Manager {
         if (s_logger.isDebugEnabled()) {
             s_logger.debug("Shutting down the service provider id=" + id + " on physical network: " + provider.getPhysicalNetworkId());
         }
-        NetworkElement element = _networkMgr.getElementImplementingProvider(provider.getProviderName());
+        NetworkElement element = _networkModel.getElementImplementingProvider(provider.getProviderName());
         if (element == null) {
             throw new InvalidParameterValueException("Unable to find the Network Element implementing the Service Provider '" + provider.getProviderName() + "'");
         }
@@ -2788,7 +2790,7 @@ public class NetworkServiceImpl implements  NetworkService, Manager {
 
         PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, Network.Provider.VirtualRouter.getName(), null, null);
         // add instance of the provider
-        VirtualRouterElement element = (VirtualRouterElement) _networkMgr.getElementImplementingProvider(Network.Provider.VirtualRouter.getName());
+        VirtualRouterElement element = (VirtualRouterElement) _networkModel.getElementImplementingProvider(Network.Provider.VirtualRouter.getName());
         if (element == null) {
             throw new CloudRuntimeException("Unable to find the Network Element implementing the VirtualRouter Provider");
         }
@@ -2802,7 +2804,7 @@ public class NetworkServiceImpl implements  NetworkService, Manager {
         PhysicalNetworkServiceProvider nsp = addProviderToPhysicalNetwork(physicalNetworkId, 
                 Network.Provider.VPCVirtualRouter.getName(), null, null);
         // add instance of the provider
-        VpcVirtualRouterElement element = (VpcVirtualRouterElement) _networkMgr.getElementImplementingProvider(Network.Provider.VPCVirtualRouter.getName());
+        VpcVirtualRouterElement element = (VpcVirtualRouterElement) _networkModel.getElementImplementingProvider(Network.Provider.VPCVirtualRouter.getName());
         if (element == null) {
             throw new CloudRuntimeException("Unable to find the Network Element implementing the VPCVirtualRouter Provider");
         }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
index ae8be0d..6759726 100644
--- a/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
+++ b/server/src/com/cloud/network/element/CloudZonesNetworkElement.java
@@ -44,7 +44,7 @@ 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.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.dao.NetworkDao;
@@ -72,7 +72,7 @@ public class CloudZonesNetworkElement extends AdapterBase implements NetworkElem
     @Inject
     NetworkDao _networkConfigDao;
     @Inject
-    NetworkManager _networkMgr;
+    NetworkModel _networkMgr;
     @Inject
     UserVmManager _userVmMgr;
     @Inject

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/server/src/com/cloud/network/element/VirtualRouterElement.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/element/VirtualRouterElement.java b/server/src/com/cloud/network/element/VirtualRouterElement.java
index abd9a50..d35e358 100755
--- a/server/src/com/cloud/network/element/VirtualRouterElement.java
+++ b/server/src/com/cloud/network/element/VirtualRouterElement.java
@@ -43,7 +43,7 @@ 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.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.PhysicalNetworkServiceProvider;
 import com.cloud.network.PublicIpAddress;
@@ -102,7 +102,7 @@ public class VirtualRouterElement extends AdapterBase implements VirtualRouterEl
     @Inject
     NetworkDao _networksDao;
     @Inject
-    NetworkManager _networkMgr;
+    NetworkModel _networkMgr;
     @Inject
     LoadBalancingRulesManager _lbMgr;
     @Inject

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/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 8e781ec..60c5bf3 100644
--- a/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
+++ b/server/src/com/cloud/network/firewall/FirewallManagerImpl.java
@@ -46,6 +46,7 @@ import com.cloud.network.Network;
 import com.cloud.network.Network.Capability;
 import com.cloud.network.Network.Service;
 import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.NetworkRuleApplier;
 import com.cloud.network.dao.FirewallRulesCidrsDao;
 import com.cloud.network.dao.FirewallRulesDao;
@@ -112,6 +113,8 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ne
     @Inject
     NetworkManager _networkMgr;
     @Inject
+    NetworkModel _networkModel;
+    @Inject
     UsageEventDao _usageEventDao;
     @Inject
     ConfigurationDao _configDao;
@@ -186,7 +189,7 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ne
                     " doesn't exist in the system");
         }
 
-        _networkMgr.checkIpForService(ipAddress, Service.Firewall, null);  
+        _networkModel.checkIpForService(ipAddress, Service.Firewall, null);  
 
         validateFirewallRule(caller, ipAddress, portStart, portEnd, protocol, Purpose.Firewall, type);
 
@@ -421,7 +424,7 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ne
             networkId = ipAddress.getAssociatedWithNetworkId();
         }
 
-        Network network = _networkMgr.getNetwork(networkId);
+        Network network = _networkModel.getNetwork(networkId);
         assert network != null : "Can't create port forwarding rule as network associated with public ip address is null?";
 
         // Verify that the network guru supports the protocol specified
@@ -429,10 +432,10 @@ public class FirewallManagerImpl implements FirewallService, FirewallManager, Ne
 
         if (purpose == Purpose.LoadBalancing) {
             if (!_elbEnabled) {
-                caps = _networkMgr.getNetworkServiceCapabilities(network.getId(), Service.Lb);
+                caps = _networkModel.getNetworkServiceCapabilities(network.getId(), Service.Lb);
             }
         } else if (purpose == Purpose.PortForwarding) {
-            caps = _networkMgr.getNetworkServiceCapabilities(network.getId(), Service.PortForwarding);
+            caps = _networkModel.getNetworkServiceCapabilities(network.getId(), Service.PortForwarding);
         }
 
         if (caps != null) {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/server/src/com/cloud/network/guru/ControlNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/ControlNetworkGuru.java b/server/src/com/cloud/network/guru/ControlNetworkGuru.java
index 934cd70..ef80522 100755
--- a/server/src/com/cloud/network/guru/ControlNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/ControlNetworkGuru.java
@@ -35,7 +35,7 @@ import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.Network;
-import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.NetworkProfile;
 import com.cloud.network.NetworkVO;
 import com.cloud.network.Networks.AddressFormat;
@@ -58,7 +58,7 @@ import com.cloud.vm.VirtualMachineProfile;
 public class ControlNetworkGuru extends PodBasedNetworkGuru implements NetworkGuru {
     private static final Logger s_logger = Logger.getLogger(ControlNetworkGuru.class);
     @Inject DataCenterDao _dcDao;
-    @Inject NetworkManager _networkMgr;
+    @Inject NetworkModel _networkMgr;
     String _cidr;
     String _gateway;
     

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/server/src/com/cloud/network/guru/DirectNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/DirectNetworkGuru.java b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
index ee824af..b290c1d 100755
--- a/server/src/com/cloud/network/guru/DirectNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/DirectNetworkGuru.java
@@ -36,6 +36,7 @@ import com.cloud.network.Network.GuestType;
 import com.cloud.network.Network.Service;
 import com.cloud.network.Network.State;
 import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.NetworkProfile;
 import com.cloud.network.NetworkVO;
 import com.cloud.network.Networks.BroadcastDomainType;
@@ -64,6 +65,8 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
     @Inject
     VlanDao _vlanDao;
     @Inject
+    NetworkModel _networkModel;
+    @Inject
     NetworkManager _networkMgr;
     @Inject
     IPAddressDao _ipAddressDao;
@@ -132,7 +135,7 @@ public class DirectNetworkGuru extends AdapterBase implements NetworkGuru {
             }
         }
 
-        boolean isSecurityGroupEnabled = _networkMgr.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
+        boolean isSecurityGroupEnabled = _networkModel.areServicesSupportedByNetworkOffering(offering.getId(), Service.SecurityGroup);
         if (isSecurityGroupEnabled) {
             config.setName("SecurityGroupEnabledNetwork");
             config.setDisplayText("SecurityGroupEnabledNetwork");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
index 354d7ed..8ca4547 100755
--- a/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/DirectPodBasedNetworkGuru.java
@@ -109,7 +109,7 @@ public class DirectPodBasedNetworkGuru extends DirectNetworkGuru {
         }
         
         if (rsStrategy == ReservationStrategy.Create) {
-            String mac = _networkMgr.getNextAvailableMacAddressInNetwork(network.getId());
+            String mac = _networkModel.getNextAvailableMacAddressInNetwork(network.getId());
             nic.setMacAddress(mac);
         }
         return nic;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/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 24d24f8..f8a8a95 100644
--- a/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/ExternalGuestNetworkGuru.java
@@ -106,7 +106,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
         NetworkVO config = (NetworkVO) super.design(offering, plan, userSpecified, owner);
         if (config == null) {
             return null;
-        } else if (_networkMgr.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getId())) {
+        } else if (_networkModel.networkIsConfiguredForExternalNetworking(plan.getDataCenterId(), config.getId())) {
             /* In order to revert userSpecified network setup */
             config.setState(State.Allocated);
         }
@@ -122,7 +122,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
             return null;
         }
         
-        if (!_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
+        if (!_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
             return super.implement(config, offering, dest, context);
         }
 
@@ -195,7 +195,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
     public NicProfile allocate(Network config, NicProfile nic, VirtualMachineProfile<? extends VirtualMachine> vm) throws InsufficientVirtualNetworkCapcityException,
             InsufficientAddressCapacityException {
 
-        if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIp() != null) {
+        if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId()) && nic != null && nic.getRequestedIp() != null) {
             throw new CloudRuntimeException("Does not support custom ip allocation at this time: " + nic);
         }
         
@@ -206,7 +206,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
             return null;
         }
 
-        if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
+        if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
             profile.setStrategy(ReservationStrategy.Start);
             /* We won't clear IP address, because router may set gateway as it IP, and it would be updated properly later */
             //profile.setIp4Address(null);
@@ -225,7 +225,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
             return;
         }
         
-        if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
+        if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
             nic.setIp4Address(null);
             nic.setGateway(null);
             nic.setNetmask(null);
@@ -245,7 +245,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
         
         DataCenter dc = _dcDao.findById(config.getDataCenterId());
 
-        if (_networkMgr.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
+        if (_networkModel.networkIsConfiguredForExternalNetworking(config.getDataCenterId(), config.getId())) {
             nic.setBroadcastUri(config.getBroadcastUri());
             nic.setIsolationUri(config.getBroadcastUri());
             nic.setDns1(dc.getDns1());
@@ -280,7 +280,7 @@ public class ExternalGuestNetworkGuru extends GuestNetworkGuru {
 
         NetworkVO network = _networkDao.findById(nic.getNetworkId());
         
-        if (network != null && _networkMgr.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
+        if (network != null && _networkModel.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
             return true;
         } else {
             return super.release(nic, vm, reservationId);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/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 91b95f9..9587885 100755
--- a/server/src/com/cloud/network/guru/GuestNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/GuestNetworkGuru.java
@@ -45,6 +45,7 @@ import com.cloud.network.IPAddressVO;
 import com.cloud.network.Network;
 import com.cloud.network.Network.State;
 import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.NetworkProfile;
 import com.cloud.network.NetworkVO;
 import com.cloud.network.Networks.AddressFormat;
@@ -82,6 +83,8 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
     @Inject
     protected NetworkManager _networkMgr;
     @Inject
+    protected NetworkModel _networkModel;
+    @Inject
     protected DataCenterDao _dcDao;
     @Inject
     protected VlanDao _vlanDao;
@@ -310,7 +313,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
         long dcId = dest.getDataCenter().getId();
 
         //get physical network id
-        long physicalNetworkId = _networkMgr.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
+        long physicalNetworkId = _networkModel.findPhysicalNetworkId(dcId, offering.getTags(), offering.getTrafficType());
 
         NetworkVO implemented = new NetworkVO(network.getTrafficType(), network.getMode(), 
                 network.getBroadcastDomainType(), network.getNetworkOfferingId(), State.Allocated,
@@ -355,11 +358,11 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
                 boolean isGateway = false;
                 if (vm.getVirtualMachine().getType() == VirtualMachine.Type.DomainRouter) {
                     if (network.getVpcId() != null) {
-                        if (_networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VPCVirtualRouter)) {
+                        if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VPCVirtualRouter)) {
                             isGateway = true;
                         }
                     } else {
-                        if (_networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VirtualRouter)) {
+                        if (_networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.SourceNat, Provider.VirtualRouter)) {
                             isGateway = true;
                         }
                     }
@@ -387,7 +390,7 @@ public abstract class GuestNetworkGuru extends AdapterBase implements NetworkGur
         nic.setStrategy(ReservationStrategy.Start);
 
         if (nic.getMacAddress() == null) {
-            nic.setMacAddress(_networkMgr.getNextAvailableMacAddressInNetwork(network.getId()));
+            nic.setMacAddress(_networkModel.getNextAvailableMacAddressInNetwork(network.getId()));
             if (nic.getMacAddress() == null) {
                 throw new InsufficientAddressCapacityException("Unable to allocate more mac addresses", Network.class, network.getId());
             }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/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 9d4c9c3..b50e342 100644
--- a/server/src/com/cloud/network/guru/PrivateNetworkGuru.java
+++ b/server/src/com/cloud/network/guru/PrivateNetworkGuru.java
@@ -31,7 +31,7 @@ import com.cloud.exception.InvalidParameterValueException;
 import com.cloud.network.Network;
 import com.cloud.network.Network.GuestType;
 import com.cloud.network.Network.State;
-import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.NetworkProfile;
 import com.cloud.network.NetworkVO;
 import com.cloud.network.Networks.AddressFormat;
@@ -62,7 +62,7 @@ public class PrivateNetworkGuru extends AdapterBase implements NetworkGuru {
     @Inject
     protected PrivateIpDao _privateIpDao;
     @Inject
-    protected NetworkManager _networkMgr;
+    protected NetworkModel _networkMgr;
     
     private static final TrafficType[] _trafficTypes = {TrafficType.Guest};
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/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 aa89474..7bb2a25 100755
--- a/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
+++ b/server/src/com/cloud/network/lb/LoadBalancingRulesManagerImpl.java
@@ -68,6 +68,7 @@ import com.cloud.network.Network.Capability;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
 import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.NetworkRuleApplier;
 import com.cloud.network.NetworkVO;
 import com.cloud.network.as.AutoScalePolicy;
@@ -157,6 +158,8 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
     @Inject
     NetworkManager _networkMgr;
     @Inject
+    NetworkModel _networkModel;
+    @Inject
     RulesManager _rulesMgr;
     @Inject
     AccountManager _accountMgr;
@@ -234,7 +237,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
     // Will return a string. For LB Stickiness this will be a json, for autoscale this will be "," separated values
     @Override
     public String getLBCapability(long networkid, String capabilityName) {
-        Map<Service, Map<Capability, String>> serviceCapabilitiesMap = _networkMgr.getNetworkCapabilities(networkid);
+        Map<Service, Map<Capability, String>> serviceCapabilitiesMap = _networkModel.getNetworkCapabilities(networkid);
         if (serviceCapabilitiesMap != null) {
             for (Service service : serviceCapabilitiesMap.keySet()) {
                 ServiceResponse serviceResponse = new ServiceResponse();
@@ -486,7 +489,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
         List<LbStickinessPolicy> policyList = new ArrayList<LbStickinessPolicy>();
         policyList.add(new LbStickinessPolicy(cmd.getStickinessMethodName(), lbpolicy.getParams()));
         LoadBalancingRule lbRule = new LoadBalancingRule(loadBalancer, getExistingDestinations(lbpolicy.getId()), policyList);
-        if (!_networkMgr.validateRule(lbRule)) {
+        if (!_networkModel.validateRule(lbRule)) {
             throw new InvalidParameterValueException("Failed to create Stickiness policy: Validation Failed " + cmd.getLbRuleId());
         }
 
@@ -624,7 +627,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
             }
 
             // Let's check to make sure the vm has a nic in the same network as the load balancing rule.
-            List<? extends Nic> nics = _networkMgr.getNics(vm.getId());
+            List<? extends Nic> nics = _networkModel.getNics(vm.getId());
             Nic nicInSameNetwork = null;
             for (Nic nic : nics) {
                 if (nic.getNetworkId() == loadBalancer.getNetworkId()) {
@@ -858,7 +861,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
         // gather external network usage stats for this lb rule
         NetworkVO network = _networkDao.findById(lb.getNetworkId());
         if (network != null) {
-            if (_networkMgr.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
+            if (_networkModel.networkIsConfiguredForExternalNetworking(network.getDataCenterId(), network.getId())) {
                 _externalLBUsageMgr.updateExternalLoadBalancerNetworkUsageStats(loadBalancerId);
             }
         }
@@ -939,7 +942,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
             ipVO = _ipAddressDao.findById(ipAddrId);
         }
         
-        Network network = _networkMgr.getNetwork(lb.getNetworkId());
+        Network network = _networkModel.getNetwork(lb.getNetworkId());
 
         // FIXME: breaking the dependency on ELB manager. This breaks functionality of ELB using virtual router
         // Bug CS-15411 opened to document this
@@ -968,14 +971,14 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
                     && ipVO.getVpcId() != null && ipVO.getVpcId().longValue() == network.getVpcId();
                     if (assignToVpcNtwk) {
                         //set networkId just for verification purposes
-                        _networkMgr.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
+                        _networkModel.checkIpForService(ipVO, Service.Lb, lb.getNetworkId());
 
                         s_logger.debug("The ip is not associated with the VPC network id="+ lb.getNetworkId() + " so assigning");
                         ipVO = _networkMgr.associateIPToGuestNetwork(ipAddrId, lb.getNetworkId(), false);
                         performedIpAssoc = true;
                     }
                 } else {
-                    _networkMgr.checkIpForService(ipVO, Service.Lb, null);
+                    _networkModel.checkIpForService(ipVO, Service.Lb, null);
                 }
                 
                 if (ipVO.getAssociatedWithNetworkId() == null) { 
@@ -1047,7 +1050,7 @@ public class LoadBalancingRulesManagerImpl<Type> implements LoadBalancingRulesMa
         _accountMgr.checkAccess(caller.getCaller(), null, true, ipAddr);
 
         // verify that lb service is supported by the network
-        if (!_networkMgr.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
+        if (!_networkModel.areServicesSupportedInNetwork(network.getId(), Service.Lb)) {
             InvalidParameterValueException ex = new InvalidParameterValueException("LB service is not supported in specified network id");
             ex.addProxyObject(network, networkId, "networkId");
             throw ex;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/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 966c32d..1570d1a 100755
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -130,6 +130,7 @@ import com.cloud.network.Network.GuestType;
 import com.cloud.network.Network.Provider;
 import com.cloud.network.Network.Service;
 import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.NetworkVO;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.IsolationType;
@@ -290,6 +291,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
     @Inject
     NetworkManager _networkMgr;
     @Inject
+    NetworkModel _networkModel;
+    @Inject
     VirtualMachineManager _itMgr;
     @Inject
     VpnUserDao _vpnUsersDao;
@@ -805,7 +808,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
                     if (privateIP != null) {
                         List<? extends Nic> routerNics = _nicDao.listByVmId(router.getId());
                         for (Nic routerNic : routerNics) {
-                            Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
+                            Network network = _networkModel.getNetwork(routerNic.getNetworkId());
                             if (network.getTrafficType() == TrafficType.Public) {
                                 boolean forVpc = router.getVpcId() != null;
                                 final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName(),
@@ -1320,7 +1323,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         
             // 1) Get deployment plan and find out the list of routers
             boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic ||
-                    _networkMgr.areServicesSupportedInNetwork(guestNetwork.getId(), Service.SecurityGroup))
+                    _networkModel.areServicesSupportedInNetwork(guestNetwork.getId(), Service.SecurityGroup))
                     && guestNetwork.getTrafficType() == TrafficType.Guest;
 
             // dest has pod=null, for Basic Zone findOrDeployVRs for all Pods
@@ -1380,7 +1383,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
 
                 // Check if providers are supported in the physical networks
                 VirtualRouterProviderType type = VirtualRouterProviderType.VirtualRouter;
-                Long physicalNetworkId = _networkMgr.getPhysicalNetworkId(guestNetwork);
+                Long physicalNetworkId = _networkModel.getPhysicalNetworkId(guestNetwork);
                 PhysicalNetworkServiceProvider provider = _physicalProviderDao.findByServiceProvider(physicalNetworkId, type.toString());
                 if (provider == null) {
                     throw new CloudRuntimeException("Cannot find service provider " + type.toString() + " in physical network " + physicalNetworkId);
@@ -1390,13 +1393,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
                     throw new CloudRuntimeException("Cannot find virtual router provider " + type.toString() + " as service provider " + provider.getId());
                 }
 
-                if (_networkMgr.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
+                if (_networkModel.isNetworkSystem(guestNetwork) || guestNetwork.getGuestType() == Network.GuestType.Shared) {
                     owner = _accountMgr.getAccount(Account.ACCOUNT_ID_SYSTEM);
                 }
 
                 // Check if public network has to be set on VR
                 boolean publicNetwork = false;
-                if (_networkMgr.isProviderSupportServiceInNetwork(guestNetwork.getId(), Service.SourceNat, Provider.VirtualRouter)) {
+                if (_networkModel.isProviderSupportServiceInNetwork(guestNetwork.getId(), Service.SourceNat, Provider.VirtualRouter)) {
                     publicNetwork = true;
                 }
                 if (isRedundant && !publicNetwork) {
@@ -1598,7 +1601,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
             s_logger.debug("Adding nic for Virtual Router in Guest network " + guestNetwork);
             String defaultNetworkStartIp = null;
             if (guestNetwork.getCidr() != null && !setupPublicNetwork) {
-                String startIp = _networkMgr.getStartIpAddress(guestNetwork.getId());
+                String startIp = _networkModel.getStartIpAddress(guestNetwork.getId());
                 if (startIp != null && _ipAddressDao.findByIpAndSourceNetworkId(guestNetwork.getId(), startIp).getAllocatedTime() == null) {
                     defaultNetworkStartIp = startIp;
                 } else if (s_logger.isDebugEnabled()){
@@ -1630,7 +1633,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
 
         //2) Control network
         s_logger.debug("Adding nic for Virtual Router in Control network ");
-        List<NetworkOfferingVO> offerings = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
+        List<NetworkOfferingVO> offerings = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemControlNetwork);
         NetworkOfferingVO controlOffering = offerings.get(0);
         NetworkVO controlConfig = _networkMgr.setupNetwork(_systemAcct, controlOffering, plan, null, null, false).get(0);
         networks.add(new Pair<NetworkVO, NicProfile>(controlConfig, null));
@@ -1653,7 +1656,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
             if (hasGuestNetwork) {
                 defaultNic.setDeviceId(2);
             }
-            NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
+            NetworkOfferingVO publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
             List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
             networks.add(new Pair<NetworkVO, NicProfile>(publicNetworks.get(0), defaultNic));
         }
@@ -1871,8 +1874,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
 
                 }
             }  else if (nic.getTrafficType() == TrafficType.Guest) {
-                dnsProvided = _networkMgr.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dns, Provider.VirtualRouter);
-                dhcpProvided = _networkMgr.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dhcp, Provider.VirtualRouter);
+                dnsProvided = _networkModel.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dns, Provider.VirtualRouter);
+                dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(nic.getNetworkId(), Service.Dhcp, Provider.VirtualRouter);
                 //build bootloader parameter for the guest
                 buf.append(createGuestBootLoadArgs(nic, defaultDns1, defaultDns2, router));
             } else if (nic.getTrafficType() == TrafficType.Public) {
@@ -1973,7 +1976,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
                 s_logger.error("Failed to get update priority!", e);
                 throw new CloudRuntimeException("Failed to get update priority!");
             }
-            Network net = _networkMgr.getNetwork(guestNic.getNetworkId());
+            Network net = _networkModel.getNetwork(guestNic.getNetworkId());
             buf.append(" guestgw=").append(net.getGateway());
             String brd = NetUtils.long2Ip(NetUtils.ip2Long(guestNic.getIp4Address()) | ~NetUtils.ip2Long(guestNic.getNetmask()));
             buf.append(" guestbrd=").append(brd);
@@ -2129,13 +2132,13 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
     }
 
     protected void finalizeUserDataAndDhcpOnStart(Commands cmds, DomainRouterVO router, Provider provider, Long guestNetworkId) {
-        if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Dhcp, provider)) {
+        if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Dhcp, provider)) {
             // Resend dhcp
             s_logger.debug("Reapplying dhcp entries as a part of domR " + router + " start...");
             createDhcpEntryCommandsForVMs(router, cmds, guestNetworkId);
         }
    
-        if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.UserData, provider)) {
+        if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.UserData, provider)) {
             // Resend user data
             s_logger.debug("Reapplying vm data (userData and metaData) entries as a part of domR " + router + " start...");
             createVmDataCommandForVMs(router, cmds, guestNetworkId);
@@ -2156,26 +2159,26 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
       
             //Get information about all the rules (StaticNats and StaticNatRules; PFVPN to reapply on domR start)
             for (PublicIpAddress ip : publicIps) {
-                if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.PortForwarding, provider)) {
+                if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.PortForwarding, provider)) {
                     pfRules.addAll(_pfRulesDao.listForApplication(ip.getId()));
                 }
-                if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
+                if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
                     staticNatFirewallRules.addAll(_rulesDao.listByIpAndPurpose(ip.getId(), Purpose.StaticNat));
                 }
-                if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
+                if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
                     firewallRules.addAll(_rulesDao.listByIpAndPurpose(ip.getId(), Purpose.Firewall));
                 }
       
-                if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Vpn, provider)) {
+                if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Vpn, provider)) {
                     RemoteAccessVpn vpn = _vpnDao.findById(ip.getId());
                     if (vpn != null) {
                         vpns.add(vpn);
                     }
                 }
       
-                if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
+                if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.StaticNat, provider)) {
                     if (ip.isOneToOneNat()) {
-                            String dstIp = _networkMgr.getIpInNetwork(ip.getAssociatedWithVmId(), guestNetworkId);
+                            String dstIp = _networkModel.getIpInNetwork(ip.getAssociatedWithVmId(), guestNetworkId);
                             StaticNatImpl staticNat = new StaticNatImpl(ip.getAccountId(), ip.getDomainId(), guestNetworkId, ip.getId(), dstIp, false);
                         staticNats.add(staticNat);
                     }
@@ -2220,7 +2223,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
    
             List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkId(guestNetworkId);
             List<LoadBalancingRule> lbRules = new ArrayList<LoadBalancingRule>();
-            if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Lb, provider)) {
+            if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Lb, provider)) {
                 // Re-apply load balancing rules
                 for (LoadBalancerVO lb : lbs) {
                     List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
@@ -2245,7 +2248,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         if (publicIps != null && !publicIps.isEmpty()) {
             s_logger.debug("Found " + publicIps.size() + " ip(s) to apply as a part of domR " + router + " start.");
             // Re-apply public ip addresses - should come before PF/LB/VPN
-            if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
+            if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.Firewall, provider)) {
                 createAssociateIPCommands(router, publicIps, cmds, 0);
             }
         }
@@ -2254,7 +2257,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
     protected ArrayList<? extends PublicIpAddress> getPublicIpsToApply(VirtualRouter router, Provider provider, 
             Long guestNetworkId, com.cloud.network.IpAddress.State... skipInStates) {
         long ownerId = router.getAccountId();
-        final List<IPAddressVO> userIps = _networkMgr.listPublicIpsAssignedToGuestNtwk(ownerId, guestNetworkId, null);
+        final List<IPAddressVO> userIps = _networkModel.listPublicIpsAssignedToGuestNtwk(ownerId, guestNetworkId, null);
         List<PublicIp> allPublicIps = new ArrayList<PublicIp>();
         if (userIps != null && !userIps.isEmpty()) {
             boolean addIp = true;
@@ -2279,8 +2282,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         
         //Get public Ips that should be handled by router
         Network network = _networkDao.findById(guestNetworkId);
-        Map<PublicIp, Set<Service>> ipToServices = _networkMgr.getIpToServices(allPublicIps, false, true);
-        Map<Provider, ArrayList<PublicIp>> providerToIpList = _networkMgr.getProviderToIpList(network, ipToServices);
+        Map<PublicIp, Set<Service>> ipToServices = _networkModel.getIpToServices(allPublicIps, false, true);
+        Map<Provider, ArrayList<PublicIp>> providerToIpList = _networkModel.getProviderToIpList(network, ipToServices);
         // Only cover virtual router for now, if ELB use it this need to be modified
       
         ArrayList<PublicIp> publicIps = providerToIpList.get(provider);
@@ -2313,7 +2316,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         
         List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
         for (Nic routerNic : routerNics) {
-            Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
+            Network network = _networkModel.getNetwork(routerNic.getNetworkId());
             if (network.getTrafficType() == TrafficType.Guest) {
                 guestNetworks.add(network);
             } 
@@ -2413,7 +2416,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         for (VirtualRouter router : routers) {
             if (router.getState() == State.Running) {
                 Commands cmds = new Commands(OnError.Continue);
-                IpAddress ip = _networkMgr.getIp(vpn.getServerAddressId());
+                IpAddress ip = _networkModel.getIp(vpn.getServerAddressId());
 
                 RemoteAccessVpnCfgCommand removeVpnCmd = new RemoteAccessVpnCfgCommand(false, ip.getAddress().addr(), 
                         vpn.getLocalIp(), vpn.getIpRange(), vpn.getIpsecPresharedKey());
@@ -2513,7 +2516,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         NicVO defaultNic = _nicDao.findDefaultNicForVM(userVmId);
         
         //check if DNS provider is the domR
-        if (!_networkMgr.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) {
+        if (!_networkModel.isProviderSupportServiceInNetwork(defaultNic.getNetworkId(), Service.Dns, Provider.VirtualRouter)) {
             return null;
         }
         
@@ -2522,7 +2525,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
             return findGatewayIp(userVmId);
         }
         
-        DataCenter dc = _dcDao.findById(_networkMgr.getNetwork(defaultNic.getNetworkId()).getDataCenterId());
+        DataCenter dc = _dcDao.findById(_networkModel.getNetwork(defaultNic.getNetworkId()).getDataCenterId());
         boolean isZoneBasic = (dc.getNetworkType() == NetworkType.Basic);
         
         //find domR's nic in the network
@@ -2741,8 +2744,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
             });
 
             // Get network rate - required for IpAssoc
-            Integer networkRate = _networkMgr.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
-            Network network = _networkMgr.getNetwork(ipAddrList.get(0).getNetworkId());
+            Integer networkRate = _networkModel.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
+            Network network = _networkModel.getNetwork(ipAddrList.get(0).getNetworkId());
 
             IpAddressTO[] ipsToSend = new IpAddressTO[ipAddrList.size()];
             int i = 0;
@@ -2765,7 +2768,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
                         sourceNat, vlanId, vlanGateway, vlanNetmask, vifMacAddress, networkRate, ipAddr.isOneToOneNat());
 
                 ip.setTrafficType(network.getTrafficType());
-                ip.setNetworkName(_networkMgr.getNetworkTag(router.getHypervisorType(), network));
+                ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
                 ipsToSend[i++] = ip;
                 /* send the firstIP = true for the first Add, this is to create primary on interface*/
                 if (!firstIP || add)  {
@@ -2788,7 +2791,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         if (rules != null) {
             rulesTO = new ArrayList<PortForwardingRuleTO>();
             for (PortForwardingRule rule : rules) {
-                IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
+                IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
                 PortForwardingRuleTO ruleTO = new PortForwardingRuleTO(rule, null, sourceIp.getAddress().addr());
                 rulesTO.add(ruleTO);
             }
@@ -2816,7 +2819,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         if (rules != null) {
             rulesTO = new ArrayList<StaticNatRuleTO>();
             for (StaticNatRule rule : rules) {
-                IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
+                IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
                 StaticNatRuleTO ruleTO = new StaticNatRuleTO(rule, null, sourceIp.getAddress().addr(), rule.getDestIpAddress());
                 rulesTO.add(ruleTO);
             }
@@ -2841,7 +2844,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
             String algorithm = rule.getAlgorithm();
             String uuid = rule.getUuid();
 
-            String srcIp = _networkMgr.getIp(rule.getSourceIpAddressId()).getAddress().addr();
+            String srcIp = _networkModel.getIp(rule.getSourceIpAddressId()).getAddress().addr();
             int srcPort = rule.getSourcePortStart();
             List<LbDestination> destinations = rule.getDestinations();
             List<LbStickinessPolicy> stickinessPolicies = rule.getStickinessPolicies();
@@ -2855,12 +2858,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
             routerPublicIp = domr.getPublicIpAddress();
         }
         
-        Network guestNetwork = _networkMgr.getNetwork(guestNetworkId);
+        Network guestNetwork = _networkModel.getNetwork(guestNetworkId);
         Nic nic = _nicDao.findByInstanceIdAndNetworkId(guestNetwork.getId(), router.getId());
         NicProfile nicProfile = new NicProfile(nic, guestNetwork, nic.getBroadcastUri(), nic.getIsolationUri(), 
-                _networkMgr.getNetworkRate(guestNetwork.getId(), router.getId()), 
-                _networkMgr.isSecurityGroupSupportedInNetwork(guestNetwork), 
-                _networkMgr.getNetworkTag(router.getHypervisorType(), guestNetwork));
+                _networkModel.getNetworkRate(guestNetwork.getId(), router.getId()), 
+                _networkModel.isSecurityGroupSupportedInNetwork(guestNetwork), 
+                _networkModel.getNetworkTag(router.getHypervisorType(), guestNetwork));
 
         LoadBalancerConfigCommand cmd = new LoadBalancerConfigCommand(lbs,routerPublicIp, 
                 getRouterIpInNetwork(guestNetworkId, router.getId()),router.getPrivateIpAddress(), 
@@ -2898,7 +2901,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         addUsersCmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, getRouterIpInNetwork(vpn.getNetworkId(), router.getId()));
         addUsersCmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
 
-        IpAddress ip = _networkMgr.getIp(vpn.getServerAddressId());
+        IpAddress ip = _networkModel.getIp(vpn.getServerAddressId());
 
         RemoteAccessVpnCfgCommand startVpnCmd = new RemoteAccessVpnCfgCommand(true, ip.getAddress().addr(), 
                 vpn.getLocalIp(), vpn.getIpRange(), vpn.getIpsecPresharedKey());
@@ -3173,7 +3176,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         if (rules != null) {
             rulesTO = new ArrayList<FirewallRuleTO>();
             for (FirewallRule rule : rules) {
-                IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
+                IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
                 FirewallRuleTO ruleTO = new FirewallRuleTO(rule, null, sourceIp.getAddress().addr());
                 rulesTO.add(ruleTO);
             }
@@ -3317,7 +3320,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         if (rules != null) {
             rulesTO = new ArrayList<StaticNatRuleTO>();
             for (StaticNat rule : rules) {
-                IpAddress sourceIp = _networkMgr.getIp(rule.getSourceIpAddressId());
+                IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
                 StaticNatRuleTO ruleTO = new StaticNatRuleTO(0, sourceIp.getAddress().addr(), null, 
                         null, rule.getDestIpAddress(), null, null, null, rule.isForRevoke(), false);
                 rulesTO.add(ruleTO);
@@ -3450,7 +3453,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
         if (privateIP != null) {
             List<? extends Nic> routerNics = _nicDao.listByVmId(router.getId());
             for (Nic routerNic : routerNics) {
-                Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
+                Network network = _networkModel.getNetwork(routerNic.getNetworkId());
                 if (network.getTrafficType() == TrafficType.Public) {
                     boolean forVpc = router.getVpcId() != null;
                     final NetworkUsageCommand usageCmd = new NetworkUsageCommand(privateIP, router.getHostName(),

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/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 1fd710d..12af4ba 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -287,12 +287,12 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         }
         
         //Check if router is a part of the Guest network
-        if (!_networkMgr.isVmPartOfNetwork(router.getId(), network.getId())) {
+        if (!_networkModel.isVmPartOfNetwork(router.getId(), network.getId())) {
             s_logger.debug("Router " + router + " is not a part of the Guest network " + network);
             return true;
         }
         
-        boolean result = setupVpcGuestNetwork(network, router, false, _networkMgr.getNicProfile(router, network.getId(), null));
+        boolean result = setupVpcGuestNetwork(network, router, false, _networkModel.getNicProfile(router, network.getId(), null));
         if (!result) {
             s_logger.warn("Failed to destroy guest network config " + network + " on router " + router);
             return false;
@@ -421,13 +421,13 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     }
 
     protected SetupGuestNetworkCommand createSetupGuestNetworkCommand(VirtualRouter router, boolean add, NicProfile guestNic) {
-        Network network = _networkMgr.getNetwork(guestNic.getNetworkId());
+        Network network = _networkModel.getNetwork(guestNic.getNetworkId());
         
         String defaultDns1 = null;
         String defaultDns2 = null;
         
-        boolean dnsProvided = _networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter);
-        boolean dhcpProvided = _networkMgr.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, 
+        boolean dnsProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dns, Provider.VPCVirtualRouter);
+        boolean dhcpProvided = _networkModel.isProviderSupportServiceInNetwork(network.getId(), Service.Dhcp, 
                 Provider.VPCVirtualRouter);
         
         boolean setupDns = dnsProvided || dhcpProvided;
@@ -441,7 +441,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         String networkDomain = network.getNetworkDomain();
         String dhcpRange = getGuestDhcpRange(guestNic, network, _configMgr.getZone(network.getDataCenterId()));
         
-        NicProfile nicProfile = _networkMgr.getNicProfile(router, nic.getNetworkId(), null);
+        NicProfile nicProfile = _networkModel.getNicProfile(router, nic.getNetworkId(), null);
 
         SetupGuestNetworkCommand setupCmd = new SetupGuestNetworkCommand(dhcpRange, networkDomain, false, null, 
                 defaultDns1, defaultDns2, add, _itMgr.toNicTO(nicProfile, router.getHypervisorType()));
@@ -482,8 +482,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             List<PublicIpAddress> ipAddrList = vlanAndIp.getValue();
 
             // Get network rate - required for IpAssoc
-            Integer networkRate = _networkMgr.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
-            Network network = _networkMgr.getNetwork(ipAddrList.get(0).getNetworkId());
+            Integer networkRate = _networkModel.getNetworkRate(ipAddrList.get(0).getNetworkId(), router.getId());
+            Network network = _networkModel.getNetwork(ipAddrList.get(0).getNetworkId());
 
             IpAddressTO[] ipsToSend = new IpAddressTO[ipAddrList.size()];
             int i = 0;
@@ -498,7 +498,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                         networkRate, ipAddr.isOneToOneNat());
 
                 ip.setTrafficType(network.getTrafficType());
-                ip.setNetworkName(_networkMgr.getNetworkTag(router.getHypervisorType(), network));
+                ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
                 ipsToSend[i++] = ip;
                 if (ipAddr.isSourceNat()) {
                     sourceNatIpAdd = new Pair<IpAddressTO, Long>(ip, ipAddr.getNetworkId());
@@ -528,7 +528,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     }
 
     protected NicTO getNicTO(final VirtualRouter router, Long networkId, String broadcastUri) {
-        NicProfile nicProfile = _networkMgr.getNicProfile(router, networkId, broadcastUri);
+        NicProfile nicProfile = _networkModel.getNicProfile(router, networkId, broadcastUri);
         
         return _itMgr.toNicTO(nicProfile, router.getHypervisorType());
     }
@@ -557,7 +557,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         for (String vlanTag : nicsToUnplug.keySet()) {
             Network publicNtwk = null;
             try {
-                publicNtwk = _networkMgr.getNetwork(nicsToUnplug.get(vlanTag).getNetworkId());
+                publicNtwk = _networkModel.getNetwork(nicsToUnplug.get(vlanTag).getNetworkId());
                 URI broadcastUri = BroadcastDomainType.Vlan.toUri(vlanTag);
                 _itMgr.removeVmFromNetwork(router, publicNtwk, broadcastUri);
             } catch (ConcurrentOperationException e) {
@@ -589,7 +589,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             NicProfile publicNic = null;
             Network publicNtwk = null;
             try {
-                publicNtwk = _networkMgr.getNetwork(ip.getNetworkId());
+                publicNtwk = _networkModel.getNetwork(ip.getNetworkId());
                 publicNic = _itMgr.addVmToNetwork(router, publicNtwk, defaultNic);
             } catch (ConcurrentOperationException e) {
                 s_logger.warn("Failed to add router " + router + " to vlan " + vlanTag + 
@@ -772,7 +772,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         
         List<? extends Nic> routerNics = _nicDao.listByVmId(profile.getId());
         for (Nic routerNic : routerNics) {
-            Network network = _networkMgr.getNetwork(routerNic.getNetworkId());
+            Network network = _networkModel.getNetwork(routerNic.getNetworkId());
             if (network.getTrafficType() == TrafficType.Guest) {
                 Pair<Nic, Network> guestNic = new Pair<Nic, Network>(routerNic, network);
                 guestNics.add(guestNic);
@@ -835,10 +835,10 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                 PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, guestNic.getNetworkId(), null), router.getInstanceName());
                 cmds.addCommand(plugNicCmd);
                 
-                if (!_networkMgr.isPrivateGateway(guestNic)) {
+                if (!_networkModel.isPrivateGateway(guestNic)) {
                     //set guest network
                     VirtualMachine vm = _vmDao.findById(router.getId());
-                    NicProfile nicProfile = _networkMgr.getNicProfile(vm, guestNic.getNetworkId(), null);
+                    NicProfile nicProfile = _networkModel.getNicProfile(vm, guestNic.getNetworkId(), null);
                     SetupGuestNetworkCommand setupCmd = createSetupGuestNetworkCommand(router, true, nicProfile);
                     cmds.addCommand(setupCmd);
                 } else {
@@ -918,7 +918,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         super.finalizeNetworkRulesForNetwork(cmds, router, provider, guestNetworkId);
         
         if (router.getVpcId() != null) {
-            if (_networkMgr.isProviderSupportServiceInNetwork(guestNetworkId, Service.NetworkACL, Provider.VPCVirtualRouter)) {
+            if (_networkModel.isProviderSupportServiceInNetwork(guestNetworkId, Service.NetworkACL, Provider.VPCVirtualRouter)) {
                 List<? extends FirewallRule> networkACLs = _networkACLMgr.listNetworkACLs(guestNetworkId);
                 s_logger.debug("Found " + networkACLs.size() + " network ACLs to apply as a part of VPC VR " + router 
                         + " start for guest network id=" + guestNetworkId);
@@ -933,7 +933,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     public boolean setupPrivateGateway(PrivateGateway gateway, VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
         boolean result = true;
         try {
-            Network network = _networkMgr.getNetwork(gateway.getNetworkId());
+            Network network = _networkModel.getNetwork(gateway.getNetworkId());
             NicProfile requested = createPrivateNicProfileForGateway(gateway);
             
             NicProfile guestNic = _itMgr.addVmToNetwork(router, network, requested);
@@ -1006,15 +1006,15 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     public boolean destroyPrivateGateway(PrivateGateway gateway, VirtualRouter router) 
             throws ConcurrentOperationException, ResourceUnavailableException {
         
-        if (!_networkMgr.isVmPartOfNetwork(router.getId(), gateway.getNetworkId())) {
+        if (!_networkModel.isVmPartOfNetwork(router.getId(), gateway.getNetworkId())) {
             s_logger.debug("Router doesn't have nic for gateway " + gateway + " so no need to removed it");
             return true;
         }
         
-        Network privateNetwork = _networkMgr.getNetwork(gateway.getNetworkId());
+        Network privateNetwork = _networkModel.getNetwork(gateway.getNetworkId());
         
         s_logger.debug("Releasing private ip for gateway " + gateway + " from " + router);
-        boolean result = setupVpcPrivateNetwork(router, false, _networkMgr.getNicProfile(router, privateNetwork.getId(), null));
+        boolean result = setupVpcPrivateNetwork(router, false, _networkModel.getNicProfile(router, privateNetwork.getId(), null));
         if (!result) {
             s_logger.warn("Failed to release private ip for gateway " + gateway + " on router " + router);
             return false;
@@ -1167,13 +1167,13 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
             int i = 0;
 
             for (final PrivateIpAddress ipAddr : ipAddrList) {
-                Network network = _networkMgr.getNetwork(ipAddr.getNetworkId());
+                Network network = _networkModel.getNetwork(ipAddr.getNetworkId());
                 IpAddressTO ip = new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(), add, false, 
                         false, ipAddr.getVlanTag(), ipAddr.getGateway(), ipAddr.getNetmask(), ipAddr.getMacAddress(),
                         null, false);
 
                 ip.setTrafficType(network.getTrafficType());
-                ip.setNetworkName(_networkMgr.getNetworkTag(router.getHypervisorType(), network));
+                ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
                 ipsToSend[i++] = ip;
                 
             }
@@ -1205,7 +1205,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         VpcGateway privateGateway = _vpcMgr.getPrivateGatewayForVpc(vpcId);
         if (privateGateway != null) {
             NicProfile privateNic = createPrivateNicProfileForGateway(privateGateway);
-            Network privateNetwork = _networkMgr.getNetwork(privateGateway.getNetworkId());
+            Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
             networks.add(new Pair<NetworkVO, NicProfile>((NetworkVO) privateNetwork, privateNic));
         }
         
@@ -1235,7 +1235,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
                 publicNic.setBroadcastType(BroadcastDomainType.Vlan);
                 publicNic.setBroadcastUri(BroadcastDomainType.Vlan.toUri(publicIp.getVlanTag()));
                 publicNic.setIsolationUri(IsolationType.Vlan.toUri(publicIp.getVlanTag()));
-                NetworkOfferingVO publicOffering = _networkMgr.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
+                NetworkOfferingVO publicOffering = _networkModel.getSystemAccountNetworkOfferings(NetworkOfferingVO.SystemPublicNetwork).get(0);
                 List<NetworkVO> publicNetworks = _networkMgr.setupNetwork(_systemAcct, publicOffering, plan, null, null, false);
                 networks.add(new Pair<NetworkVO, NicProfile>(publicNetworks.get(0), publicNic));
                 publicVlans.add(publicIp.getVlanTag());
@@ -1247,7 +1247,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
 
     @DB
     protected NicProfile createPrivateNicProfileForGateway(VpcGateway privateGateway) {
-        Network privateNetwork = _networkMgr.getNetwork(privateGateway.getNetworkId());
+        Network privateNetwork = _networkModel.getNetwork(privateGateway.getNetworkId());
         PrivateIpVO ipVO = _privateIpDao.allocateIpAddress(privateNetwork.getDataCenterId(), privateNetwork.getId(), privateGateway.getIp4Address());
         Nic privateNic = _nicDao.findByIp4AddressAndNetworkId(ipVO.getIpAddress(), privateNetwork.getId());
         
@@ -1256,9 +1256,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
         if (privateNic != null) {
             VirtualMachine vm = _vmDao.findById(privateNic.getId());
             privateNicProfile = new NicProfile(privateNic, privateNetwork, privateNic.getBroadcastUri(), privateNic.getIsolationUri(), 
-                    _networkMgr.getNetworkRate(privateNetwork.getId(), vm.getId()), 
-                    _networkMgr.isSecurityGroupSupportedInNetwork(privateNetwork), 
-                    _networkMgr.getNetworkTag(vm.getHypervisorType(), privateNetwork));
+                    _networkModel.getNetworkRate(privateNetwork.getId(), vm.getId()), 
+                    _networkModel.isSecurityGroupSupportedInNetwork(privateNetwork), 
+                    _networkModel.getNetworkTag(vm.getHypervisorType(), privateNetwork));
         } else {
             String vlanTag = privateNetwork.getBroadcastUri().getHost();
             String netmask = NetUtils.getCidrNetmask(privateNetwork.getCidr());

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/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 02d186d..1548afe 100755
--- a/server/src/com/cloud/network/rules/RulesManagerImpl.java
+++ b/server/src/com/cloud/network/rules/RulesManagerImpl.java
@@ -33,6 +33,7 @@ import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
 import com.cloud.network.Network.Service;
 import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.dao.FirewallRulesCidrsDao;
 import com.cloud.network.dao.FirewallRulesDao;
 import com.cloud.network.dao.IPAddressDao;
@@ -90,6 +91,8 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
     @Inject
     NetworkManager _networkMgr;
     @Inject
+    NetworkModel _networkModel;
+    @Inject
     EventDao _eventDao;
     @Inject
     UsageEventDao _usageEventDao;
@@ -173,14 +176,14 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
         }
         
         Long networkId = rule.getNetworkId();
-        Network network = _networkMgr.getNetwork(networkId);
+        Network network = _networkModel.getNetwork(networkId);
         //associate ip address to network (if needed)
         boolean performedIpAssoc = false;
         if (ipAddress.getAssociatedWithNetworkId() == null) {
             boolean assignToVpcNtwk =  network.getVpcId() != null 
                     && ipAddress.getVpcId() != null && ipAddress.getVpcId().longValue() == network.getVpcId();
             if (assignToVpcNtwk) {
-                _networkMgr.checkIpForService(ipAddress, Service.PortForwarding, networkId);
+                _networkModel.checkIpForService(ipAddress, Service.PortForwarding, networkId);
 
                 s_logger.debug("The ip is not associated with the VPC network id="+ networkId + ", so assigning");
                 try {
@@ -192,7 +195,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
                 }
             }
         } else {
-            _networkMgr.checkIpForService(ipAddress, Service.PortForwarding, null);
+            _networkModel.checkIpForService(ipAddress, Service.PortForwarding, null);
         }
         
         if (ipAddress.getAssociatedWithNetworkId() == null) { 
@@ -228,7 +231,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
 
             // Verify that vm has nic in the network
             Ip dstIp = rule.getDestinationIpAddress();
-            Nic guestNic = _networkMgr.getNicInNetwork(vmId, networkId);
+            Nic guestNic = _networkModel.getNicInNetwork(vmId, networkId);
             if (guestNic == null || guestNic.getIp4Address() == null) {
                 throw new InvalidParameterValueException("Vm doesn't belong to network associated with ipAddress");
             } else {
@@ -326,15 +329,15 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
         Long accountId = ipAddress.getAllocatedToAccountId();
         Long domainId = ipAddress.getAllocatedInDomainId();
 
-        _networkMgr.checkIpForService(ipAddress, Service.StaticNat, null);
+        _networkModel.checkIpForService(ipAddress, Service.StaticNat, null);
 
-        Network network = _networkMgr.getNetwork(networkId);
+        Network network = _networkModel.getNetwork(networkId);
         NetworkOffering off = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
         if (off.getElasticIp()) {
             throw new InvalidParameterValueException("Can't create ip forwarding rules for the network where elasticIP service is enabled");
         }
 
-        String dstIp = _networkMgr.getIpInNetwork(ipAddress.getAssociatedWithVmId(), networkId);
+        String dstIp = _networkModel.getIpInNetwork(ipAddress.getAssociatedWithVmId(), networkId);
 
         Transaction txn = Transaction.currentTxn();
         txn.start();
@@ -398,19 +401,19 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
         boolean performedIpAssoc = false;
         boolean result = false;
         try {
-            Network network = _networkMgr.getNetwork(networkId);
+            Network network = _networkModel.getNetwork(networkId);
             if (network == null) {
                 throw new InvalidParameterValueException("Unable to find network by id");
             }
             
             // Check that vm has a nic in the network
-            Nic guestNic = _networkMgr.getNicInNetwork(vmId, networkId);
+            Nic guestNic = _networkModel.getNicInNetwork(vmId, networkId);
             if (guestNic == null) {
                 throw new InvalidParameterValueException("Vm doesn't belong to the network with specified id");
             }
 
             
-            if (!_networkMgr.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
+            if (!_networkModel.areServicesSupportedInNetwork(network.getId(), Service.StaticNat)) {
                 throw new InvalidParameterValueException("Unable to create static nat rule; StaticNat service is not " +
                         "supported in network with specified id");
             }
@@ -426,7 +429,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
                     boolean assignToVpcNtwk = network.getVpcId() != null 
                             && ipAddress.getVpcId() != null && ipAddress.getVpcId().longValue() == network.getVpcId();
                     if (assignToVpcNtwk) {
-                        _networkMgr.checkIpForService(ipAddress, Service.StaticNat, networkId);
+                        _networkModel.checkIpForService(ipAddress, Service.StaticNat, networkId);
                         
                         s_logger.debug("The ip is not associated with the VPC network id="+ networkId + ", so assigning");
                         try {
@@ -439,7 +442,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
                         performedIpAssoc = true;
                     }
                 } else {
-                    _networkMgr.checkIpForService(ipAddress, Service.StaticNat, null);
+                    _networkModel.checkIpForService(ipAddress, Service.StaticNat, null);
                 }
                 
                 if (ipAddress.getAssociatedWithNetworkId() == null) { 
@@ -512,7 +515,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
             Long networkId = oldIP.getAssociatedWithNetworkId();
             boolean reassignStaticNat = false;
             if (networkId != null) {
-                Network guestNetwork = _networkMgr.getNetwork(networkId);
+                Network guestNetwork = _networkModel.getNetwork(networkId);
                 NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
                 if (offering.getElasticIp()) {
                     reassignStaticNat = true;
@@ -875,7 +878,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
         List<StaticNat> staticNats = new ArrayList<StaticNat>();
         for (IPAddressVO ip : ips) {
             // Get nic IP4 address
-            String dstIp = _networkMgr.getIpInNetwork(ip.getAssociatedWithVmId(), networkId);
+            String dstIp = _networkModel.getIpInNetwork(ip.getAssociatedWithVmId(), networkId);
             StaticNatImpl staticNat = new StaticNatImpl(ip.getAllocatedToAccountId(), ip.getAllocatedInDomainId(), networkId, ip.getId(), dstIp, false);
             staticNats.add(staticNat);
         }
@@ -1170,7 +1173,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
 
         // if network has elastic IP functionality supported, we first have to disable static nat on old ip in order to
         // re-enable it on the new one enable static nat takes care of that
-        Network guestNetwork = _networkMgr.getNetwork(ipAddress.getAssociatedWithNetworkId());
+        Network guestNetwork = _networkModel.getNetwork(ipAddress.getAssociatedWithNetworkId());
         NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
         if (offering.getElasticIp()) {
             if (offering.getAssociatePublicIP()) {
@@ -1257,9 +1260,9 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
         
         String dstIp;
         if (forRevoke) {
-            dstIp = _networkMgr.getIpInNetworkIncludingRemoved(ip.getAssociatedWithVmId(), rule.getNetworkId());
+            dstIp = _networkModel.getIpInNetworkIncludingRemoved(ip.getAssociatedWithVmId(), rule.getNetworkId());
         } else {
-            dstIp = _networkMgr.getIpInNetwork(ip.getAssociatedWithVmId(), rule.getNetworkId());
+            dstIp = _networkModel.getIpInNetwork(ip.getAssociatedWithVmId(), rule.getNetworkId());
         }
 
         return new StaticNatRuleImpl(ruleVO, dstIp);
@@ -1327,7 +1330,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
         }
 
         UserVmVO vm = _vmDao.findById(sourceIp.getAssociatedWithVmId());
-        Network network = _networkMgr.getNetwork(networkId);
+        Network network = _networkModel.getNetwork(networkId);
         if (network == null) {
         	CloudRuntimeException ex = new CloudRuntimeException("Unable to find an ip address to map to specified vm id");
         	ex.addProxyObject(vm, vm.getId(), "vmId");            
@@ -1343,9 +1346,9 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
 
         String dstIp;
         if (forRevoke) {
-            dstIp = _networkMgr.getIpInNetworkIncludingRemoved(sourceIp.getAssociatedWithVmId(), networkId);
+            dstIp = _networkModel.getIpInNetworkIncludingRemoved(sourceIp.getAssociatedWithVmId(), networkId);
         } else {
-            dstIp = _networkMgr.getIpInNetwork(sourceIp.getAssociatedWithVmId(), networkId);
+            dstIp = _networkModel.getIpInNetwork(sourceIp.getAssociatedWithVmId(), networkId);
         }
 
         StaticNatImpl staticNat = new StaticNatImpl(sourceIp.getAllocatedToAccountId(), sourceIp.getAllocatedInDomainId(),
@@ -1361,7 +1364,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
         // enable static nat if eIp capability is supported
         List<? extends Nic> nics = _nicDao.listByVmId(vm.getId());
         for (Nic nic : nics) {
-            Network guestNetwork = _networkMgr.getNetwork(nic.getNetworkId());
+            Network guestNetwork = _networkModel.getNetwork(nic.getNetworkId());
             NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
             if (offering.getElasticIp()) {
                 boolean isSystemVM = (vm.getType() == Type.ConsoleProxy || vm.getType() == Type.SecondaryStorageVm);

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/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 a1ed6d7..1d7d0fd 100755
--- a/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
+++ b/server/src/com/cloud/network/security/SecurityGroupManagerImpl.java
@@ -66,6 +66,7 @@ import com.cloud.exception.ResourceInUseException;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.network.Network;
 import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.security.SecurityGroupWork.Step;
 import com.cloud.network.security.SecurityRule.SecurityRuleType;
 import com.cloud.network.security.dao.SecurityGroupDao;
@@ -152,6 +153,8 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
     @Inject
     NetworkManager _networkMgr;
     @Inject
+    NetworkModel _networkModel;
+    @Inject
     AccountManager _accountMgr;
     @Inject
     DomainManager _domainMgr;
@@ -353,7 +356,7 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
                 if (rule.getAllowedNetworkId() != null) {
                     List<SecurityGroupVMMapVO> allowedInstances = _securityGroupVMMapDao.listBySecurityGroup(rule.getAllowedNetworkId(), State.Running);
                     for (SecurityGroupVMMapVO ngmapVO : allowedInstances) {
-                        Nic defaultNic = _networkMgr.getDefaultNic(ngmapVO.getInstanceId());
+                        Nic defaultNic = _networkModel.getDefaultNic(ngmapVO.getInstanceId());
                         if (defaultNic != null) {
                             String cidr = defaultNic.getIp4Address();
                             cidr = cidr + "/32";
@@ -1327,8 +1330,8 @@ public class SecurityGroupManagerImpl implements SecurityGroupManager, SecurityG
         VirtualMachine vm = _vmDao.findByIdIncludingRemoved(vmId);
         List<NicProfile> nics = _networkMgr.getNicProfiles(vm);
         for (NicProfile nic : nics) {
-            Network network = _networkMgr.getNetwork(nic.getNetworkId());
-            if (_networkMgr.isSecurityGroupSupportedInNetwork(network) && vm.getHypervisorType() != HypervisorType.VMware) {
+            Network network = _networkModel.getNetwork(nic.getNetworkId());
+            if (_networkModel.isSecurityGroupSupportedInNetwork(network) && vm.getHypervisorType() != HypervisorType.VMware) {
                 return true;
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/5a830c4d/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
index ce1b768..36cb8d5 100644
--- a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
+++ b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
@@ -35,7 +35,7 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
 import com.cloud.network.Network.Capability;
 import com.cloud.network.Network.Service;
-import com.cloud.network.NetworkManager;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks;
 import com.cloud.network.dao.FirewallRulesDao;
 import com.cloud.network.firewall.NetworkACLService;
@@ -79,7 +79,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{
     @Inject
     FirewallRulesDao _firewallDao;
     @Inject
-    NetworkManager _networkMgr;
+    NetworkModel _networkMgr;
     @Inject
     VpcManager _vpcMgr;
     @Inject


Mime
View raw message