mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
Feature #3654: Merge Dispatch Manager reset with reboot
This commit is contained in:
parent
36afa9c864
commit
55dd9304bc
@ -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);
|
||||
|
||||
/**
|
||||
|
@ -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,
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user