From 72d3ea947173feda490dfd909936509375bc7d77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Wed, 3 Apr 2013 17:38:06 +0200 Subject: [PATCH] Feature #1631: Change history reasons to be only 3: none, user, error --- include/History.h | 13 +++++-------- include/VirtualMachine.h | 6 +++--- src/lcm/LifeCycleActions.cc | 6 ++++-- src/lcm/LifeCycleStates.cc | 14 +++++++------- src/oca/ruby/opennebula/virtual_machine.rb | 6 ++---- src/ozones/Server/public/js/ozones.js | 4 +--- src/sunstone/public/js/opennebula.js | 4 +--- src/vm/History.cc | 2 +- 8 files changed, 24 insertions(+), 31 deletions(-) diff --git a/include/History.h b/include/History.h index 744881bdbc..9efdabe03f 100644 --- a/include/History.h +++ b/include/History.h @@ -28,16 +28,13 @@ using namespace std; class History:public ObjectSQL, public ObjectXML { public: - enum MigrationReason + enum EndReason { - NONE, /** < Normal termination in host */ - ERROR, /** < The VM was migrated because of an error */ - STOP_RESUME,/** < The VM was migrated because of a stop/resume request*/ - USER, /** < The VM was migrated because of an explicit request */ - CANCEL /** < The VM was migrated because of an explicit cancel */ + NONE, /** < History record is not closed yet */ + ERROR, /** < History record was closed because of an error */ + USER /** < History record was closed because of a user action */ }; - enum VMAction { MIGRATE_ACTION, @@ -292,7 +289,7 @@ private: time_t epilog_stime; time_t epilog_etime; - MigrationReason reason; + EndReason reason; VMAction action; diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 345eeb699a..e0bce0dce0 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -500,7 +500,7 @@ public: * Returns the reason that closed the history record in the previous host * @return the reason to close the history record in the previous host */ - const History::MigrationReason get_previous_reason() const + const History::EndReason get_previous_reason() const { return previous_history->reason; }; @@ -642,7 +642,7 @@ public: * Sets the reason that closed the history record * @param _reason reason to close the history record */ - void set_reason(History::MigrationReason _reason) + void set_reason(History::EndReason _reason) { history->reason=_reason; }; @@ -651,7 +651,7 @@ public: * Sets the reason that closed the history record in the previous host * @param _reason reason to close the history record in the previous host */ - void set_previous_reason(History::MigrationReason _reason) + void set_previous_reason(History::EndReason _reason) { previous_history->reason=_reason; }; diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 42574fd30b..f933274d64 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -48,12 +48,14 @@ void LifeCycleManager::deploy_action(int vid) if (vm->hasPreviousHistory()) { - if (vm->get_previous_reason() == History::STOP_RESUME) + if (vm->get_previous_history_action() == History::STOP_ACTION) { vm_state = VirtualMachine::PROLOG_RESUME; tm_action = TransferManager::PROLOG_RESUME; } - else if (vm->get_previous_reason() == History::NONE) + else if ( + vm->get_previous_history_action() == History::UNDEPLOY_ACTION || + vm->get_previous_history_action() == History::UNDEPLOY_HARD_ACTION) { vm_state = VirtualMachine::PROLOG_UNDEPLOY; tm_action = TransferManager::PROLOG_RESUME; diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index 6429610102..139c12a805 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -93,7 +93,7 @@ void LifeCycleManager::save_success_action(int vid) vm->set_vm_info(); - vm->set_reason(History::STOP_RESUME); + vm->set_reason(History::USER); vmpool->update_history(vm); @@ -121,7 +121,7 @@ void LifeCycleManager::save_success_action(int vid) vm->set_running_etime(the_time); - vm->set_reason(History::STOP_RESUME); + vm->set_reason(History::USER); vmpool->update_history(vm); @@ -434,7 +434,7 @@ void LifeCycleManager::deploy_failure_action(int vid) vm->set_running_etime(the_time); - vm->set_reason(History::STOP_RESUME); + vm->set_reason(History::ERROR); vmpool->update_history(vm); @@ -510,7 +510,7 @@ void LifeCycleManager::shutdown_success_action(int vid) vm->set_vm_info(); - vm->set_reason(History::STOP_RESUME); + vm->set_reason(History::USER); vmpool->update_history(vm); @@ -720,7 +720,7 @@ void LifeCycleManager::prolog_failure_action(int vid) vm->set_vm_info(); - vm->set_reason(History::STOP_RESUME); + vm->set_reason(History::ERROR); vmpool->update_history(vm); @@ -953,7 +953,7 @@ void LifeCycleManager::cancel_success_action(int vid) vmpool->update(vm); - vm->set_reason(History::CANCEL); + vm->set_reason(History::USER); vm->set_epilog_stime(the_time); @@ -1119,7 +1119,7 @@ void LifeCycleManager::monitor_suspend_action(int vid) vm->set_vm_info(); - vm->set_reason(History::STOP_RESUME); + vm->set_reason(History::ERROR); vmpool->update_history(vm); diff --git a/src/oca/ruby/opennebula/virtual_machine.rb b/src/oca/ruby/opennebula/virtual_machine.rb index 905a7e83e8..23bdf977b6 100644 --- a/src/oca/ruby/opennebula/virtual_machine.rb +++ b/src/oca/ruby/opennebula/virtual_machine.rb @@ -103,14 +103,12 @@ module OpenNebula "PROLOG_UNDEPLOY" => "prol" } - MIGRATE_REASON=%w{NONE ERROR STOP_RESUME USER CANCEL} + MIGRATE_REASON=%w{NONE ERROR USER} SHORT_MIGRATE_REASON={ "NONE" => "none", "ERROR" => "erro", - "STOP_RESUME" => "stop", - "USER" => "user", - "CANCEL" => "canc" + "USER" => "user" } # Creates a VirtualMachine description with just its identifier diff --git a/src/ozones/Server/public/js/ozones.js b/src/ozones/Server/public/js/ozones.js index e8661caccd..ee70bb595c 100644 --- a/src/ozones/Server/public/js/ozones.js +++ b/src/ozones/Server/public/js/ozones.js @@ -125,9 +125,7 @@ var oZones = { case "vm_migrate_reason": state = tr(["NONE", "ERROR", - "STOP_RESUME", - "USER", - "CANCEL"][value]); + "USER"][value]); break; default: return value; diff --git a/src/sunstone/public/js/opennebula.js b/src/sunstone/public/js/opennebula.js index 9b3d5dcb18..38d535d00a 100644 --- a/src/sunstone/public/js/opennebula.js +++ b/src/sunstone/public/js/opennebula.js @@ -133,9 +133,7 @@ var OpenNebula = { case "vm_migrate_reason": state = tr(["NONE", "ERROR", - "STOP_RESUME", - "USER", - "CANCEL"][value]); + "USER"][value]); break; default: return value; diff --git a/src/vm/History.cc b/src/vm/History.cc index 2509b5b6e7..5e2ba19dfe 100644 --- a/src/vm/History.cc +++ b/src/vm/History.cc @@ -352,7 +352,7 @@ int History::rebuild_attributes() rc += xpath(int_reason , "/HISTORY/REASON", 0); rc += xpath(int_action , "/HISTORY/ACTION", 0); - reason = static_cast(int_reason); + reason = static_cast(int_reason); action = static_cast(int_action); non_persistent_data();