Correcting the reboot vm command

reviewed-by : Marvin (vm lifecycle test)
This commit is contained in:
Prasanna Santhanam 2012-08-23 21:26:59 +05:30
parent 4f9194c778
commit de026f947c
1 changed files with 20 additions and 3 deletions

View File

@ -476,9 +476,26 @@ public class MockVmManagerImpl implements MockVmManager {
}
@Override
public Answer rebootVM(RebootCommand cmd) {
return new RebootAnswer(cmd, "Rebooted "+cmd.getVmName(), false);
}
public Answer rebootVM(RebootCommand cmd) {
Transaction txn = Transaction.open(Transaction.SIMULATOR_DB);
try {
txn.start();
MockVm vm = _mockVmDao.findByVmName(cmd.getVmName());
if (vm != null) {
vm.setState(State.Running);
_mockVmDao.update(vm.getId(), (MockVMVO) vm);
}
txn.commit();
return new RebootAnswer(cmd, "Rebooted " + cmd.getVmName(), true);
} catch (Exception ex) {
txn.rollback();
throw new CloudRuntimeException("unable to stop vm " + cmd.getVmName(), ex);
} finally {
txn.close();
txn = Transaction.open(Transaction.CLOUD_DB);
txn.close();
}
}
@Override
public Answer getVncPort(GetVncPortCommand cmd) {