1
0
mirror of https://github.com/OpenNebula/one.git synced 2024-12-22 13:33:52 +03:00

feature #3654: Retry PROLOGs, EPILOGs, SHUTDOWNs and BOOTs through recover. Remove restart action from oned, removed shutdown retries through shutdown

feature #3214: Redo saveas check.

Revert "Feature #3654: Allow to run a shutdown again from shutdown state". This reverts 36afa9c864

Revert "Feature #3654: Allow to run a poweroff/undeploy again from shutdown_poweroff/undeploy". This reverts 9be8b151bc
This commit is contained in:
Ruben S. Montero 2015-04-26 16:47:00 +02:00
parent 3eaffe16d6
commit 41782d01e5
10 changed files with 114 additions and 236 deletions

View File

@ -216,16 +216,6 @@ public:
int vid,
string& error_str);
/**
* Restart a previusly deployed VM.
* @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 restart(
int vid,
string& error_str);
/**
* Ends a VM life cycle inside ONE.
* @param vid VirtualMachine identification

View File

@ -103,9 +103,6 @@ public:
case RESUME_ACTION:
st = "resume";
break;
case BOOT_ACTION:
st = "boot";
break;
case DELETE_ACTION:
st = "delete";
break;
@ -143,6 +140,7 @@ public:
st = "nic-detach";
break;
case NONE_ACTION:
case BOOT_ACTION:
st = "none";
break;
}
@ -196,10 +194,6 @@ public:
{
action = RESUME_ACTION;
}
else if (st == "boot")
{
action = BOOT_ACTION;
}
else if (st == "delete")
{
action = DELETE_ACTION;
@ -248,7 +242,7 @@ public:
{
action = NIC_DETACH_ACTION;
}
else
else //BOOT_ACTION and others
{
action = NONE_ACTION;
return -1;

View File

@ -51,15 +51,15 @@ public:
*/
enum VmState
{
INIT = 0,
PENDING = 1,
HOLD = 2,
ACTIVE = 3,
STOPPED = 4,
SUSPENDED = 5,
DONE = 6,
//FAILED = 7,
POWEROFF = 8,
INIT = 0,
PENDING = 1,
HOLD = 2,
ACTIVE = 3,
STOPPED = 4,
SUSPENDED = 5,
DONE = 6,
//FAILED = 7,
POWEROFF = 8,
UNDEPLOYED = 9
};
@ -117,7 +117,7 @@ public:
EPILOG_STOP = 10,
EPILOG = 11,
SHUTDOWN = 12,
//CANCEL = 13,
//CANCEL = 13,
//FAILURE = 14,
CLEANUP_RESUBMIT = 15,
UNKNOWN = 16,
@ -1252,7 +1252,6 @@ public:
int save_disk(int disk_id,
const string& source,
int img_id);
/**
* Clears the SAVE_AS attribute for the "disk_id"th disk.
* @param disk_id Index of the disk to save

View File

@ -57,8 +57,6 @@ digraph OpenNebula {
shutdown -> running [style="dotted", color="red"];
shutdown -> shutdown [label="shutdown [--hard]"];
suspended -> epilog [label="shutdown [--hard]"];
poweroff -> epilog [label="shutdown [--hard]"];
@ -66,8 +64,6 @@ digraph OpenNebula {
running -> shutdown_poweroff [label="poweroff [--hard]"];
shutdown_poweroff -> poweroff [style="dashed", color="blue"];
shutdown_poweroff -> shutdown_poweroff [label="poweroff [--hard]"];
shutdown_poweroff -> running [style="dotted", color="red"];
# livemigrate
@ -109,8 +105,6 @@ digraph OpenNebula {
shutdown_undeploy -> running [style="dotted", color="red"];
epilog_undeploy -> undeployed [style="dashed", color="blue"];
shutdown_undeploy -> shutdown_undeploy [label="undeploy [--hard]"];
poweroff -> epilog_undeploy [label="undeploy [--hard]"];
# suspend

View File

@ -348,7 +348,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
With --hard it unplugs the VM.
States: RUNNING, UNKNOWN (with --hard), SHUTDOWN
States: RUNNING, UNKNOWN (with --hard)
EOT
command :shutdown, shutdown_desc, [:range,:vmid_list],
@ -371,7 +371,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
With --hard it unplugs the VM.
States: RUNNING, UNKNOWN, SHUTDOWN_UNDEPLOY
States: RUNNING
EOT
command :undeploy, undeploy_desc, [:range,:vmid_list],
@ -393,7 +393,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
Powers off the given VM. The VM will remain in the poweroff state, and
can be powered on with the 'onevm resume' command.
States: RUNNING, UNKNOWN, SHUTDOWN_POWEROFF
States: RUNNING
EOT
command :poweroff, poweroff_desc, [:range,:vmid_list],

View File

@ -240,8 +240,7 @@ int DispatchManager::shutdown (
vm->get_state() == VirtualMachine::SUSPENDED ||
(vm->get_state() == VirtualMachine::ACTIVE &&
(vm->get_lcm_state() == VirtualMachine::RUNNING ||
vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN)))
vm->get_lcm_state() == VirtualMachine::UNKNOWN)))
{
Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm();
@ -301,8 +300,7 @@ int DispatchManager::undeploy(
if ( vm->get_state() == VirtualMachine::POWEROFF ||
(vm->get_state() == VirtualMachine::ACTIVE &&
(vm->get_lcm_state() == VirtualMachine::RUNNING ||
vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY)))
vm->get_lcm_state() == VirtualMachine::UNKNOWN)))
{
Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm();
@ -361,8 +359,7 @@ int DispatchManager::poweroff (
if (vm->get_state() == VirtualMachine::ACTIVE &&
(vm->get_lcm_state() == VirtualMachine::RUNNING ||
vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF))
vm->get_lcm_state() == VirtualMachine::UNKNOWN))
{
Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm();
@ -607,6 +604,9 @@ int DispatchManager::resume(
VirtualMachine * vm;
ostringstream oss;
Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm();
vm = vmpool->get(vid,true);
if ( vm == 0 )
@ -626,16 +626,12 @@ int DispatchManager::resume(
}
else if (vm->get_state() == VirtualMachine::SUSPENDED)
{
Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm();
lcm->trigger(LifeCycleManager::RESTORE,vid);
}
else if (vm->get_state() == VirtualMachine::POWEROFF)
else if ( vm->get_state() == VirtualMachine::POWEROFF ||
(vm->get_state() == VirtualMachine::ACTIVE &&
vm->get_lcm_state() == VirtualMachine::UNKNOWN))
{
Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm();
lcm->trigger(LifeCycleManager::RESTART,vid);
}
else
@ -663,64 +659,6 @@ error:
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int DispatchManager::restart(
int vid,
string& error_str)
{
VirtualMachine * vm;
ostringstream oss;
vm = vmpool->get(vid,true);
if ( vm == 0 )
{
return -1;
}
oss << "Restarting VM " << vid;
NebulaLog::log("DiM",Log::DEBUG,oss);
if (vm->get_state() == VirtualMachine::ACTIVE &&
(vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::BOOT ||
vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF ||
vm->get_lcm_state() == VirtualMachine::BOOT_SUSPENDED ||
vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED ||
vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY ||
vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE ))
{
Nebula& nd = Nebula::instance();
LifeCycleManager * lcm = nd.get_lcm();
lcm->trigger(LifeCycleManager::RESTART,vid);
}
else
{
goto error;
}
vm->unlock();
return 0;
error:
oss.str("");
oss << "Could not restart 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::reboot(
int vid,
bool hard,

View File

@ -411,24 +411,12 @@ void LifeCycleManager::shutdown_action(int vid, bool hard)
if (vm->get_state() == VirtualMachine::ACTIVE &&
(vm->get_lcm_state() == VirtualMachine::RUNNING ||
vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN))
vm->get_lcm_state() == VirtualMachine::UNKNOWN))
{
//----------------------------------------------------
// SHUTDOWN STATE
//----------------------------------------------------
if (vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF)
{
vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid);
}
else
{
vm->set_resched(false);
vmpool->update(vm);
}
vm->set_state(VirtualMachine::SHUTDOWN);
if (hard)
@ -448,6 +436,9 @@ void LifeCycleManager::shutdown_action(int vid, bool hard)
vmm->trigger(VirtualMachineManager::SHUTDOWN,vid);
}
vm->set_resched(false);
vmpool->update(vm);
vmpool->update_history(vm);
}
else if (vm->get_state() == VirtualMachine::SUSPENDED ||
@ -496,25 +487,17 @@ void LifeCycleManager::undeploy_action(int vid, bool hard)
if (vm->get_state() == VirtualMachine::ACTIVE &&
(vm->get_lcm_state() == VirtualMachine::RUNNING ||
vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY))
vm->get_lcm_state() == VirtualMachine::UNKNOWN))
{
//----------------------------------------------------
// SHUTDOWN_UNDEPLOY STATE
//----------------------------------------------------
if (vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY)
{
vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid);
}
else
{
vm->set_state(VirtualMachine::SHUTDOWN_UNDEPLOY);
vm->set_state(VirtualMachine::SHUTDOWN_UNDEPLOY);
vm->set_resched(false);
vm->set_resched(false);
vmpool->update(vm);
}
vmpool->update(vm);
//----------------------------------------------------
@ -597,25 +580,17 @@ void LifeCycleManager::poweroff_action(int vid, bool hard)
if (vm->get_state() == VirtualMachine::ACTIVE &&
(vm->get_lcm_state() == VirtualMachine::RUNNING ||
vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF))
vm->get_lcm_state() == VirtualMachine::UNKNOWN))
{
//----------------------------------------------------
// SHUTDOWN_POWEROFF STATE
//----------------------------------------------------
if (vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF)
{
vmm->trigger(VirtualMachineManager::DRIVER_CANCEL,vid);
}
else
{
vm->set_state(VirtualMachine::SHUTDOWN_POWEROFF);
vm->set_state(VirtualMachine::SHUTDOWN_POWEROFF);
vm->set_resched(false);
vm->set_resched(false);
vmpool->update(vm);
}
vmpool->update(vm);
//----------------------------------------------------
@ -712,74 +687,36 @@ void LifeCycleManager::restart_action(int vid)
return;
}
VirtualMachine::LcmState lstate = vm->get_lcm_state();
VirtualMachine::VmState vstate = vm->get_state();
if (vstate == VirtualMachine::POWEROFF || ( vstate == VirtualMachine::ACTIVE &&
(lstate == VirtualMachine::UNKNOWN || lstate == VirtualMachine::BOOT ||
lstate == VirtualMachine::BOOT_UNKNOWN || lstate == VirtualMachine::BOOT_POWEROFF ||
lstate == VirtualMachine::BOOT_SUSPENDED || lstate == VirtualMachine::BOOT_STOPPED ||
lstate == VirtualMachine::BOOT_UNDEPLOY || lstate == VirtualMachine::BOOT_MIGRATE)))
if (vm->get_state() == VirtualMachine::ACTIVE &&
vm->get_lcm_state() == VirtualMachine::UNKNOWN)
{
VirtualMachineManager::Actions action;
vm->set_state(VirtualMachine::BOOT_UNKNOWN);
//----------------------------------------------------
// RE-START THE VM IN THE SAME HOST
//----------------------------------------------------
vmpool->update(vm);
if (vstate == VirtualMachine::ACTIVE)
{
switch (lstate) {
case VirtualMachine::BOOT:
case VirtualMachine::BOOT_UNKNOWN:
case VirtualMachine::BOOT_POWEROFF:
action = VirtualMachineManager::DEPLOY;
vm->log("LCM", Log::INFO, "Sending BOOT command to VM again");
break;
vmm->trigger(VirtualMachineManager::DEPLOY, vid);
}
else if ( vm->get_state() == VirtualMachine::POWEROFF )
{
time_t the_time = time(0);
case VirtualMachine::BOOT_SUSPENDED:
case VirtualMachine::BOOT_STOPPED:
case VirtualMachine::BOOT_UNDEPLOY:
case VirtualMachine::BOOT_MIGRATE:
action = VirtualMachineManager::RESTORE;
vm->log("LCM", Log::INFO, "Sending RESTORE command to VM again");
break;
vm->set_state(VirtualMachine::ACTIVE); // Only needed by poweroff
case VirtualMachine::UNKNOWN:
action = VirtualMachineManager::DEPLOY;
vm->set_state(VirtualMachine::BOOT_UNKNOWN);
vm->set_state(VirtualMachine::BOOT_POWEROFF);
vmpool->update(vm);
break;
vm->cp_history();
default:
break;
}
vmpool->update(vm);
vmm->trigger(action,vid);
}
else if ( vm->get_state() == VirtualMachine::POWEROFF )
{
time_t the_time = time(0);
vm->set_stime(the_time);
vm->set_state(VirtualMachine::ACTIVE); // Only needed by poweroff
vm->set_last_poll(0);
vm->set_state(VirtualMachine::BOOT_POWEROFF);
vm->set_running_stime(the_time);
vm->cp_history();
vmpool->update_history(vm);
vmpool->update(vm);
vm->set_stime(the_time);
vm->set_last_poll(0);
vm->set_running_stime(the_time);
vmpool->update_history(vm);
vmm->trigger(VirtualMachineManager::DEPLOY, vid);
}
vmm->trigger(VirtualMachineManager::DEPLOY, vid);
}
else
{
@ -807,7 +744,6 @@ void LifeCycleManager::delete_action(int vid)
return;
}
if ( vm->get_state() != VirtualMachine::ACTIVE )
{
vm->log("LCM", Log::ERROR, "clean_action, VM in a wrong state.");
@ -1376,19 +1312,69 @@ void LifeCycleManager::retry(VirtualMachine * vm)
tm->trigger(TransferManager::EPILOG_STOP,vid);
break;
case VirtualMachine::LCM_INIT:
case VirtualMachine::BOOT:
case VirtualMachine::BOOT_MIGRATE:
case VirtualMachine::BOOT_POWEROFF:
case VirtualMachine::BOOT_SUSPENDED:
case VirtualMachine::BOOT_STOPPED:
case VirtualMachine::BOOT_UNDEPLOY:
vmm->trigger(VirtualMachineManager::RESTORE, vid);
break;
case VirtualMachine::BOOT:
case VirtualMachine::BOOT_POWEROFF:
case VirtualMachine::BOOT_UNKNOWN:
case VirtualMachine::CLEANUP_RESUBMIT:
case VirtualMachine::CLEANUP_DELETE:
vmm->trigger(VirtualMachineManager::DEPLOY, vid);
break;
case VirtualMachine::SHUTDOWN:
case VirtualMachine::SHUTDOWN_POWEROFF:
case VirtualMachine::SHUTDOWN_UNDEPLOY:
if (vm->get_action() == History::SHUTDOWN_HARD_ACTION)
{
vmm->trigger(VirtualMachineManager::CANCEL,vid);
}
else
{
vmm->trigger(VirtualMachineManager::SHUTDOWN,vid);
}
break;
case VirtualMachine::SAVE_STOP:
case VirtualMachine::SAVE_SUSPEND:
case VirtualMachine::SAVE_MIGRATE:
vmm->trigger(VirtualMachineManager::SAVE,vid);
break;
case VirtualMachine::MIGRATE:
vmm->trigger(VirtualMachineManager::MIGRATE,vid);
break;
case VirtualMachine::PROLOG:
tm->trigger(TransferManager::PROLOG,vid);
break;
case VirtualMachine::PROLOG_MIGRATE:
case VirtualMachine::PROLOG_MIGRATE_POWEROFF:
case VirtualMachine::PROLOG_MIGRATE_SUSPEND:
tm->trigger(TransferManager::PROLOG_MIGR,vid);
break;
case VirtualMachine::PROLOG_RESUME:
case VirtualMachine::PROLOG_UNDEPLOY:
tm->trigger(TransferManager::PROLOG_RESUME,vid);
break;
case VirtualMachine::EPILOG:
tm->trigger(TransferManager::EPILOG,vid);
break;
case VirtualMachine::EPILOG_STOP:
case VirtualMachine::EPILOG_UNDEPLOY:
tm->trigger(TransferManager::EPILOG_STOP,vid);
break;
case VirtualMachine::LCM_INIT:
case VirtualMachine::CLEANUP_RESUBMIT:
case VirtualMachine::CLEANUP_DELETE:
case VirtualMachine::HOTPLUG:
case VirtualMachine::HOTPLUG_NIC:
case VirtualMachine::HOTPLUG_SNAPSHOT:
@ -1397,20 +1383,7 @@ void LifeCycleManager::retry(VirtualMachine * vm)
case VirtualMachine::HOTPLUG_SAVEAS_SUSPENDED:
case VirtualMachine::HOTPLUG_PROLOG_POWEROFF:
case VirtualMachine::HOTPLUG_EPILOG_POWEROFF:
case VirtualMachine::PROLOG:
case VirtualMachine::PROLOG_MIGRATE:
case VirtualMachine::PROLOG_MIGRATE_POWEROFF:
case VirtualMachine::PROLOG_MIGRATE_SUSPEND:
case VirtualMachine::PROLOG_RESUME:
case VirtualMachine::PROLOG_UNDEPLOY:
case VirtualMachine::MIGRATE:
case VirtualMachine::RUNNING:
case VirtualMachine::SAVE_STOP:
case VirtualMachine::SAVE_SUSPEND:
case VirtualMachine::SAVE_MIGRATE:
case VirtualMachine::SHUTDOWN:
case VirtualMachine::SHUTDOWN_POWEROFF:
case VirtualMachine::SHUTDOWN_UNDEPLOY:
case VirtualMachine::UNKNOWN:
break;
}

View File

@ -190,11 +190,8 @@ int ImageDelete::drop(int oid, PoolObjectSQL * object, string& error_msg)
object->get_template_attribute("SAVE_AS", save_as);
if (save_as)
{
save_as = save_as && object->get_template_attribute("SAVED_VM_ID", vm_id);
save_as = save_as && object->get_template_attribute("SAVED_DISK_ID", disk_id);
}
save_as &= object->get_template_attribute("SAVED_VM_ID", vm_id) &
object->get_template_attribute("SAVED_DISK_ID", disk_id);
object->unlock();

View File

@ -489,10 +489,6 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
{
action_st = "shutdown-hard";
}
else if (action_st == "restart")
{
action_st = "boot";
}
else if (action_st == "finalize")
{
action_st = "delete";
@ -564,9 +560,6 @@ void VirtualMachineAction::request_execute(xmlrpc_c::paramList const& paramList,
case History::RESUME_ACTION:
rc = dm->resume(id, error);
break;
case History::BOOT_ACTION:
rc = dm->restart(id, error);
break;
case History::DELETE_ACTION:
rc = dm->finalize(id, error);
break;

View File

@ -103,7 +103,7 @@ var lcm_state_actions = {
11: //OpenNebula.VM.lcm_state.EPILOG:
[],
12: //OpenNebula.VM.lcm_state.SHUTDOWN:
["VM.shutdown", "VM.shutdown_hard"],
[],
13: //OpenNebula.VM.lcm_state.CANCEL:
[],
14: //OpenNebula.VM.lcm_state.FAILURE:
@ -115,7 +115,7 @@ var lcm_state_actions = {
17: //OpenNebula.VM.lcm_state.HOTPLUG:
[],
18: //OpenNebula.VM.lcm_state.SHUTDOWN_POWEROFF:
["VM.poweroff", "VM.poweroff_hard"],
[],
19: //OpenNebula.VM.lcm_state.BOOT_UNKNOWN:
["VM.boot"],
20: //OpenNebula.VM.lcm_state.BOOT_POWEROFF:
@ -137,7 +137,7 @@ var lcm_state_actions = {
28: //OpenNebula.VM.lcm_state.HOTPLUG_SAVEAS_SUSPENDED:
[],
29: //OpenNebula.VM.lcm_state.SHUTDOWN_UNDEPLOY:
["VM.undeploy", "VM.undeploy_hard"],
[],
30: //OpenNebula.VM.lcm_state.EPILOG_UNDEPLOY:
[],
31: //OpenNebula.VM.lcm_state.PROLOG_UNDEPLOY: