1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-10 01:17:40 +03:00

feature #3654: Add BOOT_UNDEPLOY_FAILURE and BOOT_STOPPED_FAILURE. Get rid of map<string, string> empty declarations.

This commit is contained in:
Ruben S. Montero 2015-04-28 11:44:56 +02:00
parent b53eca5707
commit a03e3054e5
11 changed files with 94 additions and 76 deletions

View File

@ -150,7 +150,9 @@ public:
PROLOG_MIGRATE_POWEROFF = 43,
PROLOG_MIGRATE_POWEROFF_FAILURE = 44,
PROLOG_MIGRATE_SUSPEND = 45,
PROLOG_MIGRATE_SUSPEND_FAILURE = 46
PROLOG_MIGRATE_SUSPEND_FAILURE = 46,
BOOT_UNDEPLOY_FAILURE = 47,
BOOT_STOPPED_FAILURE = 48
};
static int lcm_state_from_str(string& st, LcmState& state)
@ -202,6 +204,8 @@ public:
else if ( st == "PROLOG_MIGRATE_POWEROFF_FAILURE") { state = PROLOG_MIGRATE_POWEROFF_FAILURE;}
else if ( st == "PROLOG_MIGRATE_SUSPEND") { state = PROLOG_MIGRATE_SUSPEND;}
else if ( st == "PROLOG_MIGRATE_SUSPEND_FAILURE") { state = PROLOG_MIGRATE_SUSPEND_FAILURE;}
else if ( st == "BOOT_STOPPED_FAILURE") { state = BOOT_STOPPED_FAILURE; }
else if ( st == "BOOT_UNDEPLOY_FAILURE") { state = BOOT_UNDEPLOY_FAILURE; }
else {return -1;}
return 0;
@ -256,6 +260,8 @@ public:
case PROLOG_MIGRATE_POWEROFF_FAILURE: st = "PROLOG_MIGRATE_POWEROFF_FAILURE"; break;
case PROLOG_MIGRATE_SUSPEND: st = "PROLOG_MIGRATE_SUSPEND"; break;
case PROLOG_MIGRATE_SUSPEND_FAILURE: st = "PROLOG_MIGRATE_SUSPEND_FAILURE"; break;
case BOOT_STOPPED_FAILURE: st = "BOOT_STOPPED_FAILURE"; break;
case BOOT_UNDEPLOY_FAILURE: st = "BOOT_UNDEPLOY_FAILURE"; break;
}
return st;
@ -369,7 +375,8 @@ public:
};
/**
* Updates VM dynamic information (usage counters), and updates last_poll
* Updates VM dynamic information (usage counters), and updates last_poll,
* and copies it to history record for acct.
* @param _memory Kilobytes used by the VM (total)
* @param _cpu used by the VM (rate)
* @param _net_tx transmitted bytes (total)
@ -382,6 +389,17 @@ public:
const long long _net_rx,
const map<string, string> &custom);
/**
* Clears the VM monitor information: usage counters, last_poll,
* custom attributes, and copies it to the history record for acct.
*/
void reset_info()
{
map<string,string> empty;
update_info(0, 0, -1, -1, empty);
}
/**
* Returns the deployment ID
* @return the VMM driver specific ID

View File

@ -23,7 +23,7 @@ digraph OpenNebula {
subgraph { rank = min; user}
subgraph { rank = same; suspended; stopped; undeployed; poweroff; color="white" }
subgraph { rank = same; boot; boot_stopped; boot_undeploy; boot_suspended; boot_unknown; boot_poweroff; boot_migrate; boot_failure; boot_migrate_failure; color="white"}
subgraph { rank = same; boot; boot_stopped; boot_undeploy; boot_suspended; boot_unknown; boot_poweroff; boot_migrate; boot_failure; boot_migrate_failure; boot_undeploy_failure, boot_stopped_failure; color="white"}
subgraph { rank = same; running; unknown; color="white"}
subgraph { rank = same; pending; hold; color="white"}
subgraph { rank = same; prolog; prolog_failure; prolog_resume; prolog_migrate; prolog_migrate_failure; prolog_migrate_poweroff; prolog_migrate_poweroff_failure; prolog_migrate_suspend; prolog_migrate_suspend_failure; prolog_undeploy; color="white" }

View File

@ -160,6 +160,8 @@
PROLOG_MIGRATE_POWEROFF_FAILURE = 44,
PROLOG_MIGRATE_SUSPEND = 45,
PROLOG_MIGRATE_SUSPEND_FAILURE = 46
BOOT_UNDEPLOY_FAILURE = 47,
BOOT_STOPPED_FAILURE = 48
-->
<xs:element name="LCM_STATE" type="xs:integer"/>
<xs:element name="PREV_STATE" type="xs:integer"/>

View File

@ -93,6 +93,8 @@
PROLOG_MIGRATE_POWEROFF_FAILURE = 44,
PROLOG_MIGRATE_SUSPEND = 45,
PROLOG_MIGRATE_SUSPEND_FAILURE = 46
BOOT_UNDEPLOY_FAILURE = 47,
BOOT_STOPPED_FAILURE = 48
-->
<xs:element name="LCM_STATE" type="xs:integer"/>
<xs:element name="PREV_STATE" type="xs:integer"/>

View File

@ -248,12 +248,12 @@ void LifeCycleManager::migrate_action(int vid)
vmm->trigger(VirtualMachineManager::SAVE,vid);
}
else if (vm->get_state() == VirtualMachine::POWEROFF ||
vm->get_state() == VirtualMachine::SUSPENDED )
vm->get_state() == VirtualMachine::SUSPENDED )
{
//------------------------------------------------------
// Bypass SAVE_MIGRATE & go to PROLOG_MIGRATE_POWEROFF
//------------------------------------------------------
if (vm->get_state() == VirtualMachine::POWEROFF)
if (vm->get_state() == VirtualMachine::POWEROFF)
{
vm->set_state(VirtualMachine::PROLOG_MIGRATE_POWEROFF);
}
@ -268,8 +268,7 @@ void LifeCycleManager::migrate_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -290,7 +289,7 @@ void LifeCycleManager::migrate_action(int vid)
tm->trigger(TransferManager::PROLOG_MIGR,vid);
}
else if (vm->get_state() == VirtualMachine::ACTIVE &&
vm->get_lcm_state() == VirtualMachine::UNKNOWN)
vm->get_lcm_state() == VirtualMachine::UNKNOWN)
{
//----------------------------------------------------
// Bypass SAVE_MIGRATE & PROLOG_MIGRATE goto BOOT
@ -302,8 +301,7 @@ void LifeCycleManager::migrate_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -867,8 +865,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, int& imag
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -901,6 +898,8 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm, bool dispose, int& imag
case VirtualMachine::BOOT_MIGRATE:
case VirtualMachine::BOOT_FAILURE:
case VirtualMachine::BOOT_MIGRATE_FAILURE:
case VirtualMachine::BOOT_UNDEPLOY_FAILURE:
case VirtualMachine::BOOT_STOPPED_FAILURE:
case VirtualMachine::RUNNING:
case VirtualMachine::UNKNOWN:
case VirtualMachine::SHUTDOWN:
@ -1143,6 +1142,8 @@ void LifeCycleManager::recover(VirtualMachine * vm, bool success)
case VirtualMachine::BOOT_MIGRATE:
case VirtualMachine::BOOT_MIGRATE_FAILURE:
case VirtualMachine::BOOT_FAILURE:
case VirtualMachine::BOOT_STOPPED_FAILURE:
case VirtualMachine::BOOT_UNDEPLOY_FAILURE:
if (success)
{
//Auto-generate deploy-id it'll work for Xen, KVM and VMware
@ -1255,6 +1256,22 @@ void LifeCycleManager::retry(VirtualMachine * vm)
vmm->trigger(VirtualMachineManager::RESTORE, vid);
break;
case VirtualMachine::BOOT_UNDEPLOY_FAILURE:
vm->set_state(VirtualMachine::BOOT_UNDEPLOY);
vmpool->update(vm);
vmm->trigger(VirtualMachineManager::DEPLOY, vid);
break;
case VirtualMachine::BOOT_STOPPED_FAILURE:
vm->set_state(VirtualMachine::BOOT_STOPPED);
vmpool->update(vm);
vmm->trigger(VirtualMachineManager::RESTORE, vid);
break;
case VirtualMachine::PROLOG_MIGRATE_FAILURE:
vm->set_state(VirtualMachine::PROLOG_MIGRATE);

View File

@ -47,8 +47,7 @@ void LifeCycleManager::save_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -84,8 +83,7 @@ void LifeCycleManager::save_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -115,8 +113,7 @@ void LifeCycleManager::save_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -295,6 +292,8 @@ void LifeCycleManager::deploy_success_action(int vid)
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->set_state(VirtualMachine::RUNNING);
@ -430,55 +429,21 @@ void LifeCycleManager::deploy_failure_action(int vid)
}
else if (vm->get_lcm_state() == VirtualMachine::BOOT_STOPPED)
{
time_t the_time = time(0);
//----------------------------------------------------
// EPILOG_STOP STATE FROM BOOT
//----------------------------------------------------
vm->set_state(VirtualMachine::EPILOG_STOP);
vm->set_state(VirtualMachine::BOOT_STOPPED_FAILURE);
vmpool->update(vm);
vm->set_epilog_stime(the_time);
vm->set_running_etime(the_time);
vm->set_reason(History::ERROR);
vmpool->update_history(vm);
//----------------------------------------------------
tm->trigger(TransferManager::EPILOG_STOP,vid);
}
else if (vm->get_lcm_state() == VirtualMachine::BOOT_UNDEPLOY)
{
time_t the_time = time(0);
//----------------------------------------------------
// EPILOG_UNDEPLOY STATE FROM BOOT
//----------------------------------------------------
vm->set_state(VirtualMachine::EPILOG_UNDEPLOY);
vm->set_state(VirtualMachine::BOOT_UNDEPLOY_FAILURE);
vmpool->update(vm);
vm->set_epilog_stime(the_time);
vm->set_running_etime(the_time);
vm->set_reason(History::ERROR);
vmpool->update_history(vm);
//----------------------------------------------------
tm->trigger(TransferManager::EPILOG_STOP,vid);
}
//wrong state + recover failure from failure state
else if ( vm->get_lcm_state() != VirtualMachine::BOOT_FAILURE &&
vm->get_lcm_state() != VirtualMachine::BOOT_MIGRATE_FAILURE )
vm->get_lcm_state() != VirtualMachine::BOOT_MIGRATE_FAILURE &&
vm->get_lcm_state() != VirtualMachine::BOOT_UNDEPLOY_FAILURE &&
vm->get_lcm_state() != VirtualMachine::BOOT_STOPPED_FAILURE )
{
vm->log("LCM",Log::ERROR,"deploy_failure_action, VM in a wrong state");
}
@ -511,8 +476,7 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -536,8 +500,7 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -565,8 +528,7 @@ void LifeCycleManager::shutdown_success_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -643,7 +605,6 @@ void LifeCycleManager::prolog_success_action(int vid)
VirtualMachine * vm;
time_t the_time = time(0);
ostringstream os;
map<string, string> empty;
VirtualMachineManager::Actions action;
@ -717,7 +678,7 @@ void LifeCycleManager::prolog_success_action(int vid)
case VirtualMachine::PROLOG_MIGRATE_SUSPEND_FAILURE: //recover success
vm->delete_snapshots();
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -1072,8 +1033,7 @@ void LifeCycleManager::monitor_suspend_action(int vid)
vm->delete_snapshots();
map<string, string> empty;
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vmpool->update(vm);
@ -1152,12 +1112,11 @@ void LifeCycleManager::monitor_poweroff_action(int vid)
//----------------------------------------------------
// POWEROFF STATE
//----------------------------------------------------
map<string, string> empty;
time_t the_time = time(0);
time_t the_time = time(0);
vm->delete_snapshots();
vm->update_info(0, 0, -1, -1, empty);
vm->reset_info();
vm->set_resched(false);

View File

@ -123,7 +123,9 @@ public class VirtualMachine extends PoolElement{
"PROLOG_MIGRATE_POWEROFF",
"PROLOG_MIGRATE_POWEROFF_FAILURE",
"PROLOG_MIGRATE_SUSPEND",
"PROLOG_MIGRATE_SUSPEND_FAILURE"
"PROLOG_MIGRATE_SUSPEND_FAILURE",
"BOOT_UNDEPLOY_FAILURE",
"BOOT_STOPPED_FAILURE"
};
private static final String[] SHORT_LCM_STATES =
@ -174,8 +176,10 @@ public class VirtualMachine extends PoolElement{
"migr", // PROLOG_MIGRATE_POWEROFF
"fail", // PROLOG_MIGRATE_POWEROFF_FAILURE
"migr", // PROLOG_MIGRATE_SUSPEND
"fail" // PROLOG_MIGRATE_SUSPEND_FAILURE
};
"fail", // PROLOG_MIGRATE_SUSPEND_FAILURE
"fail", // BOOT_UNDEPLOY_FAILURE
"fail" // BOOT_STOPPED_FAILURE
};
/**
* Creates a new VM representation.

View File

@ -98,6 +98,8 @@ module OpenNebula
PROLOG_MIGRATE_POWEROFF_FAILURE
PROLOG_MIGRATE_SUSPEND
PROLOG_MIGRATE_SUSPEND_FAILURE
BOOT_UNDEPLOY_FAILURE
BOOT_STOPPED_FAILURE
}
SHORT_VM_STATES={
@ -160,6 +162,8 @@ module OpenNebula
"PROLOG_MIGRATE_POWEROFF_FAILURE" => "fail",
"PROLOG_MIGRATE_SUSPEND" => "migr",
"PROLOG_MIGRATE_SUSPEND_FAILURE" => "fail",
"BOOT_UNDEPLOY_FAILURE" => "fail",
"BOOT_STOPPED_FAILURE" => "fail"
}
MIGRATE_REASON=%w{NONE ERROR USER}

View File

@ -79,6 +79,8 @@ VNC_STATES = [
#44, #PROLOG_MIGRATE_POWEROFF_FAILURE
#45, #PROLOG_MIGRATE_SUSPEND
#46, #PROLOG_MIGRATE_SUSPEND_FAILURE
#47, #BOOT_UNDEPLOY_FAILURE
#48, #BOOT_STOPPED_FAILURE
]
class OpenNebulaVNC

View File

@ -164,7 +164,9 @@ var OpenNebula = {
"MIGRATE", // PROLOG_MIGRATE_POWEROFF
"FAILURE", // PROLOG_MIGRATE_POWEROFF_FAILURE
"MIGRATE", // PROLOG_MIGRATE_SUSPEND
"FAILURE" // PROLOG_MIGRATE_SUSPEND_FAILURE
"FAILURE", // PROLOG_MIGRATE_SUSPEND_FAILURE
"FAILURE", // BOOT_UNDEPLOY_FAILURE
"FAILURE" // BOOT_STOPPED_FAILURE
][value]);
break;
case "VM_LCM":
@ -215,7 +217,9 @@ var OpenNebula = {
"PROLOG_MIGRATE_POWEROFF",
"PROLOG_MIGRATE_POWEROFF_FAILURE",
"PROLOG_MIGRATE_SUSPEND",
"PROLOG_MIGRATE_SUSPEND_FAILURE"
"PROLOG_MIGRATE_SUSPEND_FAILURE",
"BOOT_UNDEPLOY_FAILURE",
"BOOT_STOPPED_FAILURE"
][value]);
break;
case "IMAGE":
@ -1017,7 +1021,9 @@ var OpenNebula = {
"PROLOG_MIGRATE_POWEROFF" : 43,
"PROLOG_MIGRATE_POWEROFF_FAILURE" : 44,
"PROLOG_MIGRATE_SUSPEND" : 45,
"PROLOG_MIGRATE_SUSPEND_FAILURE" : 46
"PROLOG_MIGRATE_SUSPEND_FAILURE" : 46,
"BOOT_UNDEPLOY_FAILURE" : 47,
"BOOT_STOPPED_FAILURE" : 48
},
"create": function(params){

View File

@ -172,6 +172,10 @@ var lcm_state_actions = {
[],
46: //OpenNebula.VM.lcm_state.PROLOG_MIGRATE_SUSPEND_FAILURE:
[],
47: //OpenNebula.VM.lcm_state.BOOT_UNDEPLOY_FAILURE:
[],
48: //OpenNebula.VM.lcm_state.BOOT_STOPPED_FAILURE:
[],
}
//Permanent storage for last value of aggregated network usage