incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alena1...@apache.org
Subject [30/30] git commit: Implementing Migration and Maintenance mode for the simulator
Date Fri, 03 Aug 2012 21:33:31 GMT
Implementing Migration and Maintenance mode for the simulator


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

Branch: refs/heads/vpc
Commit: 87bcd8e1165b61b6ccc598d1745cfdf4085e3194
Parents: befd6dd
Author: Prasanna Santhanam <Prasanna.Santhanam@citrix.com>
Authored: Fri Aug 3 15:55:01 2012 +0530
Committer: Prasanna Santhanam <Prasanna.Santhanam@citrix.com>
Committed: Fri Aug 3 15:55:01 2012 +0530

----------------------------------------------------------------------
 .../com/cloud/agent/manager/MockAgentManager.java  |    4 ++--
 .../cloud/agent/manager/MockAgentManagerImpl.java  |   11 +++++++----
 .../src/com/cloud/agent/manager/MockVmManager.java |    2 +-
 .../com/cloud/agent/manager/MockVmManagerImpl.java |    4 ++--
 .../com/cloud/resource/AgentRoutingResource.java   |    5 ++---
 5 files changed, 14 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/87bcd8e1/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java b/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java
index e01b016..9932173 100644
--- a/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java
+++ b/agent-simulator/src/com/cloud/agent/manager/MockAgentManager.java
@@ -50,11 +50,11 @@ public interface MockAgentManager extends Manager {
     Answer checkHealth(CheckHealthCommand cmd);
     Answer pingTest(PingTestCommand cmd);
     
-    Answer PrepareForMigration(PrepareForMigrationCommand cmd);
+    Answer prepareForMigrate(PrepareForMigrationCommand cmd);
     
     MockHost getHost(String guid);
 
-    Answer MaintainCommand(MaintainCommand cmd);
+    Answer maintain(MaintainCommand cmd);
 
 	Answer checkNetworkCommand(CheckNetworkCommand cmd);
 }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/87bcd8e1/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java b/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
index 356c257..0dd8f05 100755
--- a/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
+++ b/agent-simulator/src/com/cloud/agent/manager/MockAgentManagerImpl.java
@@ -45,10 +45,9 @@ import com.cloud.agent.api.MaintainAnswer;
 import com.cloud.agent.api.PingTestCommand;
 import com.cloud.agent.api.PrepareForMigrationAnswer;
 import com.cloud.agent.api.PrepareForMigrationCommand;
-import com.cloud.agent.api.StartupCommand;
+import com.cloud.agent.api.to.VirtualMachineTO;
 import com.cloud.dc.dao.HostPodDao;
 import com.cloud.host.Host;
-import com.cloud.host.Host.Type;
 import com.cloud.resource.AgentResourceBase;
 import com.cloud.resource.AgentRoutingResource;
 import com.cloud.resource.AgentStorageResource;
@@ -340,7 +339,11 @@ public class MockAgentManagerImpl implements MockAgentManager {
 
 
     @Override
-    public PrepareForMigrationAnswer PrepareForMigration(PrepareForMigrationCommand cmd)
{
+    public PrepareForMigrationAnswer prepareForMigrate(PrepareForMigrationCommand cmd) {
+    	VirtualMachineTO vm = cmd.getVirtualMachine();
+        if (s_logger.isDebugEnabled()) {
+            s_logger.debug("Preparing host for migrating " + vm);
+        }
         return new PrepareForMigrationAnswer(cmd);
     }
 
@@ -364,7 +367,7 @@ public class MockAgentManagerImpl implements MockAgentManager {
 
 
     @Override
-    public MaintainAnswer MaintainCommand(com.cloud.agent.api.MaintainCommand cmd) {
+    public MaintainAnswer maintain(com.cloud.agent.api.MaintainCommand cmd) {
         return new MaintainAnswer(cmd);
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/87bcd8e1/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 179544d..cd8f5fa 100644
--- a/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java
+++ b/agent-simulator/src/com/cloud/agent/manager/MockVmManager.java
@@ -55,7 +55,7 @@ public interface MockVmManager extends Manager {
     public Answer stopVM(StopCommand cmd);
 	public Answer rebootVM(RebootCommand cmd);
     
-    public Answer checkVmState(CheckVirtualMachineCommand cmd, String hostGuid);
+    public Answer checkVmState(CheckVirtualMachineCommand cmd);
     public Map<String, State> getVmStates(String hostGuid);
     public Answer getVncPort(GetVncPortCommand cmd);
 

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/87bcd8e1/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 5e66464..9f420be 100644
--- a/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
+++ b/agent-simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
@@ -243,8 +243,8 @@ public class MockVmManagerImpl implements MockVmManager {
     }
 
     @Override
-    public CheckVirtualMachineAnswer checkVmState(CheckVirtualMachineCommand cmd, String
hostGuid) {
-        MockVMVO vm = _mockVmDao.findByVmNameAndHost(cmd.getVmName(), hostGuid);
+    public CheckVirtualMachineAnswer checkVmState(CheckVirtualMachineCommand cmd) {
+        MockVMVO vm = _mockVmDao.findByVmName(cmd.getVmName());
         if (vm == null) {
             return new CheckVirtualMachineAnswer(cmd, "can't find vm:" + cmd.getVmName());
         }

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/87bcd8e1/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java
----------------------------------------------------------------------
diff --git a/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java b/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java
index 291e46a..f10713d 100644
--- a/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java
+++ b/agent-simulator/src/com/cloud/resource/AgentRoutingResource.java
@@ -33,6 +33,7 @@ import com.cloud.agent.api.CheckVirtualMachineCommand;
 import com.cloud.agent.api.Command;
 import com.cloud.agent.api.PingCommand;
 import com.cloud.agent.api.PingRoutingWithNwGroupsCommand;
+import com.cloud.agent.api.PrepareForMigrationAnswer;
 import com.cloud.agent.api.PrepareForMigrationCommand;
 import com.cloud.agent.api.ReadyAnswer;
 import com.cloud.agent.api.ReadyCommand;
@@ -85,8 +86,6 @@ public class AgentRoutingResource extends AgentStorageResource {
                 return execute((StartCommand) cmd);
             } else if (cmd instanceof StopCommand) {
                 return execute((StopCommand) cmd);
-            } else if (cmd instanceof PrepareForMigrationCommand) {
-                return execute((PrepareForMigrationCommand) cmd);
             } else if (cmd instanceof CheckVirtualMachineCommand) {
                 return execute((CheckVirtualMachineCommand) cmd);
             } else if (cmd instanceof ReadyCommand) {
@@ -191,7 +190,7 @@ public class AgentRoutingResource extends AgentStorageResource {
 		String vmName = vmSpec.getName();
 		if (this.totalCpu < (vmSpec.getCpus() * vmSpec.getSpeed() + this.usedCpu) ||
 			this.totalMem < (vmSpec.getMaxRam() + this.usedMem)) {
-			return new StartAnswer(cmd, "No enough resource to start the vm"); 
+			return new StartAnswer(cmd, "Not enough resource to start the vm"); 
 		}
 		State state = State.Stopped;
 		synchronized (_vms) {


Mime
View raw message