Repository: cloudstack
Updated Branches:
  refs/heads/master 8bc029401 -> 53cba7c74


Made following fixes in simulator
- Support for ScaleVmCommand/NetworkRulesVmSecondaryIpCommand in resource layer
- Added support for scaling up a running VM in simulator
- Fixed some method names not following convention


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

Branch: refs/heads/master
Commit: 86684cd4bc1966ffcc4b337641fc8bf814724eb1
Parents: 2772e4d
Author: Koushik Das <[email protected]>
Authored: Tue Aug 25 14:52:48 2015 +0530
Committer: Koushik Das <[email protected]>
Committed: Tue Aug 25 14:52:48 2015 +0530

----------------------------------------------------------------------
 .../com/cloud/agent/manager/MockVmManager.java  | 12 +++---
 .../cloud/agent/manager/MockVmManagerImpl.java  | 45 +++++++++++++++-----
 .../agent/manager/SimulatorManagerImpl.java     | 12 +++---
 server/src/com/cloud/vm/UserVmManagerImpl.java  |  2 +-
 4 files changed, 47 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86684cd4/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManager.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManager.java 
b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManager.java
index 44c652a..df2703d 100644
--- 
a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManager.java
+++ 
b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManager.java
@@ -81,23 +81,23 @@ public interface MockVmManager extends Manager {
 
     Answer setVmData(VmDataCommand cmd);
 
-    Answer CheckConsoleProxyLoad(CheckConsoleProxyLoadCommand cmd);
+    Answer checkConsoleProxyLoad(CheckConsoleProxyLoadCommand cmd);
 
-    Answer WatchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd);
+    Answer watchConsoleProxyLoad(WatchConsoleProxyLoadCommand cmd);
 
-    Answer SavePassword(SavePasswordCommand cmd);
+    Answer savePassword(SavePasswordCommand cmd);
 
-    MigrateAnswer Migrate(MigrateCommand cmd, SimulatorInfo info);
+    MigrateAnswer migrate(MigrateCommand cmd, SimulatorInfo info);
 
     PrepareForMigrationAnswer prepareForMigrate(PrepareForMigrationCommand 
cmd);
 
-    SecurityGroupRuleAnswer AddSecurityGroupRules(SecurityGroupRulesCmd cmd, 
SimulatorInfo info);
+    SecurityGroupRuleAnswer addSecurityGroupRules(SecurityGroupRulesCmd cmd, 
SimulatorInfo info);
 
     GetDomRVersionAnswer getDomRVersion(GetDomRVersionCmd cmd);
 
     CheckRouterAnswer checkRouter(CheckRouterCommand cmd);
 
-    Answer CleanupNetworkRules(CleanupNetworkRulesCmd cmd, SimulatorInfo info);
+    Answer cleanupNetworkRules(CleanupNetworkRulesCmd cmd, SimulatorInfo info);
 
     Answer scaleVm(ScaleVmCommand cmd);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86684cd4/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 dbe8ade..d580295 100644
--- 
a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
+++ 
b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
@@ -57,6 +57,7 @@ import com.cloud.agent.api.RebootAnswer;
 import com.cloud.agent.api.RebootCommand;
 import com.cloud.agent.api.RevertToVMSnapshotAnswer;
 import com.cloud.agent.api.RevertToVMSnapshotCommand;
+import com.cloud.agent.api.ScaleVmAnswer;
 import com.cloud.agent.api.ScaleVmCommand;
 import com.cloud.agent.api.SecurityGroupRuleAnswer;
 import com.cloud.agent.api.SecurityGroupRulesCmd;
@@ -248,7 +249,7 @@ public class MockVmManagerImpl extends ManagerBase 
implements MockVmManager {
             return vmMap;
         } catch (final Exception ex) {
             txn.rollback();
-            throw new CloudRuntimeException("unable to fetch vms  from host " 
+ hostGuid, ex);
+            throw new CloudRuntimeException("unable to fetch vms from host " + 
hostGuid, ex);
         } finally {
             txn.close();
             txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
@@ -292,7 +293,7 @@ public class MockVmManagerImpl extends ManagerBase 
implements MockVmManager {
             return states;
         } catch (final Exception ex) {
             txn.rollback();
-            throw new CloudRuntimeException("unable to fetch vms  from host " 
+ hostGuid, ex);
+            throw new CloudRuntimeException("unable to fetch vms from host " + 
hostGuid, ex);
         } finally {
             txn.close();
             txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
@@ -369,7 +370,7 @@ public class MockVmManagerImpl extends ManagerBase 
implements MockVmManager {
     }
 
     @Override
-    public MigrateAnswer Migrate(final MigrateCommand cmd, final SimulatorInfo 
info) {
+    public MigrateAnswer migrate(final MigrateCommand cmd, final SimulatorInfo 
info) {
         TransactionLegacy txn = 
TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
         try {
             txn.start();
@@ -382,7 +383,7 @@ public class MockVmManagerImpl extends ManagerBase 
implements MockVmManager {
 
             final MockHost destHost = _mockHostDao.findByGuid(destGuid);
             if (destHost == null) {
-                return new MigrateAnswer(cmd, false, "can;t find host:" + 
info.getHostUuid(), null);
+                return new MigrateAnswer(cmd, false, "can't find destination 
host:" + destGuid, null);
             }
             vm.setHostId(destHost.getId());
             _mockVmDao.update(vm.getId(), vm);
@@ -424,7 +425,7 @@ public class MockVmManagerImpl extends ManagerBase 
implements MockVmManager {
     }
 
     @Override
-    public Answer CleanupNetworkRules(final CleanupNetworkRulesCmd cmd, final 
SimulatorInfo info) {
+    public Answer cleanupNetworkRules(final CleanupNetworkRulesCmd cmd, final 
SimulatorInfo info) {
         TransactionLegacy txn = 
TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
         try {
             txn.start();
@@ -449,12 +450,34 @@ public class MockVmManagerImpl extends ManagerBase 
implements MockVmManager {
 
     @Override
     public Answer scaleVm(final ScaleVmCommand cmd) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        TransactionLegacy txn = 
TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
+        try {
+            txn.start();
+            final String vmName = cmd.getVmName();
+            final MockVMVO vm = _mockVmDao.findByVmName(vmName);
+            if (vm == null) {
+                return new ScaleVmAnswer(cmd, false, "Can't find VM " + 
vmName);
+            }
+            vm.setCpu(cmd.getCpus() * cmd.getMaxSpeed());
+            vm.setMemory(cmd.getMaxRam());
+            _mockVmDao.update(vm.getId(), vm);
+            s_logger.debug("Scaled up VM " + vmName);
+            txn.commit();
+            return new ScaleVmAnswer(cmd, true, null);
+        } catch (final Exception ex) {
+            txn.rollback();
+            throw new CloudRuntimeException("Unable to scale up VM", ex);
+        } finally {
+            txn.close();
+            txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
+            txn.close();
+        }
     }
 
     @Override
     public Answer plugSecondaryIp(final NetworkRulesVmSecondaryIpCommand cmd) {
-        return null;  //To change body of implemented methods use File | 
Settings | File Templates.
+        s_logger.debug("Plugged secondary IP to VM " + cmd.getVmName());
+        return new Answer(cmd, true, null);
     }
 
     @Override
@@ -527,12 +550,12 @@ public class MockVmManagerImpl extends ManagerBase 
implements MockVmManager {
     }
 
     @Override
-    public Answer CheckConsoleProxyLoad(final CheckConsoleProxyLoadCommand 
cmd) {
+    public Answer checkConsoleProxyLoad(final CheckConsoleProxyLoadCommand 
cmd) {
         return Answer.createUnsupportedCommandAnswer(cmd);
     }
 
     @Override
-    public Answer WatchConsoleProxyLoad(final WatchConsoleProxyLoadCommand 
cmd) {
+    public Answer watchConsoleProxyLoad(final WatchConsoleProxyLoadCommand 
cmd) {
         return Answer.createUnsupportedCommandAnswer(cmd);
     }
 
@@ -543,7 +566,7 @@ public class MockVmManagerImpl extends ManagerBase 
implements MockVmManager {
     }
 
     @Override
-    public SecurityGroupRuleAnswer AddSecurityGroupRules(final 
SecurityGroupRulesCmd cmd, final SimulatorInfo info) {
+    public SecurityGroupRuleAnswer addSecurityGroupRules(final 
SecurityGroupRulesCmd cmd, final SimulatorInfo info) {
         if (!info.isEnabled()) {
             return new SecurityGroupRuleAnswer(cmd, false, "Disabled", 
SecurityGroupRuleAnswer.FailureReason.CANNOT_BRIDGE_FIREWALL);
         }
@@ -611,7 +634,7 @@ public class MockVmManagerImpl extends ManagerBase 
implements MockVmManager {
     }
 
     @Override
-    public Answer SavePassword(final SavePasswordCommand cmd) {
+    public Answer savePassword(final SavePasswordCommand cmd) {
         return new Answer(cmd);
     }
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86684cd4/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
 
b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
index bd7e9e8..9ba135a 100644
--- 
a/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
+++ 
b/plugins/hypervisors/simulator/src/com/cloud/agent/manager/SimulatorManagerImpl.java
@@ -286,7 +286,7 @@ public class SimulatorManagerImpl extends ManagerBase 
implements SimulatorManage
                 } else if (cmd instanceof PrepareForMigrationCommand) {
                     answer = 
_mockVmMgr.prepareForMigrate((PrepareForMigrationCommand)cmd);
                 } else if (cmd instanceof MigrateCommand) {
-                    answer = _mockVmMgr.Migrate((MigrateCommand)cmd, info);
+                    answer = _mockVmMgr.migrate((MigrateCommand)cmd, info);
                 } else if (cmd instanceof StartCommand) {
                     answer = _mockVmMgr.startVM((StartCommand)cmd, info);
                 } else if (cmd instanceof CheckSshCommand) {
@@ -310,7 +310,7 @@ public class SimulatorManagerImpl extends ManagerBase 
implements SimulatorManage
                 } else if (cmd instanceof VmDataCommand) {
                     answer = _mockVmMgr.setVmData((VmDataCommand)cmd);
                 } else if (cmd instanceof CleanupNetworkRulesCmd) {
-                    answer = 
_mockVmMgr.CleanupNetworkRules((CleanupNetworkRulesCmd)cmd, info);
+                    answer = 
_mockVmMgr.cleanupNetworkRules((CleanupNetworkRulesCmd)cmd, info);
                 } else if (cmd instanceof CheckNetworkCommand) {
                     answer = 
_mockAgentMgr.checkNetworkCommand((CheckNetworkCommand)cmd);
                 } else if (cmd instanceof StopCommand) {
@@ -320,13 +320,13 @@ public class SimulatorManagerImpl extends ManagerBase 
implements SimulatorManage
                 } else if (cmd instanceof GetVncPortCommand) {
                     answer = _mockVmMgr.getVncPort((GetVncPortCommand)cmd);
                 } else if (cmd instanceof CheckConsoleProxyLoadCommand) {
-                    answer = 
_mockVmMgr.CheckConsoleProxyLoad((CheckConsoleProxyLoadCommand)cmd);
+                    answer = 
_mockVmMgr.checkConsoleProxyLoad((CheckConsoleProxyLoadCommand)cmd);
                 } else if (cmd instanceof WatchConsoleProxyLoadCommand) {
-                    answer = 
_mockVmMgr.WatchConsoleProxyLoad((WatchConsoleProxyLoadCommand)cmd);
+                    answer = 
_mockVmMgr.watchConsoleProxyLoad((WatchConsoleProxyLoadCommand)cmd);
                 } else if (cmd instanceof SecurityGroupRulesCmd) {
-                    answer = 
_mockVmMgr.AddSecurityGroupRules((SecurityGroupRulesCmd)cmd, info);
+                    answer = 
_mockVmMgr.addSecurityGroupRules((SecurityGroupRulesCmd)cmd, info);
                 } else if (cmd instanceof SavePasswordCommand) {
-                    answer = _mockVmMgr.SavePassword((SavePasswordCommand)cmd);
+                    answer = _mockVmMgr.savePassword((SavePasswordCommand)cmd);
                 } else if (cmd instanceof PrimaryStorageDownloadCommand) {
                     answer = 
_mockStorageMgr.primaryStorageDownload((PrimaryStorageDownloadCommand)cmd);
                 } else if (cmd instanceof CreateCommand) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/86684cd4/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java 
b/server/src/com/cloud/vm/UserVmManagerImpl.java
index d26a84d..ac51363 100644
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -1500,7 +1500,7 @@ public class UserVmManagerImpl extends ManagerBase 
implements UserVmManager, Vir
 
         Account caller = CallContext.current().getCallingAccount();
         VMInstanceVO vmInstance = _vmInstanceDao.findById(vmId);
-        if (vmInstance.getHypervisorType() != HypervisorType.XenServer && 
vmInstance.getHypervisorType() != HypervisorType.VMware) {
+        if (vmInstance.getHypervisorType() != HypervisorType.XenServer && 
vmInstance.getHypervisorType() != HypervisorType.VMware && 
vmInstance.getHypervisorType() != HypervisorType.Simulator) {
             s_logger.info("Scaling the VM dynamically is not supported for VMs 
running on Hypervisor "+vmInstance.getHypervisorType());
             throw new InvalidParameterValueException("Scaling the VM 
dynamically is not supported for VMs running on Hypervisor 
"+vmInstance.getHypervisorType());
         }

Reply via email to