diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 2ae2cfc6260..1958d1ef75a 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1412,6 +1412,26 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V throw new CloudRuntimeException(errMsg); } + private void checkAndResetPriorityOfRedundantRouter(List routers) { + boolean allStopped = true; + for (DomainRouterVO router : routers) { + if (!router.getIsRedundantRouter() || router.getState() != VirtualMachine.State.Stopped) { + allStopped = false; + break; + } + } + if (!allStopped) { + return; + } + + for (DomainRouterVO router : routers) { + // getUpdatedPriority() would update the value later + router.setPriority(0); + router.setIsPriorityBumpUp(false); + _routerDao.update(router.getId(), router); + } + } + @DB protected List findOrDeployVirtualRouterInGuestNetwork(Network guestNetwork, DeployDestination dest, Account owner, boolean isRedundant, Map params) throws ConcurrentOperationException, @@ -1482,6 +1502,10 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V int routerCount = 1; if (isRedundant) { routerCount = 2; + //Check current redundant routers, if possible(all routers are stopped), reset the priority + if (routers.size() != 0) { + checkAndResetPriorityOfRedundantRouter(routers); + } } // If old network is redundant but new is single router, then routers.size() = 2 but routerCount = 1 diff --git a/systemvm/patches/debian/config/etc/init.d/cloud-early-config b/systemvm/patches/debian/config/etc/init.d/cloud-early-config index 88ecc119b61..d44f94d7d17 100755 --- a/systemvm/patches/debian/config/etc/init.d/cloud-early-config +++ b/systemvm/patches/debian/config/etc/init.d/cloud-early-config @@ -1189,6 +1189,7 @@ change_password() { start() { # Clear /tmp for file lock rm -f /tmp/*.lock + rm -f /tmp/rrouter_bumped local hyp=$(hypervisor) [ $? -ne 0 ] && log_it "Failed to detect hypervisor type, bailing out of early init" && exit 10 log_it "Detected that we are running inside $hyp guest"