incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bfede...@apache.org
Subject [12/54] [abbrv] git commit: simulator:Using the priority to decide b/w MASTER/BACKUP
Date Tue, 08 Jan 2013 00:41:19 GMT
simulator:Using the priority to decide b/w MASTER/BACKUP

BootArgs carry router priority for master and backup and simulator will
reuse the priority to decide RvR status. Deprecating the odd/even logic.

Signed-off-by: Prasanna Santhanam <tsp@apache.org>


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

Branch: refs/heads/ui-quick-view-v2
Commit: f0c3b4c62a7a1a440d723696d61b42dad58f6faf
Parents: ed25ec0
Author: Prasanna Santhanam <tsp@apache.org>
Authored: Sat Dec 22 14:09:59 2012 -0800
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Sat Dec 22 14:09:59 2012 -0800

----------------------------------------------------------------------
 .../com/cloud/agent/manager/MockVmManagerImpl.java |   22 ++++++++-------
 .../src/com/cloud/simulator/MockVMVO.java          |   10 +++++++
 .../simulator/src/com/cloud/simulator/MockVm.java  |    3 ++
 setup/db/create-schema-simulator.sql               |    1 +
 4 files changed, 26 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0c3b4c6/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
index d04e166..40cd80a 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
@@ -107,6 +107,7 @@ public class MockVmManagerImpl implements MockVmManager {
             vm.setName(vmName);
             vm.setVncPort(vncPort);
             vm.setHostId(host.getId());
+            vm.setBootargs(bootArgs);
             if(vmName.startsWith("s-")) {
 		vm.setType("SecondaryStorageVm");
             } else if (vmName.startsWith("v-")) {
@@ -238,15 +239,16 @@ public class MockVmManagerImpl implements MockVmManager {
     @Override
     public CheckRouterAnswer checkRouter(CheckRouterCommand cmd) {
         String router_name = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
-        int router_id = Integer.parseInt(router_name.split("-")[1]);
-        if (router_id % 2 == 0) {
-            s_logger.debug("Found even routerId, making it MASTER in RvR");
+        MockVm vm = _mockVmDao.findByVmName(router_name);
+        String args = vm.getBootargs();
+        if (args.indexOf("router_pr=100") > 0) {
+            s_logger.debug("Router priority is for MASTER");
             CheckRouterAnswer ans = new CheckRouterAnswer(cmd, "Status: MASTER & Bumped:
NO", true);
             ans.setState(VirtualRouter.RedundantState.MASTER);
             return ans;
         } else {
-            s_logger.debug("Found odd routerId, making it BACKUP in RvR");
-            CheckRouterAnswer ans = new CheckRouterAnswer(cmd, "Status: MASTER & Bumped:
NO", true);
+            s_logger.debug("Router priority is for BACKUP");
+            CheckRouterAnswer ans = new CheckRouterAnswer(cmd, "Status: BACKUP & Bumped:
NO", true);
             ans.setState(VirtualRouter.RedundantState.BACKUP);
             return ans;
         }
@@ -255,13 +257,13 @@ public class MockVmManagerImpl implements MockVmManager {
     @Override
     public Answer bumpPriority(BumpUpPriorityCommand cmd) {
         String router_name = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
-        int router_id = Integer.parseInt(router_name.split("-")[1]);
-        if (router_id % 2 == 0) {
-            return new Answer(cmd, true, "Status: MASTER & Bumped: YES");
-        } else {
+        MockVm vm = _mockVmDao.findByVmName(router_name);
+        String args = vm.getBootargs();
+        if (args.indexOf("router_pr=100") > 0) {
             return new Answer(cmd, true, "Status: BACKUP & Bumped: YES");
+        } else {
+            return new Answer(cmd, true, "Status: MASTER & Bumped: YES");
         }
-
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0c3b4c6/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVMVO.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVMVO.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVMVO.java
index 4fb3085..3a5aa3d 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVMVO.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVMVO.java
@@ -55,6 +55,9 @@ public class MockVMVO implements MockVm{
     @Column(name="cpu")
     private int cpu;
 
+    @Column(name="bootargs")
+    private String bootargs;
+
     public MockVMVO() {
 
     }
@@ -127,4 +130,11 @@ public class MockVMVO implements MockVm{
 	this.vmType = type;
     }
 
+    public String getBootargs() {
+        return bootargs;
+    }
+
+    public void setBootargs(String bootargs) {
+        this.bootargs = bootargs;
+    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0c3b4c6/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVm.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVm.java b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVm.java
index 2e1ba27..e46b6a0 100644
--- a/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVm.java
+++ b/plugins/hypervisors/simulator/src/com/cloud/simulator/MockVm.java
@@ -41,4 +41,7 @@ public interface MockVm {
 	public void setType(String type);
 	public void setVncPort(int vncPort);
 	public long getId();
+
+    public String getBootargs();
+    public void setBootargs(String bootargs);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/f0c3b4c6/setup/db/create-schema-simulator.sql
----------------------------------------------------------------------
diff --git a/setup/db/create-schema-simulator.sql b/setup/db/create-schema-simulator.sql
index 1ab838b..6d4a130 100644
--- a/setup/db/create-schema-simulator.sql
+++ b/setup/db/create-schema-simulator.sql
@@ -76,6 +76,7 @@ CREATE TABLE `simulator`.`mockvm` (
   `vnc_port` bigint unsigned,
   `memory` bigint unsigned,
   `cpu` bigint unsigned,
+  `bootargs` varchar(255),
   PRIMARY KEY  (`id`),
   INDEX `i_mockvm__host_id`(`host_id`),
   INDEX `i_mockvm__state`(`state`),


Mime
View raw message