You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/03/17 11:26:06 UTC

[04/50] git commit: updated refs/heads/master to 3c429ee

Implementing redundant router arguments to add redundant_state
Implementing the arguments on the python side


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

Branch: refs/heads/master
Commit: a5d6f90f666798e7575c6b7d3af5b3024af8768e
Parents: 279f1a2
Author: wilderrodrigues <wr...@schubergphilis.com>
Authored: Mon Jan 26 17:33:50 2015 +0100
Committer: wilderrodrigues <wr...@schubergphilis.com>
Committed: Mon Mar 16 11:39:51 2015 +0100

----------------------------------------------------------------------
 .../VirtualNetworkApplianceManagerImpl.java     | 40 +++++++++++++-------
 .../VpcVirtualNetworkApplianceManagerImpl.java  | 16 ++------
 .../debian/config/opt/cloud/bin/cs/CsDatabag.py |  5 +++
 .../config/opt/cloud/bin/cs/CsRedundant.py      |  3 +-
 4 files changed, 38 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5d6f90f/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index a3f56c6..f0730f5 100644
--- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
@@ -1060,8 +1060,8 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
 
         /*
          * In order to make fail-over works well at any time, we have to ensure:
-         * 1. Backup router's priority = Master's priority - DELTA + 1 2. Backup
-         * router's priority hasn't been bumped up.
+         * 1. Backup router's priority = Master's priority - DELTA + 1
+         * 2. Backup router's priority hasn't been bumped up.
          */
         private void checkSanity(final List<DomainRouterVO> routers) {
             final Set<Long> checkedNetwork = new HashSet<Long>();
@@ -1137,15 +1137,8 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
         protected void runInContext() {
             while (true) {
                 try {
-                    final Long networkId = _vrUpdateQueue.take(); // This is a
-                    // blocking
-                    // call so
-                    // this thread
-                    // won't run
-                    // all the
-                    // time if no
-                    // work item
-                    // in queue.
+                    final Long networkId = _vrUpdateQueue.take();
+                    // This is a blocking call so this thread won't run all the time if no work item in queue.
                     final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(networkId, Role.VIRTUAL_ROUTER);
 
                     if (routers.size() != 2) {
@@ -1159,7 +1152,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
                     final DomainRouterVO router0 = routers.get(0);
                     final DomainRouterVO router1 = routers.get(1);
                     DomainRouterVO router = router0;
-                    if (router0.getId() < router1.getId() && router0.getHostId() != null) {
+                    if (router0.getId() < router1.getId()) {
                         router = router0;
                     } else {
                         router = router1;
@@ -1596,7 +1589,28 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
         final boolean isRedundant = router.getIsRedundantRouter();
         if (isRedundant) {
             buf.append(" redundant_router=1");
-            final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(nic.getNetworkId(), Role.VIRTUAL_ROUTER);
+
+            final Long vpcId = router.getVpcId();
+            final List<DomainRouterVO> routers;
+            if (vpcId != null) {
+                routers = _routerDao.listByVpcId(vpcId);
+            } else {
+                routers = _routerDao.listByNetworkAndRole(nic.getNetworkId(), Role.VIRTUAL_ROUTER);
+            }
+
+            String redundantState = RedundantState.BACKUP.toString();
+            if (routers.size() == 0) {
+                redundantState = RedundantState.MASTER.toString();
+            } else {
+                final DomainRouterVO router0 = routers.get(0);
+
+                if (router.getId() == router0.getId()) {
+                    redundantState = RedundantState.MASTER.toString();
+                }
+            }
+
+            buf.append(" redundant_state=").append(redundantState);
+
             try {
                 final int priority = getUpdatedPriority(network, routers, router);
                 router.setPriority(priority);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5d6f90f/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
index f06b1ba..77cc0de 100644
--- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
+++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
@@ -236,7 +236,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile, final DeployDestination dest, final ReservationContext context) {
         final DomainRouterVO domainRouterVO = _routerDao.findById(profile.getId());
 
-        if (domainRouterVO.getVpcId() != null) {
+        final Long vpcId = domainRouterVO.getVpcId();
+
+        if (vpcId != null) {
             if (domainRouterVO.getState() == State.Starting || domainRouterVO.getState() == State.Running) {
                 String defaultDns1 = null;
                 String defaultDns2 = null;
@@ -257,7 +259,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
 
                 // add vpc cidr/dns/networkdomain to the boot load args
                 final StringBuilder buf = profile.getBootArgsBuilder();
-                final Vpc vpc = _entityMgr.findById(Vpc.class, domainRouterVO.getVpcId());
+                final Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
                 buf.append(" vpccidr=" + vpc.getCidr() + " domain=" + vpc.getNetworkDomain());
 
                 buf.append(" dns1=").append(defaultDns1);
@@ -689,16 +691,6 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
     }
 
     @Override
-    public boolean start() {
-        return true;
-    }
-
-    @Override
-    public boolean stop() {
-        return true;
-    }
-
-    @Override
     public boolean startRemoteAccessVpn(final RemoteAccessVpn vpn, final VirtualRouter router) throws ResourceUnavailableException {
         if (router.getState() != State.Running) {
             s_logger.warn("Unable to apply remote access VPN configuration, virtual router is not in the right state " + router.getState());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5d6f90f/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDatabag.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDatabag.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDatabag.py
index fbafad2..d1d899b 100644
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDatabag.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsDatabag.py
@@ -125,3 +125,8 @@ class CsCmdLine(CsDataBag):
         if "redundant_master" in self.idata():
             return self.idata()['redundant_master'] == "true"
         return False
+    
+    def get_state(self):
+        if "redundant_state" in self.idata():
+            return self.idata()['redundant_state']
+        return "MASTER"
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a5d6f90f/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
----------------------------------------------------------------------
diff --git a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
index d9d36e2..267cc1c 100644
--- a/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
+++ b/systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py
@@ -101,6 +101,7 @@ class CsRedundant(object):
         file.search(" router_id ", "    router_id %s" % self.cl.get_name())
         file.search(" priority ", "    priority %s" % self.cl.get_priority())
         file.search(" weight ", "    weight %s" % 2)
+        file.search(" state ", "    state %s" % self.cl.get_state())
         file.greplace("[RROUTER_BIN_PATH]", self.CS_ROUTER_DIR)
         file.section("virtual_ipaddress {", "}", self._collect_ips())
         file.commit()
@@ -121,7 +122,7 @@ class CsRedundant(object):
         if connt.is_changed():
             CsHelper.service("conntrackd", "restart")
 
-        if file.is_changed():
+        if file.is_changed() and self.cl.get_state() == 'MASTER':
             CsHelper.service("keepalived", "restart")
 
         # FIXME