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
|
* Reboots a VM preserving any resource and RUNNING state
|
||||||
* @param vid VirtualMachine identification
|
* @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
|
* @return 0 on success, -1 if the VM does not exits or -2 if the VM is
|
||||||
* in a wrong a state
|
* in a wrong a state
|
||||||
*/
|
*/
|
||||||
int reboot(
|
int reboot(
|
||||||
int vid,
|
int vid,
|
||||||
string& error_str);
|
bool hard,
|
||||||
|
|
||||||
/**
|
|
||||||
* 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,
|
|
||||||
string& error_str);
|
string& error_str);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -723,6 +723,7 @@ error:
|
|||||||
|
|
||||||
int DispatchManager::reboot(
|
int DispatchManager::reboot(
|
||||||
int vid,
|
int vid,
|
||||||
|
bool hard,
|
||||||
string& error_str)
|
string& error_str)
|
||||||
{
|
{
|
||||||
VirtualMachine * vm;
|
VirtualMachine * vm;
|
||||||
@ -744,7 +745,14 @@ int DispatchManager::reboot(
|
|||||||
Nebula& nd = Nebula::instance();
|
Nebula& nd = Nebula::instance();
|
||||||
VirtualMachineManager * vmm = nd.get_vmm();
|
VirtualMachineManager * vmm = nd.get_vmm();
|
||||||
|
|
||||||
|
if (hard)
|
||||||
|
{
|
||||||
|
vmm->trigger(VirtualMachineManager::RESET,vid);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
vmm->trigger(VirtualMachineManager::REBOOT,vid);
|
vmm->trigger(VirtualMachineManager::REBOOT,vid);
|
||||||
|
}
|
||||||
|
|
||||||
vm->set_resched(false); //Rebooting cancels re-scheduling actions
|
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 DispatchManager::resched(
|
||||||
int vid,
|
int vid,
|
||||||
bool do_resched,
|
bool do_resched,
|
||||||
|
@ -574,7 +574,7 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
|
|||||||
rc = dm->resubmit(id, error);
|
rc = dm->resubmit(id, error);
|
||||||
break;
|
break;
|
||||||
case History::REBOOT_ACTION:
|
case History::REBOOT_ACTION:
|
||||||
rc = dm->reboot(id, error);
|
rc = dm->reboot(id, false, error);
|
||||||
break;
|
break;
|
||||||
case History::RESCHED_ACTION:
|
case History::RESCHED_ACTION:
|
||||||
rc = dm->resched(id, true, error);
|
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);
|
rc = dm->resched(id, false, error);
|
||||||
break;
|
break;
|
||||||
case History::REBOOT_HARD_ACTION:
|
case History::REBOOT_HARD_ACTION:
|
||||||
rc = dm->reset(id, error);
|
rc = dm->reboot(id, true, error);
|
||||||
break;
|
break;
|
||||||
case History::POWEROFF_ACTION:
|
case History::POWEROFF_ACTION:
|
||||||
rc = dm->poweroff(id, false, error);
|
rc = dm->poweroff(id, false, error);
|
||||||
|
Loading…
Reference in New Issue
Block a user