From a03e3054e515848fc6d0c83ddca19b9971c002f9 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Tue, 28 Apr 2015 11:44:56 +0200 Subject: [PATCH] feature #3654: Add BOOT_UNDEPLOY_FAILURE and BOOT_STOPPED_FAILURE. Get rid of map empty declarations. --- include/VirtualMachine.h | 22 +++++- share/doc/states/states-complete.dot | 2 +- share/doc/xsd/acct.xsd | 2 + share/doc/xsd/vm.xsd | 2 + src/lcm/LifeCycleActions.cc | 35 ++++++--- src/lcm/LifeCycleStates.cc | 75 +++++-------------- .../opennebula/client/vm/VirtualMachine.java | 10 ++- src/oca/ruby/opennebula/virtual_machine.rb | 4 + src/sunstone/OpenNebulaVNC.rb | 2 + src/sunstone/public/js/opennebula.js | 12 ++- src/sunstone/public/js/plugins/vms-tab.js | 4 + 11 files changed, 94 insertions(+), 76 deletions(-) diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 2c363d7980..928ef6a09b 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -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 &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 empty; + + update_info(0, 0, -1, -1, empty); + } + /** * Returns the deployment ID * @return the VMM driver specific ID diff --git a/share/doc/states/states-complete.dot b/share/doc/states/states-complete.dot index 9eec98f8ec..d7928cae1e 100644 --- a/share/doc/states/states-complete.dot +++ b/share/doc/states/states-complete.dot @@ -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" } diff --git a/share/doc/xsd/acct.xsd b/share/doc/xsd/acct.xsd index 249debe11e..8d47261cda 100644 --- a/share/doc/xsd/acct.xsd +++ b/share/doc/xsd/acct.xsd @@ -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 --> diff --git a/share/doc/xsd/vm.xsd b/share/doc/xsd/vm.xsd index 31ef56338e..a0c89c5702 100644 --- a/share/doc/xsd/vm.xsd +++ b/share/doc/xsd/vm.xsd @@ -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 --> diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 118c1de40c..4b007247d7 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -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 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 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 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); diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index a6bb485db0..496e68174c 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -47,8 +47,7 @@ void LifeCycleManager::save_success_action(int vid) vm->delete_snapshots(); - map 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 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 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 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 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 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 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 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 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); diff --git a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java index a11b84ffad..2456f52c00 100644 --- a/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java +++ b/src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java @@ -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. diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index 070e7ae487..c2613ba63d 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -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} diff --git a/src/sunstone/OpenNebulaVNC.rb b/src/sunstone/OpenNebulaVNC.rb index ce3a3349ae..8a7fdfd285 100644 --- a/src/sunstone/OpenNebulaVNC.rb +++ b/src/sunstone/OpenNebulaVNC.rb @@ -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 diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index b34bbac6b4..e94f01b8fc 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -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){ diff --git a/src/sunstone/public/js/plugins/vms-tab.js b/src/sunstone/public/js/plugins/vms-tab.js index 0886d5548f..63502ac6e6 100644 --- a/src/sunstone/public/js/plugins/vms-tab.js +++ b/src/sunstone/public/js/plugins/vms-tab.js @@ -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