diff --git a/include/DispatchManager.h b/include/DispatchManager.h index df78ddb9a0..80d3912ef4 100644 --- a/include/DispatchManager.h +++ b/include/DispatchManager.h @@ -249,21 +249,13 @@ public: /** * Reboots a VM preserving any resource and RUNNING state * @param vid VirtualMachine identification + * @param hard True to force the shutdown (cancel instead of shutdown) * @return 0 on success, -1 if the VM does not exits or -2 if the VM is * in a wrong a state */ int reboot( int vid, - string& error_str); - - /** - * Resets a VM preserving any resource and RUNNING state - * @param vid VirtualMachine identification - * @return 0 on success, -1 if the VM does not exits or -2 if the VM is - * in a wrong a state - */ - int reset( - int vid, + bool hard, string& error_str); /** diff --git a/src/dm/DispatchManagerActions.cc b/src/dm/DispatchManagerActions.cc index d20e6e5dbc..39b97fb355 100644 --- a/src/dm/DispatchManagerActions.cc +++ b/src/dm/DispatchManagerActions.cc @@ -723,6 +723,7 @@ error: int DispatchManager::reboot( int vid, + bool hard, string& error_str) { VirtualMachine * vm; @@ -744,7 +745,14 @@ int DispatchManager::reboot( Nebula& nd = Nebula::instance(); VirtualMachineManager * vmm = nd.get_vmm(); - vmm->trigger(VirtualMachineManager::REBOOT,vid); + if (hard) + { + vmm->trigger(VirtualMachineManager::RESET,vid); + } + else + { + vmm->trigger(VirtualMachineManager::REBOOT,vid); + } vm->set_resched(false); //Rebooting cancels re-scheduling actions @@ -776,61 +784,6 @@ error: /* -------------------------------------------------------------------------- */ /* -------------------------------------------------------------------------- */ -int DispatchManager::reset( - int vid, - string& error_str) -{ - VirtualMachine * vm; - ostringstream oss; - - vm = vmpool->get(vid,true); - - if ( vm == 0 ) - { - return -1; - } - - oss << "Resetting VM " << vid; - NebulaLog::log("DiM",Log::DEBUG,oss); - - if (vm->get_state() == VirtualMachine::ACTIVE && - vm->get_lcm_state() == VirtualMachine::RUNNING ) - { - Nebula& nd = Nebula::instance(); - VirtualMachineManager * vmm = nd.get_vmm(); - - vmm->trigger(VirtualMachineManager::RESET,vid); - - vm->set_resched(false); //Resetting cancels re-scheduling actions - - vmpool->update(vm); - } - else - { - goto error; - } - - vm->unlock(); - - return 0; - -error: - oss.str(""); - oss << "Could not reset VM " << vid << ", wrong state."; - NebulaLog::log("DiM",Log::ERROR,oss); - - oss.str(""); - oss << "This action is not available for state " << vm->state_str(); - error_str = oss.str(); - - vm->unlock(); - - return -2; -} - -/* -------------------------------------------------------------------------- */ -/* -------------------------------------------------------------------------- */ - int DispatchManager::resched( int vid, bool do_resched, diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 999c8db2ed..e6261db77f 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -574,7 +574,7 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList, rc = dm->resubmit(id, error); break; case History::REBOOT_ACTION: - rc = dm->reboot(id, error); + rc = dm->reboot(id, false, error); break; case History::RESCHED_ACTION: rc = dm->resched(id, true, error); @@ -583,7 +583,7 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList, rc = dm->resched(id, false, error); break; case History::REBOOT_HARD_ACTION: - rc = dm->reset(id, error); + rc = dm->reboot(id, true, error); break; case History::POWEROFF_ACTION: rc = dm->poweroff(id, false, error);