incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [3/4] git commit: Rudimentary RvR functionality for the simulator
Date Tue, 25 Sep 2012 07:11:29 GMT
Rudimentary RvR functionality for the simulator

- Will decide based on even - MASTER or odd - BACKUP router id
- BumpUpPriority never fails and always returns true
- SwitchOver is untested and most likely won't work


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

Branch: refs/heads/master
Commit: fb813c84e1f43e01d47f464fb5a3f3d6b681c446
Parents: d947b3d
Author: Prasanna Santhanam <Prasanna.Santhanam@citrix.com>
Authored: Mon Sep 17 21:49:25 2012 +0530
Committer: Prasanna Santhanam <tsp@apache.org>
Committed: Fri Sep 21 10:45:30 2012 +0530

----------------------------------------------------------------------
 .../src/com/cloud/agent/manager/MockVmManager.java |   21 +----
 .../com/cloud/agent/manager/MockVmManagerImpl.java |   67 ++++++++-------
 .../cloud/agent/manager/SimulatorManagerImpl.java  |   46 ++---------
 3 files changed, 46 insertions(+), 88 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/fb813c84/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java b/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java
index cd8f5fa..07cf584 100644
--- a/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java
+++ b/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java
@@ -19,21 +19,7 @@ package com.cloud.agent.manager;
 import java.util.HashMap;
 import java.util.Map;
 
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.CheckVirtualMachineCommand;
-import com.cloud.agent.api.CleanupNetworkRulesCmd;
-import com.cloud.agent.api.GetDomRVersionAnswer;
-import com.cloud.agent.api.GetDomRVersionCmd;
-import com.cloud.agent.api.GetVmStatsCommand;
-import com.cloud.agent.api.GetVncPortCommand;
-import com.cloud.agent.api.MigrateAnswer;
-import com.cloud.agent.api.MigrateCommand;
-import com.cloud.agent.api.NetworkUsageCommand;
-import com.cloud.agent.api.RebootCommand;
-import com.cloud.agent.api.SecurityGroupRuleAnswer;
-import com.cloud.agent.api.SecurityGroupRulesCmd;
-import com.cloud.agent.api.StartCommand;
-import com.cloud.agent.api.StopCommand;
+import com.cloud.agent.api.*;
 import com.cloud.agent.api.check.CheckSshAnswer;
 import com.cloud.agent.api.check.CheckSshCommand;
 import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand;
@@ -90,5 +76,8 @@ public interface MockVmManager extends Manager {
 	MigrateAnswer Migrate(MigrateCommand cmd, SimulatorInfo info);
 	GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd);
 	Map<String, MockVMVO> getVms(String hostGuid);
-    
+
+    CheckRouterAnswer checkRouter(CheckRouterCommand cmd);
+
+    Answer bumpPriority(BumpUpPriorityCommand cmd);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/fb813c84/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java b/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
index d740ab7..78881f2 100644
--- a/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
+++ b/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
@@ -25,43 +25,15 @@ import java.util.concurrent.ConcurrentHashMap;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import com.cloud.agent.api.*;
+import com.cloud.agent.api.routing.*;
+import com.cloud.network.router.VirtualRouter;
 import org.apache.log4j.Logger;
 
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.CheckVirtualMachineAnswer;
-import com.cloud.agent.api.CheckVirtualMachineCommand;
-import com.cloud.agent.api.CleanupNetworkRulesCmd;
-import com.cloud.agent.api.GetDomRVersionAnswer;
-import com.cloud.agent.api.GetDomRVersionCmd;
-import com.cloud.agent.api.GetVmStatsAnswer;
-import com.cloud.agent.api.GetVmStatsCommand;
-import com.cloud.agent.api.GetVncPortAnswer;
-import com.cloud.agent.api.GetVncPortCommand;
-import com.cloud.agent.api.MigrateAnswer;
-import com.cloud.agent.api.MigrateCommand;
-import com.cloud.agent.api.NetworkUsageAnswer;
-import com.cloud.agent.api.NetworkUsageCommand;
-import com.cloud.agent.api.RebootAnswer;
-import com.cloud.agent.api.RebootCommand;
-import com.cloud.agent.api.SecurityGroupRuleAnswer;
-import com.cloud.agent.api.SecurityGroupRulesCmd;
-import com.cloud.agent.api.StartAnswer;
-import com.cloud.agent.api.StartCommand;
-import com.cloud.agent.api.StopAnswer;
-import com.cloud.agent.api.StopCommand;
-import com.cloud.agent.api.VmStatsEntry;
 import com.cloud.agent.api.check.CheckSshAnswer;
 import com.cloud.agent.api.check.CheckSshCommand;
 import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand;
 import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand;
-import com.cloud.agent.api.routing.DhcpEntryCommand;
-import com.cloud.agent.api.routing.IpAssocCommand;
-import com.cloud.agent.api.routing.LoadBalancerConfigCommand;
-import com.cloud.agent.api.routing.SavePasswordCommand;
-import com.cloud.agent.api.routing.SetFirewallRulesCommand;
-import com.cloud.agent.api.routing.SetPortForwardingRulesCommand;
-import com.cloud.agent.api.routing.SetStaticNatRulesCommand;
-import com.cloud.agent.api.routing.VmDataCommand;
 import com.cloud.agent.api.to.NicTO;
 import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.network.Networks.TrafficType;
@@ -262,8 +234,37 @@ public class MockVmManagerImpl implements MockVmManager {
             txn.close();
 		}
 	}
-	
-	@Override
+
+    @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");
+            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);
+            ans.setState(VirtualRouter.RedundantState.BACKUP);
+            return ans;
+        }
+    }
+
+    @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 {
+            return new Answer(cmd, true, "Status: BACKUP & Bumped: YES");
+        }
+
+    }
+
+    @Override
 	public Map<String, State> getVmStates(String hostGuid) {
 		Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
 		try {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/fb813c84/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java b/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
index 60f76fd..9a81ea6 100644
--- a/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
+++ b/agent-simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
@@ -24,45 +24,9 @@ import java.util.Map;
 import javax.ejb.Local;
 import javax.naming.ConfigurationException;
 
+import com.cloud.agent.api.*;
 import org.apache.log4j.Logger;
 
-import com.cloud.agent.api.Answer;
-import com.cloud.agent.api.AttachIsoCommand;
-import com.cloud.agent.api.AttachVolumeCommand;
-import com.cloud.agent.api.BackupSnapshotCommand;
-import com.cloud.agent.api.CheckHealthCommand;
-import com.cloud.agent.api.CheckNetworkCommand;
-import com.cloud.agent.api.CheckVirtualMachineCommand;
-import com.cloud.agent.api.CleanupNetworkRulesCmd;
-import com.cloud.agent.api.ClusterSyncAnswer;
-import com.cloud.agent.api.ClusterSyncCommand;
-import com.cloud.agent.api.Command;
-import com.cloud.agent.api.ComputeChecksumCommand;
-import com.cloud.agent.api.CreatePrivateTemplateFromSnapshotCommand;
-import com.cloud.agent.api.CreatePrivateTemplateFromVolumeCommand;
-import com.cloud.agent.api.CreateStoragePoolCommand;
-import com.cloud.agent.api.CreateVolumeFromSnapshotCommand;
-import com.cloud.agent.api.DeleteSnapshotBackupCommand;
-import com.cloud.agent.api.DeleteStoragePoolCommand;
-import com.cloud.agent.api.GetDomRVersionCmd;
-import com.cloud.agent.api.GetHostStatsCommand;
-import com.cloud.agent.api.GetStorageStatsCommand;
-import com.cloud.agent.api.GetVmStatsCommand;
-import com.cloud.agent.api.GetVncPortCommand;
-import com.cloud.agent.api.MaintainCommand;
-import com.cloud.agent.api.ManageSnapshotCommand;
-import com.cloud.agent.api.MigrateCommand;
-import com.cloud.agent.api.ModifyStoragePoolCommand;
-import com.cloud.agent.api.NetworkUsageCommand;
-import com.cloud.agent.api.PingTestCommand;
-import com.cloud.agent.api.PrepareForMigrationCommand;
-import com.cloud.agent.api.RebootCommand;
-import com.cloud.agent.api.SecStorageSetupCommand;
-import com.cloud.agent.api.SecStorageVMSetupCommand;
-import com.cloud.agent.api.SecurityGroupRulesCmd;
-import com.cloud.agent.api.StartCommand;
-import com.cloud.agent.api.StopCommand;
-import com.cloud.agent.api.StoragePoolInfo;
 import com.cloud.agent.api.check.CheckSshCommand;
 import com.cloud.agent.api.proxy.CheckConsoleProxyLoadCommand;
 import com.cloud.agent.api.proxy.WatchConsoleProxyLoadCommand;
@@ -292,13 +256,17 @@ public class SimulatorManagerImpl implements SimulatorManager {
                 return _mockAgentMgr.maintain((MaintainCommand)cmd);
             } else if (cmd instanceof GetVmStatsCommand) {
                 return _mockVmMgr.getVmStats((GetVmStatsCommand)cmd);
+            } else if (cmd instanceof CheckRouterCommand) {
+                return _mockVmMgr.checkRouter((CheckRouterCommand) cmd);
+            } else if (cmd instanceof BumpUpPriorityCommand) {
+                return _mockVmMgr.bumpPriority((BumpUpPriorityCommand) cmd);
             } else if (cmd instanceof GetDomRVersionCmd) {
-            	return _mockVmMgr.getDomRVersion((GetDomRVersionCmd)cmd);
+            	return _mockVmMgr.getDomRVersion((GetDomRVersionCmd) cmd);
             } else if (cmd instanceof ClusterSyncCommand) {
             	return new Answer(cmd);
             	//return new ClusterSyncAnswer(((ClusterSyncCommand) cmd).getClusterId(), this.getVmStates(hostGuid));
             } else if (cmd instanceof CopyVolumeCommand) {
-            	return _mockStorageMgr.CopyVolume((CopyVolumeCommand)cmd);
+            	return _mockStorageMgr.CopyVolume((CopyVolumeCommand) cmd);
             } else {
                 return Answer.createUnsupportedCommandAnswer(cmd);
             }


Mime
View raw message