cloudstack-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From koushik-das <...@git.apache.org>
Subject [GitHub] cloudstack pull request: Made following fixes in simulator
Date Wed, 26 Aug 2015 08:04:50 GMT
Github user koushik-das commented on a diff in the pull request:

    https://github.com/apache/cloudstack/pull/741#discussion_r37955517
  
    --- Diff: plugins/hypervisors/simulator/src/com/cloud/agent/manager/MockVmManagerImpl.java
---
    @@ -449,12 +450,34 @@ public Answer CleanupNetworkRules(final CleanupNetworkRulesCmd cmd,
final Simula
     
         @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);
    --- End diff --
    
    @miguelaferreira That is the current way of switching between DB's (in this case simulator
and cloud). If you look at some of the other command handlers in the simulator you will see
a similar pattern.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message