mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
feature #4701: Moved logic to LifeCycleStates
This commit is contained in:
parent
3ccdd7961d
commit
61202c75bf
@ -1141,14 +1141,18 @@ void LifeCycleManager::recover(VirtualMachine * vm, bool success)
|
||||
//----------------------------------------------------------------------
|
||||
case VirtualMachine::PROLOG:
|
||||
case VirtualMachine::PROLOG_MIGRATE:
|
||||
case VirtualMachine::PROLOG_MIGRATE_FAILURE:
|
||||
case VirtualMachine::PROLOG_RESUME:
|
||||
case VirtualMachine::PROLOG_RESUME_FAILURE:
|
||||
case VirtualMachine::PROLOG_UNDEPLOY:
|
||||
case VirtualMachine::PROLOG_UNDEPLOY_FAILURE:
|
||||
case VirtualMachine::PROLOG_FAILURE:
|
||||
case VirtualMachine::PROLOG_MIGRATE_POWEROFF:
|
||||
case VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE:
|
||||
case VirtualMachine::PROLOG_MIGRATE_SUSPEND:
|
||||
case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE:
|
||||
case VirtualMachine::PROLOG_MIGRATE_UNKNOWN:
|
||||
case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE:
|
||||
if (success)
|
||||
{
|
||||
lcm_action = LifeCycleManager::PROLOG_SUCCESS;
|
||||
@ -1159,71 +1163,6 @@ void LifeCycleManager::recover(VirtualMachine * vm, bool success)
|
||||
}
|
||||
break;
|
||||
|
||||
case VirtualMachine::PROLOG_MIGRATE_FAILURE:
|
||||
case VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE:
|
||||
case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE:
|
||||
case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE:
|
||||
if (success)
|
||||
{
|
||||
lcm_action = LifeCycleManager::PROLOG_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
int cpu, mem, disk;
|
||||
vector<VectorAttribute *> pci;
|
||||
|
||||
time_t t = time(0);
|
||||
|
||||
// Close current history record
|
||||
vm->set_prolog_etime(t);
|
||||
vm->set_etime(t);
|
||||
vm->set_reason(History::ERROR);
|
||||
vm->set_action(History::MIGRATE_ACTION);
|
||||
|
||||
vm->set_vm_info();
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
vm->get_requirements(cpu, mem, disk, pci);
|
||||
hpool->del_capacity(vm->get_hid(), vm->get_oid(), cpu, mem, disk, pci);
|
||||
|
||||
// Clone previous history record into a new one
|
||||
vm->cp_previous_history();
|
||||
|
||||
vm->set_stime(t);
|
||||
|
||||
vm->set_prolog_stime(t);
|
||||
|
||||
vm->set_last_poll(0);
|
||||
|
||||
switch (vm->get_lcm_state())
|
||||
{
|
||||
case VirtualMachine::PROLOG_MIGRATE_FAILURE:
|
||||
vm->set_state(VirtualMachine::PROLOG_MIGRATE);
|
||||
break;
|
||||
case VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE:
|
||||
vm->set_state(VirtualMachine::PROLOG_MIGRATE_POWEROFF);
|
||||
break;
|
||||
case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE:
|
||||
vm->set_state(VirtualMachine::PROLOG_MIGRATE_SUSPEND);
|
||||
break;
|
||||
case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE:
|
||||
vm->set_state(VirtualMachine::PROLOG_MIGRATE_UNKNOWN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
vmpool->update(vm); //update last_seq & state
|
||||
vmpool->update_history(vm);
|
||||
|
||||
hpool->add_capacity(vm->get_hid(), vm->get_oid(), cpu, mem, disk, pci);
|
||||
|
||||
lcm_action = LifeCycleManager::PROLOG_SUCCESS;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case VirtualMachine::EPILOG:
|
||||
case VirtualMachine::EPILOG_STOP:
|
||||
case VirtualMachine::EPILOG_UNDEPLOY:
|
||||
|
@ -763,6 +763,11 @@ void LifeCycleManager::prolog_success_action(int vid)
|
||||
|
||||
void LifeCycleManager::prolog_failure_action(int vid)
|
||||
{
|
||||
int cpu, mem, disk;
|
||||
vector<VectorAttribute *> pci;
|
||||
|
||||
time_t t = time(0);
|
||||
|
||||
VirtualMachine * vm = vmpool->get(vid,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
@ -807,10 +812,59 @@ void LifeCycleManager::prolog_failure_action(int vid)
|
||||
vmpool->update(vm);
|
||||
break;
|
||||
|
||||
case VirtualMachine::PROLOG_MIGRATE_FAILURE: //recover failure from failure state
|
||||
//recover failure from failure state
|
||||
case VirtualMachine::PROLOG_MIGRATE_FAILURE:
|
||||
case VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE:
|
||||
case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE:
|
||||
case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE:
|
||||
|
||||
// Close current history record
|
||||
vm->set_prolog_etime(t);
|
||||
vm->set_etime(t);
|
||||
vm->set_reason(History::ERROR);
|
||||
vm->set_action(History::MIGRATE_ACTION);
|
||||
|
||||
vm->set_vm_info();
|
||||
|
||||
vmpool->update_history(vm);
|
||||
|
||||
switch (vm->get_lcm_state())
|
||||
{
|
||||
case VirtualMachine::PROLOG_MIGRATE_FAILURE:
|
||||
vm->set_state(VirtualMachine::PROLOG_MIGRATE);
|
||||
break;
|
||||
case VirtualMachine::PROLOG_MIGRATE_POWEROFF_FAILURE:
|
||||
vm->set_state(VirtualMachine::PROLOG_MIGRATE_POWEROFF);
|
||||
break;
|
||||
case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE:
|
||||
vm->set_state(VirtualMachine::PROLOG_MIGRATE_SUSPEND);
|
||||
break;
|
||||
case VirtualMachine::PROLOG_MIGRATE_UNKNOWN_FAILURE:
|
||||
vm->set_state(VirtualMachine::PROLOG_MIGRATE_UNKNOWN);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
vm->get_requirements(cpu, mem, disk, pci);
|
||||
|
||||
hpool->del_capacity(vm->get_hid(), vm->get_oid(), cpu,mem,disk,pci);
|
||||
|
||||
// Clone previous history record into a new one
|
||||
vm->cp_previous_history();
|
||||
|
||||
vm->set_stime(t);
|
||||
vm->set_prolog_stime(t);
|
||||
vm->set_last_poll(0);
|
||||
|
||||
vmpool->update(vm); //update last_seq & state
|
||||
vmpool->update_history(vm);
|
||||
|
||||
hpool->add_capacity(vm->get_hid(), vm->get_oid(), cpu,mem,disk,pci);
|
||||
|
||||
trigger(LifeCycleManager::PROLOG_SUCCESS, vm->get_oid());
|
||||
break;
|
||||
|
||||
case VirtualMachine::PROLOG_RESUME_FAILURE:
|
||||
case VirtualMachine::PROLOG_UNDEPLOY_FAILURE:
|
||||
case VirtualMachine::PROLOG_FAILURE:
|
||||
|
Loading…
x
Reference in New Issue
Block a user