mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
Feature #3654: LCM updates the VM life cycle with the poll info
This commit is contained in:
parent
5c0cd43d42
commit
08f32913eb
@ -238,8 +238,11 @@ void MonitorThread::do_message()
|
||||
// 2.- It is supposed to be in RUNNING state
|
||||
// 3.- It has been monitored at least once
|
||||
if (vm->hasHistory() &&
|
||||
vm->get_lcm_state() == VirtualMachine::RUNNING &&
|
||||
vm->get_last_poll() != 0)
|
||||
vm->get_last_poll() != 0 &&
|
||||
( vm->get_lcm_state() == VirtualMachine::RUNNING ||
|
||||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN ||
|
||||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF ||
|
||||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY))
|
||||
{
|
||||
lcm->trigger(LifeCycleManager::MONITOR_POWEROFF, *its);
|
||||
}
|
||||
|
@ -1106,12 +1106,14 @@ void LifeCycleManager::monitor_poweroff_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
//This event should be ignored if the VM is not RUNNING
|
||||
if ( vm->get_lcm_state() == VirtualMachine::RUNNING )
|
||||
{
|
||||
//----------------------------------------------------
|
||||
// POWEROFF STATE
|
||||
//----------------------------------------------------
|
||||
|
||||
vm->log("LCM",Log::INFO,"VM running but monitor state is POWEROFF");
|
||||
|
||||
time_t the_time = time(0);
|
||||
|
||||
vm->delete_snapshots();
|
||||
@ -1137,6 +1139,14 @@ void LifeCycleManager::monitor_poweroff_action(int vid)
|
||||
//----------------------------------------------------
|
||||
|
||||
dm->trigger(DispatchManager::POWEROFF_SUCCESS,vid);
|
||||
|
||||
} else if ( vm->get_lcm_state() == VirtualMachine::SHUTDOWN ||
|
||||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF ||
|
||||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY )
|
||||
{
|
||||
vm->log("LCM", Log::INFO, "VM reported SHUTDOWN by the drivers");
|
||||
|
||||
trigger(LifeCycleManager::SHUTDOWN_SUCCESS, vid);
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
@ -1156,9 +1166,10 @@ void LifeCycleManager::monitor_poweron_action(int vid)
|
||||
return;
|
||||
}
|
||||
|
||||
//This event should be ignored if the VM is not POWEROFF
|
||||
if ( vm->get_state() == VirtualMachine::POWEROFF )
|
||||
{
|
||||
vm->log("VMM",Log::INFO,"VM found again by the drivers");
|
||||
|
||||
time_t the_time = time(0);
|
||||
|
||||
vm->set_state(VirtualMachine::ACTIVE);
|
||||
@ -1177,6 +1188,36 @@ void LifeCycleManager::monitor_poweron_action(int vid)
|
||||
|
||||
vmpool->update_history(vm);
|
||||
}
|
||||
else if ( vm->get_state() == VirtualMachine::ACTIVE )
|
||||
{
|
||||
switch (vm->get_lcm_state()) {
|
||||
case VirtualMachine::UNKNOWN:
|
||||
vm->log("LCM", Log::INFO, "VM found again by the drivers");
|
||||
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
vmpool->update(vm);
|
||||
break;
|
||||
|
||||
case VirtualMachine::BOOT:
|
||||
case VirtualMachine::BOOT_POWEROFF:
|
||||
case VirtualMachine::BOOT_UNKNOWN :
|
||||
case VirtualMachine::BOOT_SUSPENDED:
|
||||
case VirtualMachine::BOOT_STOPPED:
|
||||
case VirtualMachine::BOOT_UNDEPLOY:
|
||||
case VirtualMachine::BOOT_MIGRATE:
|
||||
case VirtualMachine::BOOT_MIGRATE_FAILURE:
|
||||
case VirtualMachine::BOOT_STOPPED_FAILURE:
|
||||
case VirtualMachine::BOOT_UNDEPLOY_FAILURE:
|
||||
case VirtualMachine::BOOT_FAILURE:
|
||||
vm->log("LCM", Log::INFO, "VM reported RUNNING by the drivers");
|
||||
|
||||
trigger(LifeCycleManager::DEPLOY_SUCCESS, vid);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
}
|
||||
|
@ -657,50 +657,60 @@ void VirtualMachineManagerDriver::process_poll(
|
||||
/* Process the VM state from the monitoring info */
|
||||
/* ---------------------------------------------------------------------- */
|
||||
|
||||
bool process_state = vm->get_state() == VirtualMachine::POWEROFF || (
|
||||
vm->get_state() == VirtualMachine::ACTIVE && (
|
||||
vm->get_lcm_state() == VirtualMachine::RUNNING ||
|
||||
vm->get_lcm_state() == VirtualMachine::UNKNOWN));
|
||||
|
||||
if (!process_state)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case 'a': // Still active, good!
|
||||
if ( vm->get_lcm_state() == VirtualMachine::UNKNOWN)
|
||||
{
|
||||
vm->log("VMM", Log::INFO, "VM found again, state is RUNNING");
|
||||
case 'a': // Active
|
||||
|
||||
vm->set_state(VirtualMachine::RUNNING);
|
||||
vmpool->update(vm);
|
||||
}
|
||||
else if ( vm->get_state() == VirtualMachine::POWEROFF )
|
||||
if ( vm->get_state() == VirtualMachine::POWEROFF ||
|
||||
(vm->get_state() == VirtualMachine::ACTIVE &&
|
||||
( vm->get_lcm_state() == VirtualMachine::UNKNOWN ||
|
||||
vm->get_lcm_state() == VirtualMachine::BOOT ||
|
||||
vm->get_lcm_state() == VirtualMachine::BOOT_POWEROFF ||
|
||||
vm->get_lcm_state() == VirtualMachine::BOOT_UNKNOWN ||
|
||||
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 ||
|
||||
vm->get_lcm_state() == VirtualMachine::BOOT_MIGRATE_FAILURE ||
|
||||
vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED_FAILURE ||
|
||||
vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY_FAILURE ||
|
||||
vm->get_lcm_state() == VirtualMachine::BOOT_FAILURE )))
|
||||
{
|
||||
vm->log("VMM", Log::INFO, "VM found again, state is RUNNING");
|
||||
|
||||
lcm->trigger(LifeCycleManager::MONITOR_POWERON, vm->get_oid());
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'p': // It's paused
|
||||
vm->log("VMM",Log::INFO, "VM running but monitor state is PAUSED.");
|
||||
if ( vm->get_state() == VirtualMachine::ACTIVE &&
|
||||
( vm->get_lcm_state() == VirtualMachine::RUNNING ||
|
||||
vm->get_lcm_state() == VirtualMachine::UNKNOWN ))
|
||||
{
|
||||
vm->log("VMM",Log::INFO, "VM running but monitor state is PAUSED.");
|
||||
|
||||
lcm->trigger(LifeCycleManager::MONITOR_SUSPEND, vm->get_oid());
|
||||
lcm->trigger(LifeCycleManager::MONITOR_SUSPEND, vm->get_oid());
|
||||
}
|
||||
break;
|
||||
|
||||
case 'e': //Failed
|
||||
vm->log("VMM",Log::INFO,"VM running but monitor state is ERROR.");
|
||||
if ( vm->get_state() == VirtualMachine::ACTIVE &&
|
||||
vm->get_lcm_state() == VirtualMachine::RUNNING )
|
||||
{
|
||||
vm->log("VMM",Log::INFO,"VM running but monitor state is ERROR.");
|
||||
|
||||
lcm->trigger(LifeCycleManager::MONITOR_DONE, vm->get_oid());
|
||||
lcm->trigger(LifeCycleManager::MONITOR_DONE, vm->get_oid());
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd': //The VM was powered-off
|
||||
vm->log("VMM",Log::INFO,"VM running but monitor state is POWEROFF");
|
||||
|
||||
lcm->trigger(LifeCycleManager::MONITOR_POWEROFF, vm->get_oid());
|
||||
if ( vm->get_state() == VirtualMachine::ACTIVE &&
|
||||
( vm->get_lcm_state() == VirtualMachine::RUNNING ||
|
||||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN ||
|
||||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_POWEROFF ||
|
||||
vm->get_lcm_state() == VirtualMachine::SHUTDOWN_UNDEPLOY ))
|
||||
{
|
||||
lcm->trigger(LifeCycleManager::MONITOR_POWEROFF, vm->get_oid());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user