cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [43/50] [abbrv] git commit: updated refs/heads/master to 771d052
Date Tue, 14 Oct 2014 18:16:01 GMT
Changing the way the DAOs were being injected in the RuleApplier;
Making code clearer and simple.

Conflicts:
	server/src/com/cloud/network/rules/PrivateGatewayRules.java
	server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
	server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
	server/src/org/apache/cloudstack/network/topology/NetworkTopologyVisitor.java


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

Branch: refs/heads/master
Commit: 9f801d1f3a6ca78b8497ab6786005154614d6b44
Parents: 60eea3b
Author: Wilder Rodrigues <wrodrigues@schubergphilis.com>
Authored: Tue Sep 9 17:09:29 2014 +0200
Committer: wilderrodrigues <wrodrigues@schubergphilis.com>
Committed: Tue Oct 14 15:08:12 2014 +0200

----------------------------------------------------------------------
 .../cloud/network/rules/AdvancedVpnRules.java   |   4 +-
 .../com/cloud/network/rules/DhcpEntryRules.java |  12 +-
 .../src/com/cloud/network/rules/DhcpRules.java  |   9 +-
 .../cloud/network/rules/DhcpSubNetRules.java    |  52 +++--
 .../com/cloud/network/rules/FirewallRules.java  |  20 +-
 .../cloud/network/rules/LoadBalancingRules.java |  20 +-
 .../cloud/network/rules/NicPlugInOutRules.java  |  48 +++--
 .../network/rules/PasswordToRouterRules.java    |   8 +-
 .../network/rules/PrivateGatewayRules.java      |  41 ++--
 .../com/cloud/network/rules/RuleApplier.java    |  47 +---
 .../network/rules/SshKeyToRouterRules.java      |  16 +-
 .../cloud/network/rules/UserdataPwdRules.java   |  10 +-
 .../network/rules/UserdataToRouterRules.java    |  10 +-
 .../rules/VirtualNetworkApplianceFactory.java   | 212 ++++---------------
 .../network/rules/VpcIpAssociationRules.java    |   4 +-
 .../topology/AdvancedNetworkTopology.java       |  20 +-
 .../topology/AdvancedNetworkVisitor.java        |   4 +-
 .../network/topology/BasicNetworkTopology.java  |  26 ++-
 .../network/topology/BasicNetworkVisitor.java   |   9 +
 .../topology/NetworkTopologyVisitor.java        |   8 +-
 20 files changed, 260 insertions(+), 320 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/AdvancedVpnRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/AdvancedVpnRules.java b/server/src/com/cloud/network/rules/AdvancedVpnRules.java
index f7cb361..d97ffb6 100644
--- a/server/src/com/cloud/network/rules/AdvancedVpnRules.java
+++ b/server/src/com/cloud/network/rules/AdvancedVpnRules.java
@@ -28,6 +28,7 @@ import com.cloud.network.RemoteAccessVpn;
 import com.cloud.network.VpnUser;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.vpc.Vpc;
+import com.cloud.network.vpc.dao.VpcDao;
 import com.cloud.vm.VirtualMachine.State;
 
 public class AdvancedVpnRules extends BasicVpnRules {
@@ -45,7 +46,8 @@ public class AdvancedVpnRules extends BasicVpnRules {
     public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
         _router = router;
 
-        Vpc vpc = _vpcDao.findById(_remoteAccessVpn.getVpcId());
+        VpcDao vpcDao = visitor.getVirtualNetworkApplianceFactory().getVpcDao();
+        Vpc vpc = vpcDao.findById(_remoteAccessVpn.getVpcId());
 
         if (_router.getState() != State.Running) {
             s_logger.warn("Failed to add/remove Remote Access VPN users: router not in running state");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/DhcpEntryRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/DhcpEntryRules.java b/server/src/com/cloud/network/rules/DhcpEntryRules.java
index b7a7bd3..991813c 100644
--- a/server/src/com/cloud/network/rules/DhcpEntryRules.java
+++ b/server/src/com/cloud/network/rules/DhcpEntryRules.java
@@ -27,6 +27,8 @@ import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.vm.dao.UserVmDao;
 
 public class DhcpEntryRules extends RuleApplier {
 
@@ -49,9 +51,13 @@ public class DhcpEntryRules extends RuleApplier {
     public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
         _router = router;
 
-        _userVM = _userVmDao.findById(_profile.getId());
-        _userVmDao.loadDetails(_userVM);
-        _nicVo = _nicDao.findById(_nic.getId());
+        UserVmDao userVmDao = visitor.getVirtualNetworkApplianceFactory().getUserVmDao();
+        _userVM = userVmDao.findById(_profile.getId());
+
+        userVmDao.loadDetails(_userVM);
+
+        NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
+        _nicVo = nicDao.findById(_nic.getId());
 
         return visitor.visit(this);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/DhcpRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/DhcpRules.java b/server/src/com/cloud/network/rules/DhcpRules.java
index 655d430..5e8cf9e 100644
--- a/server/src/com/cloud/network/rules/DhcpRules.java
+++ b/server/src/com/cloud/network/rules/DhcpRules.java
@@ -22,6 +22,8 @@ import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 import com.cloud.agent.api.PvlanSetupCommand;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.dao.NetworkDao;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.vm.NicProfile;
 
@@ -48,8 +50,11 @@ public class DhcpRules extends RuleApplier {
             op = "delete";
         }
 
-        final Network network = _networkDao.findById(_nic.getNetworkId());
-        final String networkTag = _networkModel.getNetworkTag(_router.getHypervisorType(), network);
+        NetworkDao networkDao = visitor.getVirtualNetworkApplianceFactory().getNetworkDao();
+        final Network network = networkDao.findById(_nic.getNetworkId());
+
+        NetworkModel networkModel = visitor.getVirtualNetworkApplianceFactory().getNetworkModel();
+        final String networkTag = networkModel.getNetworkTag(_router.getHypervisorType(), network);
 
         _setupCommand = PvlanSetupCommand.createDhcpSetup(op, _nic.getBroadCastUri(), networkTag, _router.getInstanceName(), _nic.getMacAddress(), _nic.getIp4Address());
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/DhcpSubNetRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/DhcpSubNetRules.java b/server/src/com/cloud/network/rules/DhcpSubNetRules.java
index 0bbcfcc..ac69479 100644
--- a/server/src/com/cloud/network/rules/DhcpSubNetRules.java
+++ b/server/src/com/cloud/network/rules/DhcpSubNetRules.java
@@ -28,12 +28,17 @@ import com.cloud.dc.DataCenter;
 import com.cloud.dc.DataCenter.NetworkType;
 import com.cloud.dc.Vlan;
 import com.cloud.dc.VlanVO;
+import com.cloud.dc.dao.DataCenterDao;
+import com.cloud.dc.dao.HostPodDao;
+import com.cloud.dc.dao.VlanDao;
 import com.cloud.exception.InsufficientAddressCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.network.IpAddressManager;
 import com.cloud.network.Network;
 import com.cloud.network.Network.GuestType;
 import com.cloud.network.Networks.TrafficType;
 import com.cloud.network.addr.PublicIp;
+import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.user.Account;
 import com.cloud.utils.db.Transaction;
@@ -47,7 +52,10 @@ import com.cloud.vm.NicVO;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VirtualMachine;
 import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.vm.dao.NicIpAliasDao;
 import com.cloud.vm.dao.NicIpAliasVO;
+import com.cloud.vm.dao.UserVmDao;
 
 public class DhcpSubNetRules extends RuleApplier {
 
@@ -70,11 +78,13 @@ public class DhcpSubNetRules extends RuleApplier {
     public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
         _router = router;
 
-        final UserVmVO vm = _userVmDao.findById(_profile.getId());
-        _userVmDao.loadDetails(vm);
+        UserVmDao userVmDao = visitor.getVirtualNetworkApplianceFactory().getUserVmDao();
+        final UserVmVO vm = userVmDao.findById(_profile.getId());
+        userVmDao.loadDetails(vm);
 
+        NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
         // check if this is not the primary subnet.
-        final NicVO domr_guest_nic = _nicDao.findByInstanceIdAndIpAddressAndVmtype(_router.getId(), _nicDao.getIpAddress(_nic.getNetworkId(), _router.getId()),
+        final NicVO domrGuestNic = nicDao.findByInstanceIdAndIpAddressAndVmtype(_router.getId(), nicDao.getIpAddress(_nic.getNetworkId(), _router.getId()),
                 VirtualMachine.Type.DomainRouter);
         // check if the router ip address and the vm ip address belong to same
         // subnet.
@@ -82,8 +92,9 @@ public class DhcpSubNetRules extends RuleApplier {
         // create one.
         // This should happen only in case of Basic and Advanced SG enabled
         // networks.
-        if (!NetUtils.sameSubnet(domr_guest_nic.getIp4Address(), _nic.getIp4Address(), _nic.getNetmask())) {
-            final List<NicIpAliasVO> aliasIps = _nicIpAliasDao.listByNetworkIdAndState(domr_guest_nic.getNetworkId(), NicIpAlias.state.active);
+        if (!NetUtils.sameSubnet(domrGuestNic.getIp4Address(), _nic.getIp4Address(), _nic.getNetmask())) {
+            final NicIpAliasDao nicIpAliasDao = visitor.getVirtualNetworkApplianceFactory().getNicIpAliasDao();
+            final List<NicIpAliasVO> aliasIps = nicIpAliasDao.listByNetworkIdAndState(domrGuestNic.getNetworkId(), NicIpAlias.state.active);
             boolean ipInVmsubnet = false;
             for (final NicIpAliasVO alias : aliasIps) {
                 // check if any of the alias ips belongs to the Vm's subnet.
@@ -94,22 +105,27 @@ public class DhcpSubNetRules extends RuleApplier {
             }
 
             PublicIp routerPublicIP = null;
-            final DataCenter dc = _dcDao.findById(_router.getDataCenterId());
+            DataCenterDao dcDao = visitor.getVirtualNetworkApplianceFactory().getDcDao();
+            final DataCenter dc = dcDao.findById(_router.getDataCenterId());
             if (ipInVmsubnet == false) {
                 try {
-                    if ((_network.getTrafficType() == TrafficType.Guest) && (_network.getGuestType() == GuestType.Shared)) {
-                        _podDao.findById(vm.getPodIdToDeployIn());
+                    if (_network.getTrafficType() == TrafficType.Guest && _network.getGuestType() == GuestType.Shared) {
+                        HostPodDao podDao = visitor.getVirtualNetworkApplianceFactory().getPodDao();
+                        podDao.findById(vm.getPodIdToDeployIn());
                         final Account caller = CallContext.current().getCallingAccount();
-                        final List<VlanVO> vlanList = _vlanDao.listVlansByNetworkIdAndGateway(_network.getId(), _nic.getGateway());
+
+                        VlanDao vlanDao = visitor.getVirtualNetworkApplianceFactory().getVlanDao();
+                        final List<VlanVO> vlanList = vlanDao.listVlansByNetworkIdAndGateway(_network.getId(), _nic.getGateway());
                         final List<Long> vlanDbIdList = new ArrayList<Long>();
                         for (final VlanVO vlan : vlanList) {
                             vlanDbIdList.add(vlan.getId());
                         }
+                        IpAddressManager ipAddrMgr = visitor.getVirtualNetworkApplianceFactory().getIpAddrMgr();
                         if (dc.getNetworkType() == NetworkType.Basic) {
-                            routerPublicIP = _ipAddrMgr.assignPublicIpAddressFromVlans(_router.getDataCenterId(), vm.getPodIdToDeployIn(), caller, Vlan.VlanType.DirectAttached,
+                            routerPublicIP = ipAddrMgr.assignPublicIpAddressFromVlans(_router.getDataCenterId(), vm.getPodIdToDeployIn(), caller, Vlan.VlanType.DirectAttached,
                                     vlanDbIdList, _nic.getNetworkId(), null, false);
                         } else {
-                            routerPublicIP = _ipAddrMgr.assignPublicIpAddressFromVlans(_router.getDataCenterId(), null, caller, Vlan.VlanType.DirectAttached, vlanDbIdList,
+                            routerPublicIP = ipAddrMgr.assignPublicIpAddressFromVlans(_router.getDataCenterId(), null, caller, Vlan.VlanType.DirectAttached, vlanDbIdList,
                                     _nic.getNetworkId(), null, false);
                         }
 
@@ -121,21 +137,23 @@ public class DhcpSubNetRules extends RuleApplier {
                     return false;
                 }
                 // this means we did not create an IP alias on the router.
-                _nicAlias = new NicIpAliasVO(domr_guest_nic.getId(), _routerAliasIp, _router.getId(), CallContext.current().getCallingAccountId(), _network.getDomainId(),
+                _nicAlias = new NicIpAliasVO(domrGuestNic.getId(), _routerAliasIp, _router.getId(), CallContext.current().getCallingAccountId(), _network.getDomainId(),
                         _nic.getNetworkId(), _nic.getGateway(), _nic.getNetmask());
-                _nicAlias.setAliasCount((routerPublicIP.getIpMacAddress()));
-                _nicIpAliasDao.persist(_nicAlias);
+                _nicAlias.setAliasCount(routerPublicIP.getIpMacAddress());
+                nicIpAliasDao.persist(_nicAlias);
 
                 final boolean result = visitor.visit(this);
 
                 if (result == false) {
-                    final NicIpAliasVO ipAliasVO = _nicIpAliasDao.findByInstanceIdAndNetworkId(_network.getId(), _router.getId());
+                    final NicIpAliasVO ipAliasVO = nicIpAliasDao.findByInstanceIdAndNetworkId(_network.getId(), _router.getId());
                     final PublicIp routerPublicIPFinal = routerPublicIP;
                     Transaction.execute(new TransactionCallbackNoReturn() {
                         @Override
                         public void doInTransactionWithoutResult(final TransactionStatus status) {
-                            _nicIpAliasDao.expunge(ipAliasVO.getId());
-                            _ipAddressDao.unassignIpAddress(routerPublicIPFinal.getId());
+                            nicIpAliasDao.expunge(ipAliasVO.getId());
+
+                            IPAddressDao ipAddressDao = visitor.getVirtualNetworkApplianceFactory().getIpAddressDao();
+                            ipAddressDao.unassignIpAddress(routerPublicIPFinal.getId());
                         }
                     });
                     throw new CloudRuntimeException("failed to configure ip alias on the router as a part of dhcp config");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/FirewallRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/FirewallRules.java b/server/src/com/cloud/network/rules/FirewallRules.java
index 668f403..b36ce81 100644
--- a/server/src/com/cloud/network/rules/FirewallRules.java
+++ b/server/src/com/cloud/network/rules/FirewallRules.java
@@ -24,12 +24,15 @@ import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.dao.LoadBalancerDao;
 import com.cloud.network.dao.LoadBalancerVO;
 import com.cloud.network.lb.LoadBalancingRule;
 import com.cloud.network.lb.LoadBalancingRule.LbDestination;
 import com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy;
 import com.cloud.network.lb.LoadBalancingRule.LbSslCert;
 import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
+import com.cloud.network.lb.LoadBalancingRulesManager;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.rules.FirewallRule.Purpose;
 import com.cloud.network.rules.LoadBalancerContainer.Scheme;
@@ -54,15 +57,20 @@ public class FirewallRules extends RuleApplier {
         _purpose = _rules.get(0).getPurpose();
 
         if (_purpose == Purpose.LoadBalancing) {
+            LoadBalancerDao loadBalancerDao = visitor.getVirtualNetworkApplianceFactory().getLoadBalancerDao();
             // for load balancer we have to resend all lb rules for the network
-            final List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkIdAndScheme(_network.getId(), Scheme.Public);
+            final List<LoadBalancerVO> lbs = loadBalancerDao.listByNetworkIdAndScheme(_network.getId(), Scheme.Public);
             _loadbalancingRules = new ArrayList<LoadBalancingRule>();
+
+            LoadBalancingRulesManager lbMgr = visitor.getVirtualNetworkApplianceFactory().getLbMgr();
+            NetworkModel networkModel = visitor.getVirtualNetworkApplianceFactory().getNetworkModel();
+
             for (final LoadBalancerVO lb : lbs) {
-                final List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
-                final List<LbStickinessPolicy> policyList = _lbMgr.getStickinessPolicies(lb.getId());
-                final List<LbHealthCheckPolicy> hcPolicyList = _lbMgr.getHealthCheckPolicies(lb.getId());
-                final LbSslCert sslCert = _lbMgr.getLbSslCert(lb.getId());
-                final Ip sourceIp = _networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
+                final List<LbDestination> dstList = lbMgr.getExistingDestinations(lb.getId());
+                final List<LbStickinessPolicy> policyList = lbMgr.getStickinessPolicies(lb.getId());
+                final List<LbHealthCheckPolicy> hcPolicyList = lbMgr.getHealthCheckPolicies(lb.getId());
+                final LbSslCert sslCert = lbMgr.getLbSslCert(lb.getId());
+                final Ip sourceIp = networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
                 final LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList, policyList, hcPolicyList, sourceIp, sslCert, lb.getLbProtocol());
 
                 _loadbalancingRules.add(loadBalancing);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/LoadBalancingRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/LoadBalancingRules.java b/server/src/com/cloud/network/rules/LoadBalancingRules.java
index d6e762f..62c8b3b 100644
--- a/server/src/com/cloud/network/rules/LoadBalancingRules.java
+++ b/server/src/com/cloud/network/rules/LoadBalancingRules.java
@@ -23,12 +23,15 @@ import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.dao.LoadBalancerDao;
 import com.cloud.network.dao.LoadBalancerVO;
 import com.cloud.network.lb.LoadBalancingRule;
 import com.cloud.network.lb.LoadBalancingRule.LbDestination;
 import com.cloud.network.lb.LoadBalancingRule.LbHealthCheckPolicy;
 import com.cloud.network.lb.LoadBalancingRule.LbSslCert;
 import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
+import com.cloud.network.lb.LoadBalancingRulesManager;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.rules.LoadBalancerContainer.Scheme;
 import com.cloud.utils.net.Ip;
@@ -46,18 +49,23 @@ public class LoadBalancingRules extends RuleApplier {
     public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
         _router = router;
 
+        LoadBalancerDao loadBalancerDao = visitor.getVirtualNetworkApplianceFactory().getLoadBalancerDao();
         // For load balancer we have to resend all lb rules for the network
-        final List<LoadBalancerVO> lbs = _loadBalancerDao.listByNetworkIdAndScheme(_network.getId(), Scheme.Public);
+        final List<LoadBalancerVO> lbs = loadBalancerDao.listByNetworkIdAndScheme(_network.getId(), Scheme.Public);
 
         // We are cleaning it before because all the rules have to be sent to
         // the router.
         _rules.clear();
+
+        LoadBalancingRulesManager lbMgr = visitor.getVirtualNetworkApplianceFactory().getLbMgr();
+        NetworkModel networkModel = visitor.getVirtualNetworkApplianceFactory().getNetworkModel();
         for (final LoadBalancerVO lb : lbs) {
-            final List<LbDestination> dstList = _lbMgr.getExistingDestinations(lb.getId());
-            final List<LbStickinessPolicy> policyList = _lbMgr.getStickinessPolicies(lb.getId());
-            final List<LbHealthCheckPolicy> hcPolicyList = _lbMgr.getHealthCheckPolicies(lb.getId());
-            final LbSslCert sslCert = _lbMgr.getLbSslCert(lb.getId());
-            final Ip sourceIp = _networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
+
+            final List<LbDestination> dstList = lbMgr.getExistingDestinations(lb.getId());
+            final List<LbStickinessPolicy> policyList = lbMgr.getStickinessPolicies(lb.getId());
+            final List<LbHealthCheckPolicy> hcPolicyList = lbMgr.getHealthCheckPolicies(lb.getId());
+            final LbSslCert sslCert = lbMgr.getLbSslCert(lb.getId());
+            final Ip sourceIp = networkModel.getPublicIpAddress(lb.getSourceIpAddressId()).getAddress();
             final LoadBalancingRule loadBalancing = new LoadBalancingRule(lb, dstList, policyList, hcPolicyList, sourceIp, sslCert, lb.getLbProtocol());
 
             _rules.add(loadBalancing);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/NicPlugInOutRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/NicPlugInOutRules.java b/server/src/com/cloud/network/rules/NicPlugInOutRules.java
index c20d07e..121be90 100644
--- a/server/src/com/cloud/network/rules/NicPlugInOutRules.java
+++ b/server/src/com/cloud/network/rules/NicPlugInOutRules.java
@@ -34,16 +34,22 @@ import com.cloud.exception.InsufficientCapacityException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
+import com.cloud.network.NetworkModel;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.Networks.IsolationType;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.vpc.VpcManager;
 import com.cloud.network.vpc.VpcVO;
+import com.cloud.network.vpc.dao.VpcDao;
 import com.cloud.user.UserStatisticsVO;
+import com.cloud.user.dao.UserStatisticsDao;
 import com.cloud.utils.Pair;
 import com.cloud.vm.Nic;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
+import com.cloud.vm.VirtualMachineManager;
+import com.cloud.vm.dao.NicDao;
 
 public class NicPlugInOutRules extends RuleApplier {
 
@@ -62,17 +68,20 @@ public class NicPlugInOutRules extends RuleApplier {
     public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
         _router = router;
 
-        Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> nicsToChange = getNicsToChangeOnRouter(_ipAddresses);
+        Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> nicsToChange = getNicsToChangeOnRouter(visitor);
+
         Map<String, PublicIpAddress> nicsToPlug = nicsToChange.first();
         Map<String, PublicIpAddress> nicsToUnplug = nicsToChange.second();
 
+        NetworkModel networkModel = visitor.getVirtualNetworkApplianceFactory().getNetworkModel();
+        VirtualMachineManager itMgr = visitor.getVirtualNetworkApplianceFactory().getItMgr();
         // 1) Unplug the nics
         for (Entry<String, PublicIpAddress> entry : nicsToUnplug.entrySet()) {
             Network publicNtwk = null;
             try {
-                publicNtwk = _networkModel.getNetwork(entry.getValue().getNetworkId());
+                publicNtwk = networkModel.getNetwork(entry.getValue().getNetworkId());
                 URI broadcastUri = BroadcastDomainType.Vlan.toUri(entry.getKey());
-                _itMgr.removeVmFromNetwork(_router, publicNtwk, broadcastUri);
+                itMgr.removeVmFromNetwork(_router, publicNtwk, broadcastUri);
             } catch (ConcurrentOperationException e) {
                 s_logger.warn("Failed to remove router " + _router + " from vlan " + entry.getKey() + " in public network " + publicNtwk + " due to ", e);
                 return false;
@@ -80,7 +89,8 @@ public class NicPlugInOutRules extends RuleApplier {
         }
 
         _netUsageCommands = new Commands(Command.OnError.Continue);
-        VpcVO vpc = _vpcDao.findById(_router.getVpcId());
+        VpcDao vpcDao = visitor.getVirtualNetworkApplianceFactory().getVpcDao();
+        VpcVO vpc = vpcDao.findById(_router.getVpcId());
 
         // 2) Plug the nics
         for (String vlanTag : nicsToPlug.keySet()) {
@@ -101,8 +111,8 @@ public class NicPlugInOutRules extends RuleApplier {
             NicProfile publicNic = null;
             Network publicNtwk = null;
             try {
-                publicNtwk = _networkModel.getNetwork(ip.getNetworkId());
-                publicNic = _itMgr.addVmToNetwork(_router, publicNtwk, defaultNic);
+                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 + " in public network " + publicNtwk + " due to ", e);
             } catch (InsufficientCapacityException e) {
@@ -117,12 +127,14 @@ public class NicPlugInOutRules extends RuleApplier {
             // IPAssoc
             NetworkUsageCommand netUsageCmd = new NetworkUsageCommand(_router.getPrivateIpAddress(), _router.getInstanceName(), true, defaultNic.getIp4Address(), vpc.getCidr());
             _netUsageCommands.addCommand(netUsageCmd);
-            UserStatisticsVO stats = _userStatsDao.findBy(_router.getAccountId(), _router.getDataCenterId(), publicNtwk.getId(), publicNic.getIp4Address(), _router.getId(),
+
+            UserStatisticsDao userStatsDao = visitor.getVirtualNetworkApplianceFactory().getUserStatsDao();
+            UserStatisticsVO stats = userStatsDao.findBy(_router.getAccountId(), _router.getDataCenterId(), publicNtwk.getId(), publicNic.getIp4Address(), _router.getId(),
                     _router.getType().toString());
             if (stats == null) {
                 stats = new UserStatisticsVO(_router.getAccountId(), _router.getDataCenterId(), publicNic.getIp4Address(), _router.getId(), _router.getType().toString(),
                         publicNtwk.getId());
-                _userStatsDao.persist(stats);
+                userStatsDao.persist(stats);
             }
         }
 
@@ -139,24 +151,26 @@ public class NicPlugInOutRules extends RuleApplier {
         return _netUsageCommands;
     }
 
-    private Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> getNicsToChangeOnRouter(final List<? extends PublicIpAddress> publicIps) {
+    private Pair<Map<String, PublicIpAddress>, Map<String, PublicIpAddress>> getNicsToChangeOnRouter(final NetworkTopologyVisitor visitor) {
         // 1) check which nics need to be plugged/unplugged and plug/unplug them
 
         final Map<String, PublicIpAddress> nicsToPlug = new HashMap<String, PublicIpAddress>();
         final Map<String, PublicIpAddress> nicsToUnplug = new HashMap<String, PublicIpAddress>();
 
+        VpcManager vpcMgr = visitor.getVirtualNetworkApplianceFactory().getVpcMgr();
+        NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
         // find out nics to unplug
-        for (PublicIpAddress ip : publicIps) {
+        for (PublicIpAddress ip : _ipAddresses) {
             long publicNtwkId = ip.getNetworkId();
 
             // if ip is not associated to any network, and there are no firewall
             // rules, release it on the backend
-            if (!_vpcMgr.isIpAllocatedToVpc(ip)) {
+            if (!vpcMgr.isIpAllocatedToVpc(ip)) {
                 ip.setState(IpAddress.State.Releasing);
             }
 
             if (ip.getState() == IpAddress.State.Releasing) {
-                Nic nic = _nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId, _router.getId(), ip.getAddress().addr());
+                Nic nic = nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId, _router.getId(), ip.getAddress().addr());
                 if (nic != null) {
                     nicsToUnplug.put(ip.getVlanTag(), ip);
                     s_logger.debug("Need to unplug the nic for ip=" + ip + "; vlan=" + ip.getVlanTag() + " in public network id =" + publicNtwkId);
@@ -165,20 +179,20 @@ public class NicPlugInOutRules extends RuleApplier {
         }
 
         // find out nics to plug
-        for (PublicIpAddress ip : publicIps) {
+        for (PublicIpAddress ip : _ipAddresses) {
             URI broadcastUri = BroadcastDomainType.Vlan.toUri(ip.getVlanTag());
             long publicNtwkId = ip.getNetworkId();
 
             // if ip is not associated to any network, and there are no firewall
             // rules, release it on the backend
-            if (!_vpcMgr.isIpAllocatedToVpc(ip)) {
+            if (!vpcMgr.isIpAllocatedToVpc(ip)) {
                 ip.setState(IpAddress.State.Releasing);
             }
 
             if (ip.getState() == IpAddress.State.Allocated || ip.getState() == IpAddress.State.Allocating) {
                 // nic has to be plugged only when there are no nics for this
                 // vlan tag exist on VR
-                Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(publicNtwkId, _router.getId(), broadcastUri.toString());
+                Nic nic = nicDao.findByNetworkIdInstanceIdAndBroadcastUri(publicNtwkId, _router.getId(), broadcastUri.toString());
 
                 if (nic == null && nicsToPlug.get(ip.getVlanTag()) == null) {
                     nicsToPlug.put(ip.getVlanTag(), ip);
@@ -186,9 +200,9 @@ public class NicPlugInOutRules extends RuleApplier {
                 } else {
                     final PublicIpAddress nicToUnplug = nicsToUnplug.get(ip.getVlanTag());
                     if (nicToUnplug != null) {
-                        NicVO nicVO = _nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId, _router.getId(), nicToUnplug.getAddress().addr());
+                        NicVO nicVO = nicDao.findByIp4AddressAndNetworkIdAndInstanceId(publicNtwkId, _router.getId(), nicToUnplug.getAddress().addr());
                         nicVO.setIp4Address(ip.getAddress().addr());
-                        _nicDao.update(nicVO.getId(), nicVO);
+                        nicDao.update(nicVO.getId(), nicVO);
                         s_logger.debug("Updated the nic " + nicVO + " with the new ip address " + ip.getAddress().addr());
                         nicsToUnplug.remove(ip.getVlanTag());
                     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/PasswordToRouterRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/PasswordToRouterRules.java b/server/src/com/cloud/network/rules/PasswordToRouterRules.java
index 8395c10..6c46ab6 100644
--- a/server/src/com/cloud/network/rules/PasswordToRouterRules.java
+++ b/server/src/com/cloud/network/rules/PasswordToRouterRules.java
@@ -26,6 +26,8 @@ import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.vm.dao.UserVmDao;
 
 public class PasswordToRouterRules extends RuleApplier {
 
@@ -45,9 +47,11 @@ public class PasswordToRouterRules extends RuleApplier {
     public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
         _router = router;
 
-        _userVmDao.loadDetails((UserVmVO)profile.getVirtualMachine());
+        UserVmDao userVmDao = visitor.getVirtualNetworkApplianceFactory().getUserVmDao();
+        userVmDao.loadDetails((UserVmVO) profile.getVirtualMachine());
         // for basic zone, send vm data/password information only to the router in the same pod
-        nicVo = _nicDao.findById(nic.getId());
+        NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
+        nicVo = nicDao.findById(nic.getId());
 
         return visitor.visit(this);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/PrivateGatewayRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/PrivateGatewayRules.java b/server/src/com/cloud/network/rules/PrivateGatewayRules.java
index a1e1c5c..476a617 100644
--- a/server/src/com/cloud/network/rules/PrivateGatewayRules.java
+++ b/server/src/com/cloud/network/rules/PrivateGatewayRules.java
@@ -23,10 +23,16 @@ import org.apache.log4j.Logger;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
+import com.cloud.network.NetworkModel;
+import com.cloud.network.dao.NetworkDao;
+import com.cloud.network.router.NetworkHelper;
+import com.cloud.network.router.NicProfileHelper;
 import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.vpc.NetworkACLManager;
 import com.cloud.network.vpc.PrivateGateway;
 import com.cloud.network.vpc.PrivateIpVO;
 import com.cloud.vm.NicProfile;
+import com.cloud.vm.VirtualMachineManager;
 
 public class PrivateGatewayRules extends RuleApplier {
 
@@ -48,14 +54,19 @@ public class PrivateGatewayRules extends RuleApplier {
 
         boolean result = false;
         try {
-            _network = _networkModel.getNetwork(_privateGateway.getNetworkId());
-            NicProfile requested = _vpcNetworkHelper.createPrivateNicProfileForGateway(_privateGateway);
+            NetworkModel networkModel = visitor.getVirtualNetworkApplianceFactory().getNetworkModel();
+            _network = networkModel.getNetwork(_privateGateway.getNetworkId());
 
-            if (!_networkHelper.checkRouterVersion(_router)) {
+            NicProfileHelper nicProfileHelper = visitor.getVirtualNetworkApplianceFactory().getNicProfileHelper();
+            NicProfile requested = nicProfileHelper.createPrivateNicProfileForGateway(_privateGateway);
+
+            NetworkHelper networkHelper = visitor.getVirtualNetworkApplianceFactory().getNetworkHelper();
+            if (!networkHelper.checkRouterVersion(_router)) {
                 s_logger.warn("Router requires upgrade. Unable to send command to router: " + _router.getId());
                 return false;
             }
-            _nicProfile = _itMgr.addVmToNetwork(_router, _network, requested);
+            VirtualMachineManager itMgr = visitor.getVirtualNetworkApplianceFactory().getItMgr();
+            _nicProfile = itMgr.addVmToNetwork(_router, _network, requested);
 
             // setup source nat
             if (_nicProfile != null) {
@@ -89,32 +100,34 @@ public class PrivateGatewayRules extends RuleApplier {
         return _nicProfile;
     }
 
-    public PrivateIpVO retrivePrivateIP() {
-        PrivateIpVO ipVO = _privateIpDao.findByIpAndSourceNetworkId(_nicProfile.getNetworkId(), _nicProfile.getIp4Address());
+    public PrivateIpVO retrivePrivateIP(final NetworkTopologyVisitor visitor) {
+        PrivateIpVO ipVO = visitor.getVirtualNetworkApplianceFactory().getPrivateIpDao().findByIpAndSourceNetworkId(_nicProfile.getNetworkId(), _nicProfile.getIp4Address());
         return ipVO;
     }
 
-    public Network retrievePrivateNetwork() {
+    public Network retrievePrivateNetwork(final NetworkTopologyVisitor visitor) {
         // This network might be the same we have already as an instance in the
         // RuleApplier super class.
         // Just doing this here, but will double check is remove if it's not
         // needed.
-        Network network = _networkDao.findById(_nicProfile.getNetworkId());
+        NetworkDao networkDao = visitor.getVirtualNetworkApplianceFactory().getNetworkDao();
+        Network network = networkDao.findById(_nicProfile.getNetworkId());
         return network;
     }
 
     protected boolean destroyPrivateGateway(final NetworkTopologyVisitor visitor) throws ConcurrentOperationException, ResourceUnavailableException {
 
-        if (!_networkModel.isVmPartOfNetwork(_router.getId(), _privateGateway.getNetworkId())) {
+        NetworkModel networkModel = visitor.getVirtualNetworkApplianceFactory().getNetworkModel();
+        if (!networkModel.isVmPartOfNetwork(_router.getId(), _privateGateway.getNetworkId())) {
             s_logger.debug("Router doesn't have nic for gateway " + _privateGateway + " so no need to removed it");
             return true;
         }
 
-        Network privateNetwork = _networkModel.getNetwork(_privateGateway.getNetworkId());
+        Network privateNetwork = networkModel.getNetwork(_privateGateway.getNetworkId());
 
         s_logger.debug("Releasing private ip for gateway " + _privateGateway + " from " + _router);
 
-        _nicProfile = _networkModel.getNicProfile(_router, privateNetwork.getId(), null);
+        _nicProfile = networkModel.getNicProfile(_router, privateNetwork.getId(), null);
         boolean result = visitor.visit(this);
         if (!result) {
             s_logger.warn("Failed to release private ip for gateway " + _privateGateway + " on router " + _router);
@@ -122,13 +135,15 @@ public class PrivateGatewayRules extends RuleApplier {
         }
 
         // revoke network acl on the private gateway.
-        if (!_networkACLMgr.revokeACLItemsForPrivateGw(_privateGateway)) {
+        NetworkACLManager networkACLMgr = visitor.getVirtualNetworkApplianceFactory().getNetworkACLMgr();
+        if (!networkACLMgr.revokeACLItemsForPrivateGw(_privateGateway)) {
             s_logger.debug("Failed to delete network acl items on " + _privateGateway + " from router " + _router);
             return false;
         }
 
         s_logger.debug("Removing router " + _router + " from private network " + privateNetwork + " as a part of delete private gateway");
-        result = result && _itMgr.removeVmFromNetwork(_router, privateNetwork, null);
+        VirtualMachineManager itMgr = visitor.getVirtualNetworkApplianceFactory().getItMgr();
+        result = result && itMgr.removeVmFromNetwork(_router, privateNetwork, null);
         s_logger.debug("Private gateawy " + _privateGateway + " is removed from router " + _router);
         return result;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/RuleApplier.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/RuleApplier.java b/server/src/com/cloud/network/rules/RuleApplier.java
index 4c399ed..cbeb27e 100644
--- a/server/src/com/cloud/network/rules/RuleApplier.java
+++ b/server/src/com/cloud/network/rules/RuleApplier.java
@@ -19,63 +19,19 @@ package com.cloud.network.rules;
 
 import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 
-import com.cloud.dc.dao.DataCenterDao;
-import com.cloud.dc.dao.HostPodDao;
-import com.cloud.dc.dao.VlanDao;
 import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.IpAddressManager;
 import com.cloud.network.Network;
-import com.cloud.network.NetworkModel;
-import com.cloud.network.dao.IPAddressDao;
-import com.cloud.network.dao.LoadBalancerDao;
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.lb.LoadBalancingRulesManager;
-import com.cloud.network.router.NetworkHelper;
-import com.cloud.network.router.NicProfileHelper;
 import com.cloud.network.router.VirtualRouter;
-import com.cloud.network.vpc.NetworkACLManager;
-import com.cloud.network.vpc.VpcManager;
-import com.cloud.network.vpc.dao.PrivateIpDao;
-import com.cloud.network.vpc.dao.VpcDao;
-import com.cloud.storage.dao.VMTemplateDao;
-import com.cloud.user.dao.UserStatisticsDao;
-import com.cloud.vm.VirtualMachineManager;
-import com.cloud.vm.dao.NicDao;
-import com.cloud.vm.dao.NicIpAliasDao;
-import com.cloud.vm.dao.UserVmDao;
 
 public abstract class RuleApplier {
 
-    protected NetworkModel _networkModel;
-    protected LoadBalancingRulesManager _lbMgr;
-    protected LoadBalancerDao _loadBalancerDao;
-    protected NicDao _nicDao;
-    protected DataCenterDao _dcDao;
-    protected UserVmDao _userVmDao;
-    protected VMTemplateDao _templateDao;
-    protected NetworkDao _networkDao;
-    protected UserStatisticsDao _userStatsDao;
-    protected VpcDao _vpcDao;
-    protected NicIpAliasDao _nicIpAliasDao;
-    protected HostPodDao _podDao;
-    protected VlanDao _vlanDao;
-    protected IPAddressDao _ipAddressDao;
-    protected PrivateIpDao _privateIpDao;
-    protected VpcManager _vpcMgr;
-    protected VirtualMachineManager _itMgr;
-    protected IpAddressManager _ipAddrMgr;
-    protected NetworkACLManager _networkACLMgr;
     protected Network _network;
     protected VirtualRouter _router;
-    protected NetworkHelper _networkHelper;
-    protected NicProfileHelper _nicProfileHelper;
 
     public RuleApplier(final Network network) {
         _network = network;
     }
 
-    public abstract boolean accept(NetworkTopologyVisitor visitor, VirtualRouter router) throws ResourceUnavailableException;
-
     public Network getNetwork() {
         return _network;
     }
@@ -83,4 +39,7 @@ public abstract class RuleApplier {
     public VirtualRouter getRouter() {
         return _router;
     }
+
+    public abstract boolean accept(NetworkTopologyVisitor visitor, VirtualRouter router) throws ResourceUnavailableException;
+
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/SshKeyToRouterRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/SshKeyToRouterRules.java b/server/src/com/cloud/network/rules/SshKeyToRouterRules.java
index 4e4b8ba..9a924e1 100644
--- a/server/src/com/cloud/network/rules/SshKeyToRouterRules.java
+++ b/server/src/com/cloud/network/rules/SshKeyToRouterRules.java
@@ -23,10 +23,13 @@ import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.storage.VMTemplateVO;
+import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.vm.dao.UserVmDao;
 
 public class SshKeyToRouterRules extends RuleApplier {
 
@@ -49,12 +52,17 @@ public class SshKeyToRouterRules extends RuleApplier {
     @Override
     public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
         _router = router;
-        _userVM = _userVmDao.findById(_profile.getVirtualMachine().getId());
-        _userVmDao.loadDetails(_userVM);
 
-        _nicVo = _nicDao.findById(_nic.getId());
+        UserVmDao userVmDao = visitor.getVirtualNetworkApplianceFactory().getUserVmDao();
+        _userVM = userVmDao.findById(_profile.getVirtualMachine().getId());
+
+        userVmDao.loadDetails(_userVM);
+
+        NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
+        _nicVo = nicDao.findById(_nic.getId());
         // for basic zone, send vm data/password information only to the router in the same pod
-        _template = _templateDao.findByIdIncludingRemoved(_profile.getTemplateId());
+        VMTemplateDao templateDao = visitor.getVirtualNetworkApplianceFactory().getTemplateDao();
+        _template = templateDao.findByIdIncludingRemoved(_profile.getTemplateId());
 
         return visitor.visit(this);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/UserdataPwdRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/UserdataPwdRules.java b/server/src/com/cloud/network/rules/UserdataPwdRules.java
index 9d7ef15..62774d4 100644
--- a/server/src/com/cloud/network/rules/UserdataPwdRules.java
+++ b/server/src/com/cloud/network/rules/UserdataPwdRules.java
@@ -27,6 +27,8 @@ import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.vm.dao.UserVmDao;
 
 public class UserdataPwdRules extends RuleApplier {
 
@@ -49,11 +51,13 @@ public class UserdataPwdRules extends RuleApplier {
     public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
         _router = router;
 
-        _userVM = _userVmDao.findById(_profile.getId());
-        _userVmDao.loadDetails(_userVM);
+        UserVmDao userVmDao = visitor.getVirtualNetworkApplianceFactory().getUserVmDao();
+        _userVM = userVmDao.findById(_profile.getId());
+        userVmDao.loadDetails(_userVM);
 
         //for basic zone, send vm data/password information only to the router in the same pod
-        _nicVo = _nicDao.findById(_nic.getId());
+        NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
+        _nicVo = nicDao.findById(_nic.getId());
 
         return visitor.visit(this);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/UserdataToRouterRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/UserdataToRouterRules.java b/server/src/com/cloud/network/rules/UserdataToRouterRules.java
index 477342d..e47dc7f 100644
--- a/server/src/com/cloud/network/rules/UserdataToRouterRules.java
+++ b/server/src/com/cloud/network/rules/UserdataToRouterRules.java
@@ -26,6 +26,8 @@ import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.UserVmVO;
 import com.cloud.vm.VirtualMachineProfile;
+import com.cloud.vm.dao.NicDao;
+import com.cloud.vm.dao.UserVmDao;
 
 public class UserdataToRouterRules extends RuleApplier {
 
@@ -46,11 +48,13 @@ public class UserdataToRouterRules extends RuleApplier {
     public boolean accept(final NetworkTopologyVisitor visitor, final VirtualRouter router) throws ResourceUnavailableException {
         _router = router;
 
-        _userVM = _userVmDao.findById(_profile.getVirtualMachine().getId());
-        _userVmDao.loadDetails(_userVM);
+        UserVmDao userVmDao = visitor.getVirtualNetworkApplianceFactory().getUserVmDao();
+        _userVM = userVmDao.findById(_profile.getVirtualMachine().getId());
+        userVmDao.loadDetails(_userVM);
 
         // for basic zone, send vm data/password information only to the router in the same pod
-        _nicVo = _nicDao.findById(_nic.getId());
+        NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
+        _nicVo = nicDao.findById(_nic.getId());
 
         return visitor.visit(this);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java b/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
index 5a551f0..e775fb1 100644
--- a/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
+++ b/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
@@ -16,39 +16,26 @@
 // under the License.
 package com.cloud.network.rules;
 
-import java.util.List;
-
 import javax.inject.Inject;
 
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.HostPodDao;
 import com.cloud.dc.dao.VlanDao;
-import com.cloud.deploy.DeployDestination;
 import com.cloud.network.IpAddressManager;
-import com.cloud.network.Network;
 import com.cloud.network.NetworkModel;
-import com.cloud.network.PublicIpAddress;
-import com.cloud.network.RemoteAccessVpn;
-import com.cloud.network.VpnUser;
 import com.cloud.network.dao.IPAddressDao;
 import com.cloud.network.dao.LoadBalancerDao;
 import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.lb.LoadBalancingRule;
 import com.cloud.network.lb.LoadBalancingRulesManager;
 import com.cloud.network.router.NetworkHelper;
 import com.cloud.network.router.NicProfileHelper;
-import com.cloud.network.vpc.NetworkACLItem;
 import com.cloud.network.vpc.NetworkACLManager;
-import com.cloud.network.vpc.PrivateGateway;
-import com.cloud.network.vpc.StaticRouteProfile;
 import com.cloud.network.vpc.VpcManager;
 import com.cloud.network.vpc.dao.PrivateIpDao;
 import com.cloud.network.vpc.dao.VpcDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.user.dao.UserStatisticsDao;
-import com.cloud.vm.NicProfile;
 import com.cloud.vm.VirtualMachineManager;
-import com.cloud.vm.VirtualMachineProfile;
 import com.cloud.vm.dao.NicDao;
 import com.cloud.vm.dao.NicIpAliasDao;
 import com.cloud.vm.dao.UserVmDao;
@@ -98,196 +85,87 @@ public class VirtualNetworkApplianceFactory {
     @Inject
     private NicProfileHelper _nicProfileHelper;
 
-    public LoadBalancingRules createLoadBalancingRules(final Network network, final List<LoadBalancingRule> rules) {
-        LoadBalancingRules lbRules = new LoadBalancingRules(network, rules);
-
-        initBeans(lbRules);
-
-        return lbRules;
+    public NetworkModel getNetworkModel() {
+        return _networkModel;
     }
 
-    public FirewallRules createFirewallRules(final Network network, final List<? extends FirewallRule> rules) {
-        FirewallRules fwRules = new FirewallRules(network, rules);
-
-        initBeans(fwRules);
-
-        fwRules._networkDao = _networkDao;
-
-        return fwRules;
+    public LoadBalancingRulesManager getLbMgr() {
+        return _lbMgr;
     }
 
-    public StaticNatRules createStaticNatRules(final Network network, final List<? extends StaticNat> rules) {
-        StaticNatRules natRules = new StaticNatRules(network, rules);
-
-        initBeans(natRules);
-
-        return natRules;
+    public LoadBalancerDao getLoadBalancerDao() {
+        return _loadBalancerDao;
     }
 
-    private void initBeans(final RuleApplier applier) {
-        applier._networkModel = _networkModel;
-        applier._dcDao = _dcDao;
-        applier._lbMgr = _lbMgr;
-        applier._loadBalancerDao = _loadBalancerDao;
-        applier._nicDao = _nicDao;
-        applier._itMgr = _itMgr;
-        applier._networkHelper = _networkHelper;
+    public NicDao getNicDao() {
+        return _nicDao;
     }
 
-    public IpAssociationRules createIpAssociationRules(final Network network, final List<? extends PublicIpAddress> ipAddresses) {
-        IpAssociationRules ipAssociationRules = new IpAssociationRules(network, ipAddresses);
-
-        initBeans(ipAssociationRules);
-
-        ipAssociationRules._networkDao = _networkDao;
-
-        return ipAssociationRules;
+    public VirtualMachineManager getItMgr() {
+        return _itMgr;
     }
 
-    public VpcIpAssociationRules createVpcIpAssociationRules(final Network network, final List<? extends PublicIpAddress> ipAddresses) {
-        VpcIpAssociationRules ipAssociationRules = new VpcIpAssociationRules(network, ipAddresses);
-
-        initBeans(ipAssociationRules);
-
-        ipAssociationRules._networkDao = _networkDao;
-
-        return ipAssociationRules;
+    public DataCenterDao getDcDao() {
+        return _dcDao;
     }
 
-    public VpnRules createVpnRules(final Network network, final List<? extends VpnUser> users) {
-        VpnRules vpnRules = new VpnRules(network, users);
-
-        initBeans(vpnRules);
-
-        return vpnRules;
+    public UserVmDao getUserVmDao() {
+        return _userVmDao;
     }
 
-    public PasswordToRouterRules createPasswordToRouterRules(final Network network, final NicProfile nic, final VirtualMachineProfile profile) {
-        PasswordToRouterRules routerRules = new PasswordToRouterRules(network, nic, profile);
-
-        initBeans(routerRules);
-
-        routerRules._userVmDao = _userVmDao;
-
-        return routerRules;
+    public UserStatisticsDao getUserStatsDao() {
+        return _userStatsDao;
     }
 
-    public SshKeyToRouterRules createSshKeyToRouterRules(final Network network, final NicProfile nic, final VirtualMachineProfile profile, final String sshKey) {
-        SshKeyToRouterRules sshKeyToRouterRules = new SshKeyToRouterRules(network, nic, profile, sshKey);
-
-        initBeans(sshKeyToRouterRules);
-
-        sshKeyToRouterRules._userVmDao = _userVmDao;
-        sshKeyToRouterRules._templateDao = _templateDao;
-
-        return sshKeyToRouterRules;
+    public VpcDao getVpcDao() {
+        return _vpcDao;
     }
 
-    public UserdataToRouterRules createUserdataToRouterRules(final Network network, final NicProfile nic, final VirtualMachineProfile profile) {
-        UserdataToRouterRules userdataRules = new UserdataToRouterRules(network, nic, profile);
-
-        initBeans(userdataRules);
-
-        userdataRules._userVmDao = _userVmDao;
-        userdataRules._templateDao = _templateDao;
-
-        return userdataRules;
+    public VpcManager getVpcMgr() {
+        return _vpcMgr;
     }
 
-    public UserdataPwdRules createUserdataPwdRules(final Network network, final NicProfile nic, final VirtualMachineProfile profile, final DeployDestination destination) {
-        UserdataPwdRules userdataRules = new UserdataPwdRules(network, nic, profile, destination);
-
-        initBeans(userdataRules);
-
-        userdataRules._userVmDao = _userVmDao;
-        userdataRules._templateDao = _templateDao;
-
-        return userdataRules;
+    public VMTemplateDao getTemplateDao() {
+        return _templateDao;
     }
 
-    public DhcpEntryRules createDhcpEntryRules(final Network network, final NicProfile nic, final VirtualMachineProfile profile, final DeployDestination destination) {
-        DhcpEntryRules dhcpRules = new DhcpEntryRules(network, nic, profile, destination);
-
-        initBeans(dhcpRules);
-
-        dhcpRules._userVmDao = _userVmDao;
-        dhcpRules._networkDao = _networkDao;
-
-        return dhcpRules;
+    public NetworkDao getNetworkDao() {
+        return _networkDao;
     }
 
-    public NicPlugInOutRules createNicPluInOutRules(final Network network, final List<? extends PublicIpAddress> ipAddresses) {
-        NicPlugInOutRules nicPlug = new NicPlugInOutRules(network, ipAddresses);
-
-        initBeans(nicPlug);
-
-        nicPlug._vpcDao = _vpcDao;
-        nicPlug._userStatsDao = _userStatsDao;
-        nicPlug._vpcMgr = _vpcMgr;
-
-        return nicPlug;
+    public NicIpAliasDao getNicIpAliasDao() {
+        return _nicIpAliasDao;
     }
 
-    public NetworkAclsRules createNetworkAclRules(final Network network, final List<? extends NetworkACLItem> rules, final boolean isPrivateGateway) {
-        NetworkAclsRules networkAclsRules = new NetworkAclsRules(network, rules, isPrivateGateway);
-
-        initBeans(networkAclsRules);
-
-        return networkAclsRules;
+    public HostPodDao getPodDao() {
+        return _podDao;
     }
 
-    public DhcpSubNetRules createDhcpSubNetRules(final Network network, final NicProfile nic, final VirtualMachineProfile profile) {
-        DhcpSubNetRules subNetRules = new DhcpSubNetRules(network, nic, profile);
-
-        initBeans(subNetRules);
-
-        subNetRules._vpcDao = _vpcDao;
-        subNetRules._userVmDao = _userVmDao;
-        subNetRules._podDao = _podDao;
-        subNetRules._vlanDao = _vlanDao;
-        subNetRules._nicIpAliasDao = _nicIpAliasDao;
-        subNetRules._ipAddrMgr = _ipAddrMgr;
-        subNetRules._ipAddressDao = _ipAddressDao;
-
-        return subNetRules;
+    public VlanDao getVlanDao() {
+        return _vlanDao;
     }
 
-    public DhcpPvlanRules createDhcpPvlanRules(final boolean isAddPvlan, final NicProfile nic) {
-        DhcpPvlanRules pvlanRules = new DhcpPvlanRules(isAddPvlan, nic);
-
-        initBeans(pvlanRules);
-
-        pvlanRules._networkDao = _networkDao;
-
-        return pvlanRules;
+    public IPAddressDao getIpAddressDao() {
+        return _ipAddressDao;
     }
 
-    public StaticRoutesRules createStaticRoutesRules(final List<StaticRouteProfile> staticRoutes) {
-        StaticRoutesRules routesRules = new StaticRoutesRules(staticRoutes);
-        initBeans(routesRules);
-
-        return routesRules;
+    public PrivateIpDao getPrivateIpDao() {
+        return _privateIpDao;
     }
 
-    public AdvancedVpnRules createAdvancedVpnRules(final RemoteAccessVpn remoteAccessVpn, final List<? extends VpnUser> users) {
-        AdvancedVpnRules vpnRules = new AdvancedVpnRules(remoteAccessVpn, users);
-
-        initBeans(vpnRules);
-        vpnRules._vpcDao = _vpcDao;
-
-        return vpnRules;
+    public IpAddressManager getIpAddrMgr() {
+        return _ipAddrMgr;
     }
 
-    public PrivateGatewayRules createPrivateGatewayRules(final PrivateGateway gateway) {
-        PrivateGatewayRules gwRules = new PrivateGatewayRules(gateway);
-
-        initBeans(gwRules);
+    public NetworkACLManager getNetworkACLMgr() {
+        return _networkACLMgr;
+    }
 
-        gwRules._privateIpDao = _privateIpDao;
-        gwRules._networkACLMgr = _networkACLMgr;
-        gwRules._nicProfileHelper = _nicProfileHelper;
-        gwRules._networkDao = _networkDao;
+    public NetworkHelper getNetworkHelper() {
+        return _networkHelper;
+    }
 
-        return gwRules;
+    public NicProfileHelper getNicProfileHelper() {
+        return _nicProfileHelper;
     }
-}
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/com/cloud/network/rules/VpcIpAssociationRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/VpcIpAssociationRules.java b/server/src/com/cloud/network/rules/VpcIpAssociationRules.java
index bd5e6da..4f4a440 100644
--- a/server/src/com/cloud/network/rules/VpcIpAssociationRules.java
+++ b/server/src/com/cloud/network/rules/VpcIpAssociationRules.java
@@ -33,6 +33,7 @@ import com.cloud.network.PublicIpAddress;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.Nic;
+import com.cloud.vm.dao.NicDao;
 
 public class VpcIpAssociationRules extends RuleApplier {
 
@@ -56,9 +57,10 @@ public class VpcIpAssociationRules extends RuleApplier {
         _vlanMacAddress = new HashMap<String, String>();
         _ipsToSend = new ArrayList<PublicIpAddress>();
 
+        NicDao nicDao = visitor.getVirtualNetworkApplianceFactory().getNicDao();
         for (PublicIpAddress ipAddr : _ipAddresses) {
             String broadcastURI = BroadcastDomainType.Vlan.toUri(ipAddr.getVlanTag()).toString();
-            Nic nic = _nicDao.findByNetworkIdInstanceIdAndBroadcastUri(ipAddr.getNetworkId(), _router.getId(), broadcastURI);
+            Nic nic = nicDao.findByNetworkIdInstanceIdAndBroadcastUri(ipAddr.getNetworkId(), _router.getId(), broadcastURI);
 
             String macAddress = null;
             if (nic == null) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
index 053de7a..b9e3ad6 100644
--- a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
+++ b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
@@ -71,7 +71,7 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
 
         s_logger.debug("APPLYING ADVANCED VPN USERS RULES");
 
-        AdvancedVpnRules routesRules = _virtualNetworkApplianceFactory.createAdvancedVpnRules(remoteAccessVpn, users);
+        AdvancedVpnRules routesRules = new AdvancedVpnRules(remoteAccessVpn, users);
 
         boolean agentResult = routesRules.accept(_advancedVisitor, router);
 
@@ -95,7 +95,7 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
             return true;
         }
 
-        StaticRoutesRules routesRules = _virtualNetworkApplianceFactory.createStaticRoutesRules(staticRoutes);
+        StaticRoutesRules routesRules = new StaticRoutesRules(staticRoutes);
 
         boolean result = true;
         for (VirtualRouter router : routers) {
@@ -124,7 +124,7 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
             return false;
         }
 
-        DhcpPvlanRules pvlanRules = _virtualNetworkApplianceFactory.createDhcpPvlanRules(isAddPvlan, nic);
+        DhcpPvlanRules pvlanRules = new DhcpPvlanRules(isAddPvlan, nic);
 
         return pvlanRules.accept(_advancedVisitor, router);
     }
@@ -142,7 +142,7 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
             throw new ResourceUnavailableException("Unable to assign ip addresses, domR is not in right state " + router.getState(), DataCenter.class, network.getDataCenterId());
         }
 
-        DhcpSubNetRules subNetRules = _virtualNetworkApplianceFactory.createDhcpSubNetRules(network, nic, profile);
+        DhcpSubNetRules subNetRules = new DhcpSubNetRules(network, nic, profile);
 
         return subNetRules.accept(_advancedVisitor, router);
     }
@@ -151,7 +151,7 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
     public boolean setupPrivateGateway(final PrivateGateway gateway, final VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
         s_logger.debug("SETUP PRIVATE GATEWAY RULES");
 
-        PrivateGatewayRules routesRules = _virtualNetworkApplianceFactory.createPrivateGatewayRules(gateway);
+        PrivateGatewayRules routesRules = new PrivateGatewayRules(gateway);
 
         return routesRules.accept(_advancedVisitor, router);
     }
@@ -167,7 +167,7 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
         final boolean failWhenDisconnect = false;
         final Long podId = null;
 
-        UserdataPwdRules pwdRules = _virtualNetworkApplianceFactory.createUserdataPwdRules(network, nic, profile, dest);
+        UserdataPwdRules pwdRules = new UserdataPwdRules(network, nic, profile, dest);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(pwdRules));
     }
@@ -183,7 +183,7 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
         final boolean isPodLevelException = false;
         final boolean failWhenDisconnect = false;
 
-        DhcpEntryRules dhcpRules = _virtualNetworkApplianceFactory.createDhcpEntryRules(network, nic, profile, dest);
+        DhcpEntryRules dhcpRules = new DhcpEntryRules(network, nic, profile, dest);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(dhcpRules));
     }
@@ -211,10 +211,10 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
         final boolean failWhenDisconnect = false;
         final Long podId = null;
 
-        NicPlugInOutRules nicPlugInOutRules = _virtualNetworkApplianceFactory.createNicPluInOutRules(network, ipAddresses);
+        NicPlugInOutRules nicPlugInOutRules = new NicPlugInOutRules(network, ipAddresses);
         nicPlugInOutRules.accept(_advancedVisitor, router);
 
-        VpcIpAssociationRules ipAssociationRules = _virtualNetworkApplianceFactory.createVpcIpAssociationRules(network, ipAddresses);
+        VpcIpAssociationRules ipAssociationRules = new VpcIpAssociationRules(network, ipAddresses);
         boolean result = applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(ipAssociationRules));
 
         if (result) {
@@ -240,7 +240,7 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
         final boolean failWhenDisconnect = false;
         final Long podId = null;
 
-        NetworkAclsRules aclsRules = _virtualNetworkApplianceFactory.createNetworkAclRules(network, rules, isPrivateGateway);
+        NetworkAclsRules aclsRules = new NetworkAclsRules(network, rules, isPrivateGateway);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(aclsRules));
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
index 7d08813..0e265a3 100644
--- a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
+++ b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
@@ -137,8 +137,8 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
 
         if (router.getState() == State.Running) {
 
-            PrivateIpVO ipVO = privateGW.retrivePrivateIP();
-            Network network = privateGW.retrievePrivateNetwork();
+            PrivateIpVO ipVO = privateGW.retrivePrivateIP(this);
+            Network network = privateGW.retrievePrivateNetwork(this);
 
             String netmask = NetUtils.getCidrNetmask(network.getCidr());
             PrivateIpAddress ip = new PrivateIpAddress(ipVO, network.getBroadcastUri().toString(), network.getGateway(), netmask, nicProfile.getMacAddress());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java b/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
index 8560d36..d35e7f3 100644
--- a/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
+++ b/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
@@ -58,7 +58,6 @@ import com.cloud.network.rules.StaticNat;
 import com.cloud.network.rules.StaticNatRules;
 import com.cloud.network.rules.UserdataPwdRules;
 import com.cloud.network.rules.UserdataToRouterRules;
-import com.cloud.network.rules.VirtualNetworkApplianceFactory;
 import com.cloud.network.rules.VpnRules;
 import com.cloud.network.vpc.NetworkACLItem;
 import com.cloud.network.vpc.PrivateGateway;
@@ -77,9 +76,6 @@ public class BasicNetworkTopology implements NetworkTopology {
 
     private static final Logger s_logger = Logger.getLogger(BasicNetworkTopology.class);
 
-    @Inject
-    protected VirtualNetworkApplianceFactory _virtualNetworkApplianceFactory;
-
     @Autowired
     @Qualifier("basicNetworkVisitor")
     protected BasicNetworkVisitor _basicVisitor;
@@ -160,7 +156,7 @@ public class BasicNetworkTopology implements NetworkTopology {
 
         final boolean failWhenDisconnect = false;
 
-        DhcpEntryRules dhcpRules = _virtualNetworkApplianceFactory.createDhcpEntryRules(network, nic, profile, dest);
+        DhcpEntryRules dhcpRules = new DhcpEntryRules(network, nic, profile, dest);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(dhcpRules));
     }
@@ -182,7 +178,7 @@ public class BasicNetworkTopology implements NetworkTopology {
 
         final boolean failWhenDisconnect = false;
 
-        UserdataPwdRules pwdRules = _virtualNetworkApplianceFactory.createUserdataPwdRules(network, nic, profile, dest);
+        UserdataPwdRules pwdRules = new UserdataPwdRules(network, nic, profile, dest);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(pwdRules));
     }
@@ -203,7 +199,7 @@ public class BasicNetworkTopology implements NetworkTopology {
         final boolean failWhenDisconnect = false;
         final Long podId = null;
 
-        LoadBalancingRules loadBalancingRules = _virtualNetworkApplianceFactory.createLoadBalancingRules(network, rules);
+        LoadBalancingRules loadBalancingRules = new LoadBalancingRules(network, rules);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(loadBalancingRules));
     }
@@ -223,7 +219,7 @@ public class BasicNetworkTopology implements NetworkTopology {
         final boolean failWhenDisconnect = false;
         final Long podId = null;
 
-        FirewallRules firewallRules = _virtualNetworkApplianceFactory.createFirewallRules(network, rules);
+        FirewallRules firewallRules = new FirewallRules(network, rules);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(firewallRules));
     }
@@ -242,7 +238,7 @@ public class BasicNetworkTopology implements NetworkTopology {
         final boolean failWhenDisconnect = false;
         final Long podId = null;
 
-        StaticNatRules natRules = _virtualNetworkApplianceFactory.createStaticNatRules(network, rules);
+        StaticNatRules natRules = new StaticNatRules(network, rules);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(natRules));
     }
@@ -262,7 +258,7 @@ public class BasicNetworkTopology implements NetworkTopology {
         final boolean failWhenDisconnect = false;
         final Long podId = null;
 
-        IpAssociationRules ipAddresses = _virtualNetworkApplianceFactory.createIpAssociationRules(network, ipAddress);
+        IpAssociationRules ipAddresses = new IpAssociationRules(network, ipAddress);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(ipAddresses));
     }
@@ -276,6 +272,7 @@ public class BasicNetworkTopology implements NetworkTopology {
 
         s_logger.debug("APPLYING VPN RULES");
 
+        BasicVpnRules vpnRules = new BasicVpnRules(network, users);
         boolean agentResults = true;
 
         for (final DomainRouterVO router : routers) {
@@ -319,7 +316,7 @@ public class BasicNetworkTopology implements NetworkTopology {
         final boolean failWhenDisconnect = false;
         final Long podId = null;
 
-        PasswordToRouterRules routerRules = _virtualNetworkApplianceFactory.createPasswordToRouterRules(network, nic, profile);
+        PasswordToRouterRules routerRules = new PasswordToRouterRules(network, nic, profile);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(routerRules));
     }
@@ -334,7 +331,7 @@ public class BasicNetworkTopology implements NetworkTopology {
         final boolean failWhenDisconnect = false;
         final Long podId = null;
 
-        SshKeyToRouterRules keyToRouterRules = _virtualNetworkApplianceFactory.createSshKeyToRouterRules(network, nic, profile, sshPublicKey);
+        SshKeyToRouterRules keyToRouterRules = new SshKeyToRouterRules(network, nic, profile, sshPublicKey);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(keyToRouterRules));
     }
@@ -349,7 +346,7 @@ public class BasicNetworkTopology implements NetworkTopology {
         final boolean failWhenDisconnect = false;
         final Long podId = null;
 
-        UserdataToRouterRules userdataToRouterRules = _virtualNetworkApplianceFactory.createUserdataToRouterRules(network, nic, profile);
+        UserdataToRouterRules userdataToRouterRules = new UserdataToRouterRules(network, nic, profile);
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(userdataToRouterRules));
     }
@@ -420,7 +417,8 @@ public class BasicNetworkTopology implements NetworkTopology {
         if (!connectedRouters.isEmpty()) {
             // Shouldn't we include this check inside the method?
             if (!isZoneBasic && !disconnectedRouters.isEmpty() && disconnectedRouters.get(0).getIsRedundantRouter()) {
-                // These disconnected redundant virtual routers are out of sync now, stop them for synchronization
+                // These disconnected redundant virtual routers are out of sync
+                // now, stop them for synchronization
                 _networkHelper.handleSingleWorkingRedundantRouter(connectedRouters, disconnectedRouters, msg);
             }
         } else if (!disconnectedRouters.isEmpty()) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/org/apache/cloudstack/network/topology/BasicNetworkVisitor.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/topology/BasicNetworkVisitor.java b/server/src/org/apache/cloudstack/network/topology/BasicNetworkVisitor.java
index a3ef1ee..db0b6e5 100644
--- a/server/src/org/apache/cloudstack/network/topology/BasicNetworkVisitor.java
+++ b/server/src/org/apache/cloudstack/network/topology/BasicNetworkVisitor.java
@@ -54,6 +54,7 @@ import com.cloud.network.rules.StaticNatRules;
 import com.cloud.network.rules.StaticRoutesRules;
 import com.cloud.network.rules.UserdataPwdRules;
 import com.cloud.network.rules.UserdataToRouterRules;
+import com.cloud.network.rules.VirtualNetworkApplianceFactory;
 import com.cloud.network.rules.VpcIpAssociationRules;
 import com.cloud.storage.VMTemplateVO;
 import com.cloud.utils.exception.CloudRuntimeException;
@@ -75,9 +76,17 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
     protected NetworkHelper _networkGeneralHelper;
 
     @Inject
+    protected VirtualNetworkApplianceFactory _virtualNetworkApplianceFactory;
+
+    @Inject
     protected CommandSetupHelper _commandSetupHelper;
 
     @Override
+    public VirtualNetworkApplianceFactory getVirtualNetworkApplianceFactory() {
+        return _virtualNetworkApplianceFactory;
+    }
+
+    @Override
     public boolean visit(final StaticNatRules nat) throws ResourceUnavailableException {
         final Network network = nat.getNetwork();
         final VirtualRouter router = nat.getRouter();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/9f801d1f/server/src/org/apache/cloudstack/network/topology/NetworkTopologyVisitor.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/topology/NetworkTopologyVisitor.java b/server/src/org/apache/cloudstack/network/topology/NetworkTopologyVisitor.java
index c4f3af5..621ec8a 100644
--- a/server/src/org/apache/cloudstack/network/topology/NetworkTopologyVisitor.java
+++ b/server/src/org/apache/cloudstack/network/topology/NetworkTopologyVisitor.java
@@ -32,16 +32,13 @@ import com.cloud.network.rules.StaticNatRules;
 import com.cloud.network.rules.StaticRoutesRules;
 import com.cloud.network.rules.UserdataPwdRules;
 import com.cloud.network.rules.UserdataToRouterRules;
+import com.cloud.network.rules.VirtualNetworkApplianceFactory;
 import com.cloud.network.rules.VpcIpAssociationRules;
 import com.cloud.network.rules.VpnRules;
 
 public abstract class NetworkTopologyVisitor {
 
-    protected final NetworkTopology networkTopology;
-
-    public NetworkTopologyVisitor(final NetworkTopology networkTopology) {
-        this.networkTopology = networkTopology;
-    }
+    public abstract VirtualNetworkApplianceFactory getVirtualNetworkApplianceFactory();
 
     public abstract boolean visit(StaticNatRules nat) throws ResourceUnavailableException;
 
@@ -74,5 +71,6 @@ public abstract class NetworkTopologyVisitor {
     public abstract boolean visit(DhcpSubNetRules subnet) throws ResourceUnavailableException;
 
     public abstract boolean visit(NicPlugInOutRules nicPlugInOutRules) throws ResourceUnavailableException;
+
     public abstract boolean visit(StaticRoutesRules staticRoutesRules) throws ResourceUnavailableException;
 }
\ No newline at end of file


Mime
View raw message