cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject [40/50] [abbrv] refactor all private methods in the virtual router appliance and VPC appliance
Date Fri, 03 Oct 2014 11:12:18 GMT
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/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 c62f862..1d13efb 100644
--- a/server/src/com/cloud/network/rules/PrivateGatewayRules.java
+++ b/server/src/com/cloud/network/rules/PrivateGatewayRules.java
@@ -17,27 +17,15 @@
 
 package com.cloud.network.rules;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 import org.apache.log4j.Logger;
 
-import com.cloud.agent.api.routing.IpAssocVpcCommand;
-import com.cloud.agent.api.routing.NetworkElementCommand;
-import com.cloud.agent.api.to.IpAddressTO;
-import com.cloud.agent.manager.Commands;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.vpc.PrivateGateway;
-import com.cloud.network.vpc.PrivateIpAddress;
 import com.cloud.network.vpc.PrivateIpVO;
-import com.cloud.user.Account;
 import com.cloud.vm.NicProfile;
 
 public class PrivateGatewayRules extends RuleApplier {
@@ -142,47 +130,4 @@ public class PrivateGatewayRules extends RuleApplier {
         s_logger.debug("Private gateawy " + _privateGateway + " is removed from router " + _router);
         return result;
     }
-
-    public void createVpcAssociatePrivateIPCommands(final VirtualRouter router, final List<PrivateIpAddress> ips, final Commands cmds, final boolean add) {
-
-        // Ensure that in multiple vlans case we first send all ip addresses of vlan1, then all ip addresses of vlan2, etc..
-        Map<String, ArrayList<PrivateIpAddress>> vlanIpMap = new HashMap<String, ArrayList<PrivateIpAddress>>();
-        for (final PrivateIpAddress ipAddress : ips) {
-            String vlanTag = ipAddress.getBroadcastUri();
-            ArrayList<PrivateIpAddress> ipList = vlanIpMap.get(vlanTag);
-            if (ipList == null) {
-                ipList = new ArrayList<PrivateIpAddress>();
-            }
-
-            ipList.add(ipAddress);
-            vlanIpMap.put(vlanTag, ipList);
-        }
-
-        for (Map.Entry<String, ArrayList<PrivateIpAddress>> vlanAndIp : vlanIpMap.entrySet()) {
-            List<PrivateIpAddress> ipAddrList = vlanAndIp.getValue();
-            IpAddressTO[] ipsToSend = new IpAddressTO[ipAddrList.size()];
-            int i = 0;
-
-            for (final PrivateIpAddress ipAddr : ipAddrList) {
-                Network network = _networkModel.getNetwork(ipAddr.getNetworkId());
-                IpAddressTO ip =
-                        new IpAddressTO(Account.ACCOUNT_ID_SYSTEM, ipAddr.getIpAddress(), add, false, ipAddr.getSourceNat(), ipAddr.getBroadcastUri(), ipAddr.getGateway(),
-                                ipAddr.getNetmask(), ipAddr.getMacAddress(), null, false);
-
-                ip.setTrafficType(network.getTrafficType());
-                ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
-                ipsToSend[i++] = ip;
-
-            }
-
-            IpAssocVpcCommand cmd = new IpAssocVpcCommand(ipsToSend);
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(ipAddrList.get(0).getNetworkId(), router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-            DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
-            cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-
-            cmds.addCommand("IPAssocVpcCommand", cmd);
-        }
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/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 c6f1cc0..4c399ed 100644
--- a/server/src/com/cloud/network/rules/RuleApplier.java
+++ b/server/src/com/cloud/network/rules/RuleApplier.java
@@ -17,14 +17,8 @@
 
 package com.cloud.network.rules;
 
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
 import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 
-import com.cloud.agent.api.routing.NetworkElementCommand;
-import com.cloud.agent.api.routing.VmDataCommand;
-import com.cloud.agent.manager.Commands;
-import com.cloud.dc.DataCenter.NetworkType;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.HostPodDao;
 import com.cloud.dc.dao.VlanDao;
@@ -32,29 +26,20 @@ 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.FirewallRulesDao;
 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.RouterControlHelper;
 import com.cloud.network.router.VirtualRouter;
-import com.cloud.network.router.VpcNetworkHelperImpl;
 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.offerings.dao.NetworkOfferingDao;
-import com.cloud.service.dao.ServiceOfferingDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.user.dao.UserStatisticsDao;
-import com.cloud.uservm.UserVm;
-import com.cloud.utils.StringUtils;
-import com.cloud.vm.NicVO;
 import com.cloud.vm.VirtualMachineManager;
-import com.cloud.vm.dao.DomainRouterDao;
 import com.cloud.vm.dao.NicDao;
 import com.cloud.vm.dao.NicIpAliasDao;
 import com.cloud.vm.dao.UserVmDao;
@@ -62,63 +47,27 @@ import com.cloud.vm.dao.UserVmDao;
 public abstract class RuleApplier {
 
     protected NetworkModel _networkModel;
-
     protected LoadBalancingRulesManager _lbMgr;
-
     protected LoadBalancerDao _loadBalancerDao;
-
-    protected ConfigurationDao _configDao;
-
     protected NicDao _nicDao;
-
-    protected NetworkOfferingDao _networkOfferingDao;
-
     protected DataCenterDao _dcDao;
-
-    protected DomainRouterDao _routerDao;
-
     protected UserVmDao _userVmDao;
-
-    protected ServiceOfferingDao _serviceOfferingDao;
-
     protected VMTemplateDao _templateDao;
-
     protected NetworkDao _networkDao;
-
-    protected FirewallRulesDao _rulesDao;
-
     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 RouterControlHelper _routerControlHelper;
-
     protected NetworkHelper _networkHelper;
-
-    protected VpcNetworkHelperImpl _vpcNetworkHelper;
-
     protected NicProfileHelper _nicProfileHelper;
 
     public RuleApplier(final Network network) {
@@ -134,69 +83,4 @@ public abstract class RuleApplier {
     public VirtualRouter getRouter() {
         return _router;
     }
-
-    public void createVmDataCommand(final VirtualRouter router, final UserVm vm, final NicVO nic, final String publicKey, final Commands cmds) {
-        final String serviceOffering = _serviceOfferingDao.findByIdIncludingRemoved(vm.getId(), vm.getServiceOfferingId()).getDisplayText();
-        final String zoneName = _dcDao.findById(router.getDataCenterId()).getName();
-        cmds.addCommand(
-                "vmdata",
-                generateVmDataCommand(router, nic.getIp4Address(), vm.getUserData(), serviceOffering, zoneName, nic.getIp4Address(), vm.getHostName(), vm.getInstanceName(),
-                        vm.getId(), vm.getUuid(), publicKey, nic.getNetworkId()));
-    }
-
-    public VmDataCommand generateVmDataCommand(final VirtualRouter router, final String vmPrivateIpAddress, final String userData, final String serviceOffering,
-            final String zoneName, final String guestIpAddress, final String vmName, final String vmInstanceName, final long vmId, final String vmUuid, final String publicKey,
-            final long guestNetworkId) {
-        final VmDataCommand cmd = new VmDataCommand(vmPrivateIpAddress, vmName, _networkModel.getExecuteInSeqNtwkElmtCmd());
-
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(guestNetworkId, router.getId()));
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-
-        final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
-        cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-
-        cmd.addVmData("userdata", "user-data", userData);
-        cmd.addVmData("metadata", "service-offering", StringUtils.unicodeEscape(serviceOffering));
-        cmd.addVmData("metadata", "availability-zone", StringUtils.unicodeEscape(zoneName));
-        cmd.addVmData("metadata", "local-ipv4", guestIpAddress);
-        cmd.addVmData("metadata", "local-hostname", StringUtils.unicodeEscape(vmName));
-        if (dcVo.getNetworkType() == NetworkType.Basic) {
-            cmd.addVmData("metadata", "public-ipv4", guestIpAddress);
-            cmd.addVmData("metadata", "public-hostname", StringUtils.unicodeEscape(vmName));
-        } else {
-            if (router.getPublicIpAddress() == null) {
-                cmd.addVmData("metadata", "public-ipv4", guestIpAddress);
-            } else {
-                cmd.addVmData("metadata", "public-ipv4", router.getPublicIpAddress());
-            }
-            cmd.addVmData("metadata", "public-hostname", router.getPublicIpAddress());
-        }
-        if (vmUuid == null) {
-            setVmInstanceId(vmInstanceName, vmId, cmd);
-        } else {
-            setVmInstanceId(vmUuid, cmd);
-        }
-        cmd.addVmData("metadata", "public-keys", publicKey);
-
-        String cloudIdentifier = _configDao.getValue("cloud.identifier");
-        if (cloudIdentifier == null) {
-            cloudIdentifier = "";
-        } else {
-            cloudIdentifier = "CloudStack-{" + cloudIdentifier + "}";
-        }
-        cmd.addVmData("metadata", "cloud-identifier", cloudIdentifier);
-
-        return cmd;
-    }
-
-    private void setVmInstanceId(final String vmUuid, final VmDataCommand cmd) {
-        cmd.addVmData("metadata", "instance-id", vmUuid);
-        cmd.addVmData("metadata", "vm-id", vmUuid);
-    }
-
-    private void setVmInstanceId(final String vmInstanceName, final long vmId, final VmDataCommand cmd) {
-        cmd.addVmData("metadata", "instance-id", vmInstanceName);
-        cmd.addVmData("metadata", "vm-id", String.valueOf(vmId));
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/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 c88827a..4e4b8ba 100644
--- a/server/src/com/cloud/network/rules/SshKeyToRouterRules.java
+++ b/server/src/com/cloud/network/rules/SshKeyToRouterRules.java
@@ -19,15 +19,10 @@ package com.cloud.network.rules;
 
 import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 
-import com.cloud.agent.api.routing.NetworkElementCommand;
-import com.cloud.agent.api.routing.SavePasswordCommand;
-import com.cloud.agent.manager.Commands;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.storage.VMTemplateVO;
-import com.cloud.utils.PasswordGenerator;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.UserVmVO;
@@ -64,24 +59,6 @@ public class SshKeyToRouterRules extends RuleApplier {
         return visitor.visit(this);
     }
 
-    public void createPasswordCommand(final VirtualRouter router, final VirtualMachineProfile profile, final NicVO nic, final Commands cmds) {
-        final String password = (String)profile.getParameter(VirtualMachineProfile.Param.VmPassword);
-        final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
-
-        // password should be set only on default network element
-        if (password != null && nic.isDefaultNic()) {
-            final String encodedPassword = PasswordGenerator.rot13(password);
-            final SavePasswordCommand cmd =
-                    new SavePasswordCommand(encodedPassword, nic.getIp4Address(), profile.getVirtualMachine().getHostName(), _networkModel.getExecuteInSeqNtwkElmtCmd());
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(nic.getNetworkId(), router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-            cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-
-            cmds.addCommand("password", cmd);
-        }
-    }
-
     public VirtualMachineProfile getProfile() {
         return _profile;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/server/src/com/cloud/network/rules/StaticNatRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/StaticNatRules.java b/server/src/com/cloud/network/rules/StaticNatRules.java
index dc14c9f..696439c 100644
--- a/server/src/com/cloud/network/rules/StaticNatRules.java
+++ b/server/src/com/cloud/network/rules/StaticNatRules.java
@@ -17,18 +17,11 @@
 
 package com.cloud.network.rules;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 
-import com.cloud.agent.api.routing.NetworkElementCommand;
-import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
-import com.cloud.agent.api.to.StaticNatRuleTO;
-import com.cloud.agent.manager.Commands;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
 import com.cloud.network.router.VirtualRouter;
 
@@ -50,25 +43,4 @@ public class StaticNatRules extends RuleApplier {
         _router = router;
         return visitor.visit(this);
     }
-
-    public void createApplyStaticNatCommands(final List<? extends StaticNat> rules, final VirtualRouter router, final Commands cmds, final long guestNetworkId) {
-        List<StaticNatRuleTO> rulesTO = new ArrayList<StaticNatRuleTO>();
-        if (rules != null) {
-            for (final StaticNat rule : rules) {
-                final IpAddress sourceIp = _networkModel.getIp(rule.getSourceIpAddressId());
-                final StaticNatRuleTO ruleTO =
-                        new StaticNatRuleTO(0, sourceIp.getAddress().addr(), null, null, rule.getDestIpAddress(), null, null, null, rule.isForRevoke(), false);
-                rulesTO.add(ruleTO);
-            }
-        }
-
-        final SetStaticNatRulesCommand cmd = new SetStaticNatRulesCommand(rulesTO, router.getVpcId());
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(guestNetworkId, router.getId()));
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-
-        final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
-        cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-        cmds.addCommand(cmd);
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/server/src/com/cloud/network/rules/StaticRoutesRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/StaticRoutesRules.java b/server/src/com/cloud/network/rules/StaticRoutesRules.java
index b94cea2..2ba0f0c 100644
--- a/server/src/com/cloud/network/rules/StaticRoutesRules.java
+++ b/server/src/com/cloud/network/rules/StaticRoutesRules.java
@@ -21,10 +21,6 @@ import java.util.List;
 
 import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 
-import com.cloud.agent.api.routing.NetworkElementCommand;
-import com.cloud.agent.api.routing.SetStaticRouteCommand;
-import com.cloud.agent.manager.Commands;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.vpc.StaticRouteProfile;
@@ -48,13 +44,4 @@ public class StaticRoutesRules extends RuleApplier {
 
         return visitor.visit(this);
     }
-
-    public void createStaticRouteCommands(final List<StaticRouteProfile> staticRoutes, final VirtualRouter router, final Commands cmds) {
-        SetStaticRouteCommand cmd = new SetStaticRouteCommand(staticRoutes);
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _networkHelper.getRouterControlIp(router.getId()));
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-        DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
-        cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-        cmds.addCommand(cmd);
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/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 ecb2509..9d7ef15 100644
--- a/server/src/com/cloud/network/rules/UserdataPwdRules.java
+++ b/server/src/com/cloud/network/rules/UserdataPwdRules.java
@@ -19,15 +19,10 @@ package com.cloud.network.rules;
 
 import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 
-import com.cloud.agent.api.routing.NetworkElementCommand;
-import com.cloud.agent.api.routing.SavePasswordCommand;
-import com.cloud.agent.manager.Commands;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.deploy.DeployDestination;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
 import com.cloud.network.router.VirtualRouter;
-import com.cloud.utils.PasswordGenerator;
 import com.cloud.vm.NicProfile;
 import com.cloud.vm.NicVO;
 import com.cloud.vm.UserVmVO;
@@ -78,23 +73,4 @@ public class UserdataPwdRules extends RuleApplier {
     public UserVmVO getUserVM() {
         return _userVM;
     }
-
-    public void createPasswordCommand(final VirtualRouter router, final VirtualMachineProfile profile, final NicVO nic, final Commands cmds) {
-        final String password = (String)profile.getParameter(VirtualMachineProfile.Param.VmPassword);
-        final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
-
-        // password should be set only on default network element
-        if (password != null && nic.isDefaultNic()) {
-            final String encodedPassword = PasswordGenerator.rot13(password);
-            final SavePasswordCommand cmd =
-                    new SavePasswordCommand(encodedPassword, nic.getIp4Address(), profile.getVirtualMachine().getHostName(), _networkModel.getExecuteInSeqNtwkElmtCmd());
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(nic.getNetworkId(), router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-            cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-
-            cmds.addCommand("password", cmd);
-        }
-
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/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 52dfc97..5988fbd 100644
--- a/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
+++ b/server/src/com/cloud/network/rules/VirtualNetworkApplianceFactory.java
@@ -20,8 +20,6 @@ import java.util.List;
 
 import javax.inject.Inject;
 
-import org.apache.cloudstack.framework.config.dao.ConfigurationDao;
-
 import com.cloud.dc.dao.DataCenterDao;
 import com.cloud.dc.dao.HostPodDao;
 import com.cloud.dc.dao.VlanDao;
@@ -32,29 +30,25 @@ 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.FirewallRulesDao;
 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.VirtualNetworkApplianceManager;
-import com.cloud.network.router.VpcNetworkHelperImpl;
+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.offerings.dao.NetworkOfferingDao;
-import com.cloud.service.dao.ServiceOfferingDao;
 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.DomainRouterDao;
 import com.cloud.vm.dao.NicDao;
 import com.cloud.vm.dao.NicIpAliasDao;
 import com.cloud.vm.dao.UserVmDao;
@@ -62,82 +56,47 @@ import com.cloud.vm.dao.UserVmDao;
 public class VirtualNetworkApplianceFactory {
 
     @Inject
-    protected NetworkModel _networkModel;
-
+    private NetworkModel _networkModel;
     @Inject
-    protected LoadBalancingRulesManager _lbMgr;
-
+    private LoadBalancingRulesManager _lbMgr;
     @Inject
-    protected LoadBalancerDao _loadBalancerDao;
-
+    private LoadBalancerDao _loadBalancerDao;
     @Inject
-    protected ConfigurationDao _configDao;
-
+    private NicDao _nicDao;
     @Inject
-    protected NicDao _nicDao;
-
+    private VirtualMachineManager _itMgr;
     @Inject
-    protected VirtualMachineManager _itMgr;
-
+    private DataCenterDao _dcDao;
     @Inject
-    protected NetworkOfferingDao _networkOfferingDao;
-
+    private UserVmDao _userVmDao;
     @Inject
-    protected DataCenterDao _dcDao;
-
+    private UserStatisticsDao _userStatsDao;
     @Inject
-    protected UserVmDao _userVmDao;
-
+    private VpcDao _vpcDao;
     @Inject
-    protected UserStatisticsDao _userStatsDao;
-
+    private VpcManager _vpcMgr;
     @Inject
-    protected VpcDao _vpcDao;
-
+    private VMTemplateDao _templateDao;
     @Inject
-    protected VpcManager _vpcMgr;
-
+    private NetworkDao _networkDao;
     @Inject
-    protected ServiceOfferingDao _serviceOfferingDao;
-
+    private NicIpAliasDao _nicIpAliasDao;
     @Inject
-    protected VMTemplateDao _templateDao;
-
+    private HostPodDao _podDao;
     @Inject
-    protected DomainRouterDao _routerDao;
-
-    @Inject
-    protected NetworkDao _networkDao;
-
-    @Inject
-    protected FirewallRulesDao _rulesDao;
-
-    @Inject
-    protected NicIpAliasDao _nicIpAliasDao;
-
-    @Inject
-    protected HostPodDao _podDao;
-
-    @Inject
-    protected VlanDao _vlanDao;
-
+    private VlanDao _vlanDao;
     @Inject
     private IPAddressDao _ipAddressDao;
-
     @Inject
     private PrivateIpDao _privateIpDao;
-
     @Inject
     private IpAddressManager _ipAddrMgr;
-
     @Inject
-    protected VirtualNetworkApplianceManager _applianceManager;
-
+    private NetworkACLManager _networkACLMgr;
     @Inject
     private NetworkHelper _networkHelper;
-
     @Inject
-    private VpcNetworkHelperImpl _vpcNetworkHelper;
+    private NicProfileHelper _nicProfileHelper;
 
     public LoadBalancingRules createLoadBalancingRules(final Network network, final List<LoadBalancingRule> rules) {
         LoadBalancingRules lbRules = new LoadBalancingRules(network, rules);
@@ -153,7 +112,6 @@ public class VirtualNetworkApplianceFactory {
         initBeans(fwRules);
 
         fwRules._networkDao = _networkDao;
-        fwRules._rulesDao = _rulesDao;
 
         return fwRules;
     }
@@ -171,12 +129,8 @@ public class VirtualNetworkApplianceFactory {
         applier._dcDao = _dcDao;
         applier._lbMgr = _lbMgr;
         applier._loadBalancerDao = _loadBalancerDao;
-        applier._configDao = _configDao;
         applier._nicDao = _nicDao;
         applier._itMgr = _itMgr;
-        applier._networkOfferingDao = _networkOfferingDao;
-        applier._routerDao = _routerDao;
-        applier._routerControlHelper = _routerControlHelper;
         applier._networkHelper = _networkHelper;
     }
 
@@ -225,7 +179,6 @@ public class VirtualNetworkApplianceFactory {
 
         sshKeyToRouterRules._userVmDao = _userVmDao;
         sshKeyToRouterRules._templateDao = _templateDao;
-        sshKeyToRouterRules._serviceOfferingDao = _serviceOfferingDao;
 
         return sshKeyToRouterRules;
     }
@@ -237,7 +190,6 @@ public class VirtualNetworkApplianceFactory {
 
         userdataRules._userVmDao = _userVmDao;
         userdataRules._templateDao = _templateDao;
-        userdataRules._serviceOfferingDao = _serviceOfferingDao;
 
         return userdataRules;
     }
@@ -249,7 +201,6 @@ public class VirtualNetworkApplianceFactory {
 
         userdataRules._userVmDao = _userVmDao;
         userdataRules._templateDao = _templateDao;
-        userdataRules._serviceOfferingDao = _serviceOfferingDao;
 
         return userdataRules;
     }
@@ -333,7 +284,7 @@ public class VirtualNetworkApplianceFactory {
 
         gwRules._privateIpDao = _privateIpDao;
         gwRules._networkACLMgr = _networkACLMgr;
-        gwRules._vpcNetworkHelper = _vpcNetworkHelper;
+        gwRules._nicProfileHelper = _nicProfileHelper;
 
         return gwRules;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/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 e3c9bed..6257c46 100644
--- a/server/src/com/cloud/network/rules/VpcIpAssociationRules.java
+++ b/server/src/com/cloud/network/rules/VpcIpAssociationRules.java
@@ -25,19 +25,12 @@ import java.util.Map;
 import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 import org.apache.log4j.Logger;
 
-import com.cloud.agent.api.routing.IpAssocVpcCommand;
-import com.cloud.agent.api.routing.NetworkElementCommand;
-import com.cloud.agent.api.routing.SetSourceNatCommand;
-import com.cloud.agent.api.to.IpAddressTO;
-import com.cloud.agent.manager.Commands;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.IpAddress;
 import com.cloud.network.Network;
 import com.cloud.network.Networks.BroadcastDomainType;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.router.VirtualRouter;
-import com.cloud.utils.Pair;
 import com.cloud.utils.exception.CloudRuntimeException;
 import com.cloud.vm.Nic;
 
@@ -94,74 +87,4 @@ public class VpcIpAssociationRules extends RuleApplier {
     public List<PublicIpAddress> getIpsToSend() {
         return _ipsToSend;
     }
-
-    public void createVpcAssociatePublicIPCommands(final VirtualRouter router, final List<? extends PublicIpAddress> ips, final Commands cmds,
-            final Map<String, String> vlanMacAddress) {
-
-        Pair<IpAddressTO, Long> sourceNatIpAdd = null;
-        Boolean addSourceNat = null;
-        // Ensure that in multiple vlans case we first send all ip addresses of vlan1, then all ip addresses of vlan2, etc..
-        Map<String, ArrayList<PublicIpAddress>> vlanIpMap = new HashMap<String, ArrayList<PublicIpAddress>>();
-        for (final PublicIpAddress ipAddress : ips) {
-            String vlanTag = ipAddress.getVlanTag();
-            ArrayList<PublicIpAddress> ipList = vlanIpMap.get(vlanTag);
-            if (ipList == null) {
-                ipList = new ArrayList<PublicIpAddress>();
-            }
-            //VR doesn't support release for sourceNat IP address; so reset the state
-            if (ipAddress.isSourceNat() && ipAddress.getState() == IpAddress.State.Releasing) {
-                ipAddress.setState(IpAddress.State.Allocated);
-            }
-            ipList.add(ipAddress);
-            vlanIpMap.put(vlanTag, ipList);
-        }
-
-        for (Map.Entry<String, ArrayList<PublicIpAddress>> vlanAndIp : vlanIpMap.entrySet()) {
-            List<PublicIpAddress> ipAddrList = vlanAndIp.getValue();
-
-            // Get network rate - required for IpAssoc
-            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;
-
-            for (final PublicIpAddress ipAddr : ipAddrList) {
-                boolean add = (ipAddr.getState() == IpAddress.State.Releasing ? false : true);
-
-                String macAddress = vlanMacAddress.get(BroadcastDomainType.getValue(BroadcastDomainType.fromString(ipAddr.getVlanTag())));
-
-                IpAddressTO ip =
-                        new IpAddressTO(ipAddr.getAccountId(), ipAddr.getAddress().addr(), add, false, ipAddr.isSourceNat(), ipAddr.getVlanTag(), ipAddr.getGateway(),
-                                ipAddr.getNetmask(), macAddress, networkRate, ipAddr.isOneToOneNat());
-
-                ip.setTrafficType(network.getTrafficType());
-                ip.setNetworkName(_networkModel.getNetworkTag(router.getHypervisorType(), network));
-                ipsToSend[i++] = ip;
-                if (ipAddr.isSourceNat()) {
-                    sourceNatIpAdd = new Pair<IpAddressTO, Long>(ip, ipAddr.getNetworkId());
-                    addSourceNat = add;
-                }
-            }
-            IpAssocVpcCommand cmd = new IpAssocVpcCommand(ipsToSend);
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, _routerControlHelper.getRouterIpInNetwork(ipAddrList.get(0).getNetworkId(), router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-            DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
-            cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-
-            cmds.addCommand("IPAssocVpcCommand", cmd);
-        }
-
-        //set source nat ip
-        if (sourceNatIpAdd != null) {
-            IpAddressTO sourceNatIp = sourceNatIpAdd.first();
-            SetSourceNatCommand cmd = new SetSourceNatCommand(sourceNatIp, addSourceNat);
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
-            cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-            DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
-            cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-            cmds.addCommand("SetSourceNatCommand", cmd);
-        }
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/server/src/com/cloud/network/rules/VpnRules.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/rules/VpnRules.java b/server/src/com/cloud/network/rules/VpnRules.java
index fa4d1ea..f42465b 100644
--- a/server/src/com/cloud/network/rules/VpnRules.java
+++ b/server/src/com/cloud/network/rules/VpnRules.java
@@ -17,15 +17,10 @@
 
 package com.cloud.network.rules;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.cloudstack.network.topology.NetworkTopologyVisitor;
 
-import com.cloud.agent.api.routing.NetworkElementCommand;
-import com.cloud.agent.api.routing.VpnUsersCfgCommand;
-import com.cloud.agent.manager.Commands;
-import com.cloud.dc.DataCenterVO;
 import com.cloud.exception.ResourceUnavailableException;
 import com.cloud.network.Network;
 import com.cloud.network.VpnUser;
@@ -47,27 +42,6 @@ public class VpnRules extends RuleApplier {
         return visitor.visit(this);
     }
 
-    public void createApplyVpnUsersCommand(final List<? extends VpnUser> users, final VirtualRouter router, final Commands cmds) {
-        final List<VpnUser> addUsers = new ArrayList<VpnUser>();
-        final List<VpnUser> removeUsers = new ArrayList<VpnUser>();
-        for (final VpnUser user : users) {
-            if (user.getState() == VpnUser.State.Add || user.getState() == VpnUser.State.Active) {
-                addUsers.add(user);
-            } else if (user.getState() == VpnUser.State.Revoke) {
-                removeUsers.add(user);
-            }
-        }
-
-        final VpnUsersCfgCommand cmd = new VpnUsersCfgCommand(addUsers, removeUsers);
-        cmd.setAccessDetail(NetworkElementCommand.ACCOUNT_ID, String.valueOf(router.getAccountId()));
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_IP, _routerControlHelper.getRouterControlIp(router.getId()));
-        cmd.setAccessDetail(NetworkElementCommand.ROUTER_NAME, router.getInstanceName());
-        final DataCenterVO dcVo = _dcDao.findById(router.getDataCenterId());
-        cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
-
-        cmds.addCommand("users", cmd);
-    }
-
     public List<? extends VpnUser> getUsers() {
         return _users;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/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 892a81a..f51c62b 100644
--- a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
+++ b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkTopology.java
@@ -17,7 +17,6 @@
 
 package org.apache.cloudstack.network.topology;
 
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.log4j.Logger;
@@ -26,16 +25,15 @@ import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
 import com.cloud.dc.DataCenter;
-import com.cloud.dc.DataCenter.NetworkType;
-import com.cloud.dc.Pod;
 import com.cloud.deploy.DeployDestination;
-import com.cloud.exception.AgentUnavailableException;
 import com.cloud.exception.ConcurrentOperationException;
 import com.cloud.exception.ResourceUnavailableException;
-import com.cloud.host.Status;
 import com.cloud.network.Network;
 import com.cloud.network.PublicIpAddress;
+import com.cloud.network.RemoteAccessVpn;
+import com.cloud.network.VpnUser;
 import com.cloud.network.router.VirtualRouter;
+import com.cloud.network.rules.AdvancedVpnRules;
 import com.cloud.network.rules.DhcpEntryRules;
 import com.cloud.network.rules.DhcpSubNetRules;
 import com.cloud.network.rules.NetworkAclsRules;
@@ -64,6 +62,32 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
     protected AdvancedNetworkVisitor _advancedVisitor;
 
     @Override
+    public BasicNetworkVisitor getVisitor() {
+        return _advancedVisitor;
+    }
+
+    @Override
+    public String[] applyVpnUsers(final RemoteAccessVpn remoteAccessVpn, final List<? extends VpnUser> users, final VirtualRouter router) throws ResourceUnavailableException {
+
+        s_logger.debug("APPLYING ADVANCED VPN USERS RULES");
+
+        AdvancedVpnRules routesRules = _virtualNetworkApplianceFactory.createAdvancedVpnRules(remoteAccessVpn, users);
+
+        boolean agentResult = routesRules.accept(_advancedVisitor, router);
+
+        String[] result = new String[users.size()];
+        for (int i = 0; i < result.length; i++) {
+            if (agentResult) {
+                result[i] = null;
+            } else {
+                result[i] = String.valueOf(agentResult);
+            }
+        }
+
+        return result;
+    }
+
+    @Override
     public boolean applyStaticRoutes(final List<StaticRouteProfile> staticRoutes, final List<DomainRouterVO> routers) throws ResourceUnavailableException {
 
         if (staticRoutes == null || staticRoutes.isEmpty()) {
@@ -220,93 +244,4 @@ public class AdvancedNetworkTopology extends BasicNetworkTopology {
 
         return applyRules(network, routers, typeString, isPodLevelException, podId, failWhenDisconnect, new RuleApplierWrapper<RuleApplier>(aclsRules));
     }
-
-    @Override
-    public boolean applyRules(final Network network, final List<? extends VirtualRouter> routers, final String typeString, final boolean isPodLevelException, final Long podId,
-            final boolean failWhenDisconnect, final RuleApplierWrapper<RuleApplier> ruleApplierWrapper) throws ResourceUnavailableException {
-
-        if (routers == null || routers.isEmpty()) {
-            s_logger.warn("Unable to apply " + typeString + ", virtual router doesn't exist in the network " + network.getId());
-            throw new ResourceUnavailableException("Unable to apply " + typeString, DataCenter.class, network.getDataCenterId());
-        }
-
-        RuleApplier ruleApplier = ruleApplierWrapper.getRuleType();
-
-        final DataCenter dc = _dcDao.findById(network.getDataCenterId());
-        final boolean isZoneBasic = dc.getNetworkType() == NetworkType.Basic;
-
-        // isPodLevelException and podId is only used for basic zone
-        assert !(!isZoneBasic && isPodLevelException || isZoneBasic && isPodLevelException && podId == null);
-
-        final List<VirtualRouter> connectedRouters = new ArrayList<VirtualRouter>();
-        final List<VirtualRouter> disconnectedRouters = new ArrayList<VirtualRouter>();
-        boolean result = true;
-        final String msg = "Unable to apply " + typeString + " on disconnected router ";
-        for (final VirtualRouter router : routers) {
-            if (router.getState() == State.Running) {
-                s_logger.debug("Applying " + typeString + " in network " + network);
-
-                if (router.isStopPending()) {
-                    if (_hostDao.findById(router.getHostId()).getState() == Status.Up) {
-                        throw new ResourceUnavailableException("Unable to process due to the stop pending router " + router.getInstanceName()
-                                + " haven't been stopped after it's host coming back!", DataCenter.class, router.getDataCenterId());
-                    }
-                    s_logger.debug("Router " + router.getInstanceName() + " is stop pending, so not sending apply " + typeString + " commands to the backend");
-                    continue;
-                }
-
-                try {
-                    ruleApplier.accept(_advancedVisitor, router);
-
-                    connectedRouters.add(router);
-                } catch (final AgentUnavailableException e) {
-                    s_logger.warn(msg + router.getInstanceName(), e);
-                    disconnectedRouters.add(router);
-                }
-
-                // If rules fail to apply on one domR and not due to
-                // disconnection, no need to proceed with the rest
-                if (!result) {
-                    if (isZoneBasic && isPodLevelException) {
-                        throw new ResourceUnavailableException("Unable to apply " + typeString + " on router ", Pod.class, podId);
-                    }
-                    throw new ResourceUnavailableException("Unable to apply " + typeString + " on router ", DataCenter.class, router.getDataCenterId());
-                }
-
-            } else if (router.getState() == State.Stopped || router.getState() == State.Stopping) {
-                s_logger.debug("Router " + router.getInstanceName() + " is in " + router.getState() + ", so not sending apply " + typeString + " commands to the backend");
-            } else {
-                s_logger.warn("Unable to apply " + typeString + ", virtual router is not in the right state " + router.getState());
-                if (isZoneBasic && isPodLevelException) {
-                    throw new ResourceUnavailableException("Unable to apply " + typeString + ", virtual router is not in the right state", Pod.class, podId);
-                }
-                throw new ResourceUnavailableException("Unable to apply " + typeString + ", virtual router is not in the right state", DataCenter.class, router.getDataCenterId());
-            }
-        }
-
-        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
-                _nwHelper.handleSingleWorkingRedundantRouter(connectedRouters, disconnectedRouters, msg);
-            }
-        } else if (!disconnectedRouters.isEmpty()) {
-            for (final VirtualRouter router : disconnectedRouters) {
-                if (s_logger.isDebugEnabled()) {
-                    s_logger.debug(msg + router.getInstanceName() + "(" + router.getId() + ")");
-                }
-            }
-            if (isZoneBasic && isPodLevelException) {
-                throw new ResourceUnavailableException(msg, Pod.class, podId);
-            }
-            throw new ResourceUnavailableException(msg, DataCenter.class, disconnectedRouters.get(0).getDataCenterId());
-        }
-
-        result = true;
-        if (failWhenDisconnect) {
-            result = !connectedRouters.isEmpty();
-        }
-        return result;
-    }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/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 15931c6..7d08813 100644
--- a/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
+++ b/server/src/org/apache/cloudstack/network/topology/AdvancedNetworkVisitor.java
@@ -69,8 +69,8 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
         final NicVO nicVo = userdata.getNicVo();
         final UserVmVO userVM = userdata.getUserVM();
 
-        userdata.createPasswordCommand(router, profile, nicVo, commands);
-        userdata.createVmDataCommand(router, userVM, nicVo, userVM.getDetail("SSH.PublicKey"), commands);
+        _commandSetupHelper.createPasswordCommand(router, profile, nicVo, commands);
+        _commandSetupHelper.createVmDataCommand(router, userVM, nicVo, userVM.getDetail("SSH.PublicKey"), commands);
 
         return _networkGeneralHelper.sendCommandsToRouter(router, commands);
     }
@@ -83,7 +83,7 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
         final NicVO nicVo = dhcp.getNicVo();
         final UserVmVO userVM = dhcp.getUserVM();
 
-        dhcp.createDhcpEntryCommand(router, userVM, nicVo, commands);
+        _commandSetupHelper.createDhcpEntryCommand(router, userVM, nicVo, commands);
 
         return _networkGeneralHelper.sendCommandsToRouter(router, commands);
     }
@@ -107,7 +107,7 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
 
         Commands commands = new Commands(Command.OnError.Continue);
         List<? extends NetworkACLItem> rules = acls.getRules();
-        acls.createNetworkACLsCommands(rules, router, commands, network.getId(), acls.isPrivateGateway());
+        _commandSetupHelper.createNetworkACLsCommands(rules, router, commands, network.getId(), acls.isPrivateGateway());
 
         return _networkGeneralHelper.sendCommandsToRouter(router, commands);
     }
@@ -121,7 +121,7 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
         List<PublicIpAddress> ipsToSend = vpcip.getIpsToSend();
 
         if (!ipsToSend.isEmpty()) {
-            vpcip.createVpcAssociatePublicIPCommands(router, ipsToSend, cmds, vlanMacAddress);
+            _commandSetupHelper.createVpcAssociatePublicIPCommands(router, ipsToSend, cmds, vlanMacAddress);
             return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
         } else {
             return true;
@@ -147,7 +147,7 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
             privateIps.add(ip);
 
             Commands cmds = new Commands(Command.OnError.Stop);
-            privateGW.createVpcAssociatePrivateIPCommands(router, privateIps, cmds, isAddOperation);
+            _commandSetupHelper.createVpcAssociatePrivateIPCommands(router, privateIps, cmds, isAddOperation);
 
             try {
                 if (_networkGeneralHelper.sendCommandsToRouter(router, cmds)) {
@@ -202,11 +202,11 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
         final List<IpAliasTO> ipaliasTo = new ArrayList<IpAliasTO>();
         ipaliasTo.add(new IpAliasTO(routerAliasIp, nicAlias.getNetmask(), nicAlias.getAliasCount().toString()));
 
-        subnet.createIpAlias(router, ipaliasTo, nicAlias.getNetworkId(), cmds);
+        _commandSetupHelper.createIpAlias(router, ipaliasTo, nicAlias.getNetworkId(), cmds);
 
         // also add the required configuration to the dnsmasq for supporting
         // dhcp and dns on the new ip.
-        subnet.configDnsMasq(router, network, cmds);
+        _commandSetupHelper.configDnsMasq(router, network, cmds);
 
         return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
     }
@@ -217,7 +217,7 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
         List<StaticRouteProfile> staticRoutes = staticRoutesRules.getStaticRoutes();
 
         Commands cmds = new Commands(Command.OnError.Continue);
-        staticRoutesRules.createStaticRouteCommands(staticRoutes, router, cmds);
+        _commandSetupHelper.createStaticRouteCommands(staticRoutes, router, cmds);
 
         return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
     }
@@ -228,7 +228,7 @@ public class AdvancedNetworkVisitor extends BasicNetworkVisitor {
         List<? extends VpnUser> users = vpnRules.getUsers();
 
         Commands cmds = new Commands(Command.OnError.Continue);
-        vpnRules.createApplyVpnUsersCommand(users, router, cmds);
+        _commandSetupHelper.createApplyVpnUsersCommand(users, router, cmds);
 
         // Currently we receive just one answer from the agent. In the future we
         // have to parse individual answers and set

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/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 ec52911..5327a5d 100644
--- a/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
+++ b/server/src/org/apache/cloudstack/network/topology/BasicNetworkTopology.java
@@ -102,6 +102,11 @@ public class BasicNetworkTopology implements NetworkTopology {
     }
 
     @Override
+    public NetworkTopologyVisitor getVisitor() {
+        return _basicVisitor;
+    }
+
+    @Override
     public boolean setupPrivateGateway(final PrivateGateway gateway, final VirtualRouter router) throws ConcurrentOperationException, ResourceUnavailableException {
         throw new CloudRuntimeException("setupPrivateGateway not implemented in Basic Network Topology.");
     }
@@ -383,7 +388,7 @@ public class BasicNetworkTopology implements NetworkTopology {
                 }
 
                 try {
-                    ruleApplier.accept(_basicVisitor, router);
+                    ruleApplier.accept(getVisitor(), router);
 
                     connectedRouters.add(router);
                 } catch (final AgentUnavailableException e) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/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 817fad7..987e23e 100644
--- a/server/src/org/apache/cloudstack/network/topology/BasicNetworkVisitor.java
+++ b/server/src/org/apache/cloudstack/network/topology/BasicNetworkVisitor.java
@@ -32,6 +32,7 @@ import com.cloud.network.Network;
 import com.cloud.network.PublicIpAddress;
 import com.cloud.network.VpnUser;
 import com.cloud.network.lb.LoadBalancingRule;
+import com.cloud.network.router.CommandSetupHelper;
 import com.cloud.network.router.NetworkHelper;
 import com.cloud.network.router.VirtualRouter;
 import com.cloud.network.rules.DhcpEntryRules;
@@ -73,6 +74,9 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
     @Inject
     protected NetworkHelper _networkGeneralHelper;
 
+    @Inject
+    protected CommandSetupHelper _commandSetupHelper;
+
     @Override
     public boolean visit(final StaticNatRules nat) throws ResourceUnavailableException {
         final Network network = nat.getNetwork();
@@ -80,7 +84,7 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
         final List<? extends StaticNat> rules = nat.getRules();
 
         final Commands cmds = new Commands(Command.OnError.Continue);
-        nat.createApplyStaticNatCommands(rules, router, cmds, network.getId());
+        _commandSetupHelper.createApplyStaticNatCommands(rules, router, cmds, network.getId());
 
         return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
     }
@@ -92,7 +96,7 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
         final List<LoadBalancingRule> rules = loadbalancing.getRules();
 
         final Commands cmds = new Commands(Command.OnError.Continue);
-        loadbalancing.createApplyLoadBalancingRulesCommands(rules, router, cmds, network.getId());
+        _commandSetupHelper.createApplyLoadBalancingRulesCommands(rules, router, cmds, network.getId());
 
         return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
     }
@@ -110,25 +114,25 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
         final Commands cmds = new Commands(Command.OnError.Continue);
         if (purpose == Purpose.LoadBalancing) {
 
-            firewall.createApplyLoadBalancingRulesCommands(loadbalancingRules, router, cmds, network.getId());
+            _commandSetupHelper.createApplyLoadBalancingRulesCommands(loadbalancingRules, router, cmds, network.getId());
 
             return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
 
         } else if (purpose == Purpose.PortForwarding) {
 
-            firewall.createApplyPortForwardingRulesCommands((List<? extends PortForwardingRule>) rules, router, cmds, network.getId());
+            _commandSetupHelper.createApplyPortForwardingRulesCommands((List<? extends PortForwardingRule>) rules, router, cmds, network.getId());
 
             return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
 
         } else if (purpose == Purpose.StaticNat) {
 
-            firewall.createApplyStaticNatRulesCommands((List<StaticNatRule>) rules, router, cmds, network.getId());
+            _commandSetupHelper.createApplyStaticNatRulesCommands((List<StaticNatRule>) rules, router, cmds, network.getId());
 
             return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
 
         } else if (purpose == Purpose.Firewall) {
 
-            firewall.createApplyFirewallRulesCommands(rules, router, cmds, network.getId());
+            _commandSetupHelper.createApplyFirewallRulesCommands(rules, router, cmds, network.getId());
 
             return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
 
@@ -146,7 +150,7 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
         final Commands commands = new Commands(Command.OnError.Continue);
         final List<? extends PublicIpAddress> ips = ipRules.getIpAddresses();
 
-        ipRules.createAssociateIPCommands(router, ips, commands, network.getId());
+        _commandSetupHelper.createAssociateIPCommands(router, ips, commands, network.getId());
         return _networkGeneralHelper.sendCommandsToRouter(router, commands);
     }
 
@@ -161,8 +165,8 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
         final DeployDestination destination = userdata.getDestination();
 
         if (router.getPodIdToDeployIn().longValue() == destination.getPod().getId()) {
-            userdata.createPasswordCommand(router, profile, nicVo, commands);
-            userdata.createVmDataCommand(router, userVM, nicVo, userVM.getDetail("SSH.PublicKey"), commands);
+            _commandSetupHelper.createPasswordCommand(router, profile, nicVo, commands);
+            _commandSetupHelper.createVmDataCommand(router, userVM, nicVo, userVM.getDetail("SSH.PublicKey"), commands);
 
             return _networkGeneralHelper.sendCommandsToRouter(router, commands);
         }
@@ -180,7 +184,7 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
         final DeployDestination destination = dhcp.getDestination();
 
         if (router.getPodIdToDeployIn().longValue() == destination.getPod().getId()) {
-            dhcp.createDhcpEntryCommand(router, userVM, nicVo, commands);
+            _commandSetupHelper.createDhcpEntryCommand(router, userVM, nicVo, commands);
 
             return _networkGeneralHelper.sendCommandsToRouter(router, commands);
         }
@@ -199,10 +203,10 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
         final VMTemplateVO template = sshkey.getTemplate();
 
         if (template != null && template.getEnablePassword()) {
-            sshkey.createPasswordCommand(router, profile, nicVo, commands);
+            _commandSetupHelper.createPasswordCommand(router, profile, nicVo, commands);
         }
 
-        sshkey.createVmDataCommand(router, userVM, nicVo, sshKeystr, commands);
+        _commandSetupHelper.createVmDataCommand(router, userVM, nicVo, sshKeystr, commands);
 
         return _networkGeneralHelper.sendCommandsToRouter(router, commands);
     }
@@ -214,7 +218,7 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
         final VirtualMachineProfile profile = passwd.getProfile();
 
         final Commands cmds = new Commands(Command.OnError.Stop);
-        passwd.createPasswordCommand(router, profile, nicVo, cmds);
+        _commandSetupHelper.createPasswordCommand(router, profile, nicVo, cmds);
 
         return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
     }
@@ -227,7 +231,7 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
         final NicVO nicVo = userdata.getNicVo();
 
         final Commands commands = new Commands(Command.OnError.Stop);
-        userdata.createVmDataCommand(router, userVM, nicVo, null, commands);
+        _commandSetupHelper.createVmDataCommand(router, userVM, nicVo, null, commands);
 
         return _networkGeneralHelper.sendCommandsToRouter(router, commands);
     }
@@ -238,7 +242,7 @@ public class BasicNetworkVisitor extends NetworkTopologyVisitor {
         List<? extends VpnUser> users = vpn.getUsers();
 
         final Commands cmds = new Commands(Command.OnError.Continue);
-        vpn.createApplyVpnUsersCommand(users, router, cmds);
+        _commandSetupHelper.createApplyVpnUsersCommand(users, router, cmds);
 
         return _networkGeneralHelper.sendCommandsToRouter(router, cmds);
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bc90ce08/server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
----------------------------------------------------------------------
diff --git a/server/src/org/apache/cloudstack/network/topology/NetworkTopology.java b/server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
index 469c177..2129b42 100644
--- a/server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
+++ b/server/src/org/apache/cloudstack/network/topology/NetworkTopology.java
@@ -42,6 +42,7 @@ import com.cloud.vm.VirtualMachineProfile;
 public interface NetworkTopology {
 
 <<<<<<< HEAD
+<<<<<<< HEAD
     StringBuilder createGuestBootLoadArgs(final NicProfile guestNic, final String defaultDns1, final String defaultDns2, DomainRouterVO router);
 
     String retrieveGuestDhcpRange(final NicProfile guestNic, final Network guestNetwork, final DataCenter dc);
@@ -51,6 +52,10 @@ public interface NetworkTopology {
 
     // ====== USER FOR VPC ONLY ====== //
 =======
+=======
+    NetworkTopologyVisitor getVisitor();
+
+>>>>>>> 06c77f1... refactor all private methods in the virtual router appliance and VPC appliance
     // ====== USED FOR VPC ONLY ====== //
 >>>>>>> 0b8b22f... adding setupPrivateGateway to new style;
 


Mime
View raw message