From 5a175e871c184ecb8f2815db57388be58bc5b4f3 Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Tue, 3 Jul 2012 16:39:17 -0700 Subject: [PATCH] VPC: CS-15355 - fixed router when deployVm in Basic zone --- .../VirtualNetworkApplianceManager.java | 1 - .../VirtualNetworkApplianceManagerImpl.java | 43 ++++++++----------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java index b2c1cd02df1..f6d83c3f865 100644 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManager.java @@ -22,7 +22,6 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Network; import com.cloud.network.PublicIpAddress; import com.cloud.network.RemoteAccessVpn; -import com.cloud.network.Site2SiteVpnConnection; import com.cloud.network.VirtualNetworkApplianceService; import com.cloud.network.VpnUser; import com.cloud.network.rules.FirewallRule; diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 4e40432cb63..ec7bc791ab1 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1189,43 +1189,38 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian boolean isPodBased = (dest.getDataCenter().getNetworkType() == NetworkType.Basic || _networkMgr.areServicesSupportedInNetwork(guestNetwork.getId(), Service.SecurityGroup)) && guestNetwork.getTrafficType() == TrafficType.Guest; - Long podId = null; - if (isPodBased) { - Pod pod = dest.getPod(); - if (pod != null) { - podId = pod.getId(); - } - } + Pair> planAndRouters = getDeploymentPlanAndRouters(isPodBased, dest, guestNetwork.getId()); DeploymentPlan plan = planAndRouters.first(); List routers = planAndRouters.second(); //2) Figure out required routers count - int routerCount = 1; - if (isRedundant) { - routerCount = 2; - } + int routerCount = 1; + if (isRedundant) { + routerCount = 2; + } - /* If it is the single router network, then keep it untouched */ - for (DomainRouterVO router : routers) { - if (!router.getIsRedundantRouter()) { - routerCount = 1; - } + /* If it is the single router network, then keep it untouched */ + for (DomainRouterVO router : routers) { + if (!router.getIsRedundantRouter() || isPodBased) { + routerCount = 1; + break; } + } - /* If old network is redundant but new is single router, then routers.size() = 2 but routerCount = 1 */ - if (routers.size() >= routerCount || (isPodBased && podId == null)) { - return routers; - } + /* If old network is redundant but new is single router, then routers.size() = 2 but routerCount = 1 */ + if (routers.size() >= routerCount) { + return routers; + } - if (routers.size() >= 5) { - s_logger.error("Too much redundant routers!"); - } + if (routers.size() >= 5) { + s_logger.error("Too much redundant routers!"); + } Network network = _networkDao.acquireInLockTable(guestNetwork.getId()); if (network == null) { throw new ConcurrentOperationException("Unable to lock network " + guestNetwork.getId()); - } + } try { //Check if providers are supported in the physical networks