From de3cd97468bc44b38455345199a504b3e17f6415 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 5 May 2012 20:57:17 +0200 Subject: [PATCH] feature #1099: VM info is set in history records in a separate function --- include/VirtualMachine.h | 22 ++++++++++++++++------ src/lcm/LifeCycleActions.cc | 3 +++ src/lcm/LifeCycleStates.cc | 20 ++++++++++++++++++++ 3 files changed, 39 insertions(+), 6 deletions(-) diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 1332198578..1319711f81 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -428,15 +428,28 @@ public: history->stime=_stime; }; + /** + * Sets VM info (with monitoring info) in the history record + */ + void set_vm_info() + { + obj_template->to_xml(history->vm_info); + }; + + /** + * Sets VM info (with monitoring info) in the previous history record + */ + void set_previous_vm_info() + { + obj_template->to_xml(previous_history->vm_info); + }; + /** * Sets end time of a VM. * @param _etime time when the VM finished */ void set_etime(time_t _etime) { - string xml; - history->vm_info = obj_template->to_xml(xml); - history->etime=_etime; }; @@ -446,9 +459,6 @@ public: */ void set_previous_etime(time_t _etime) { - string xml; - previous_history->vm_info = obj_template->to_xml(xml); - previous_history->etime=_etime; }; diff --git a/src/lcm/LifeCycleActions.cc b/src/lcm/LifeCycleActions.cc index 234e686a58..3e6d0c2b9a 100644 --- a/src/lcm/LifeCycleActions.cc +++ b/src/lcm/LifeCycleActions.cc @@ -615,6 +615,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) vmpool->update(vm); vm->set_etime(the_time); + vm->set_vm_info(); vm->set_reason(History::USER); vm->get_requirements(cpu,mem,disk); @@ -650,6 +651,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) vmpool->update_history(vm); vm->set_previous_etime(the_time); + vm->set_previous_vm_info(); vm->set_previous_running_etime(the_time); vm->set_previous_reason(History::USER); vmpool->update_previous_history(vm); @@ -680,6 +682,7 @@ void LifeCycleManager::clean_up_vm(VirtualMachine * vm) vmpool->update_history(vm); vm->set_previous_etime(the_time); + vm->set_previous_vm_info(); vm->set_previous_running_etime(the_time); vm->set_previous_reason(History::USER); vmpool->update_previous_history(vm); diff --git a/src/lcm/LifeCycleStates.cc b/src/lcm/LifeCycleStates.cc index 11cf2bd7be..0165d3ec8d 100644 --- a/src/lcm/LifeCycleStates.cc +++ b/src/lcm/LifeCycleStates.cc @@ -49,6 +49,8 @@ void LifeCycleManager::save_success_action(int vid) vm->set_previous_etime(the_time); + vm->set_previous_vm_info(); + vm->set_previous_running_etime(the_time); vm->set_previous_reason(History::USER); @@ -84,6 +86,8 @@ void LifeCycleManager::save_success_action(int vid) vm->set_etime(the_time); + vm->set_vm_info(); + vm->set_reason(History::STOP_RESUME); vmpool->update_history(vm); @@ -162,6 +166,8 @@ void LifeCycleManager::save_failure_action(int vid) vm->set_etime(the_time); + vm->set_vm_info(); + vm->set_reason(History::ERROR); vmpool->update_history(vm); @@ -172,6 +178,8 @@ void LifeCycleManager::save_failure_action(int vid) vm->set_previous_etime(the_time); + vm->set_previous_vm_info(); + vm->set_previous_running_etime(the_time); vm->set_previous_reason(History::USER); @@ -251,6 +259,8 @@ void LifeCycleManager::deploy_success_action(int vid) vm->set_previous_etime(the_time); + vm->set_previous_vm_info(); + vm->set_previous_running_etime(the_time); vm->set_previous_reason(History::USER); @@ -304,10 +314,14 @@ void LifeCycleManager::deploy_failure_action(int vid) vm->set_etime(the_time); + vm->set_vm_info(); + vm->set_reason(History::ERROR); vm->set_previous_etime(the_time); + vm->set_previous_vm_info(); + vm->set_previous_running_etime(the_time); vm->set_previous_reason(History::USER); @@ -554,6 +568,8 @@ void LifeCycleManager::epilog_success_action(int vid) vm->set_etime(the_time); + vm->set_vm_info(); + vmpool->update_history(vm); vm->get_requirements(cpu,mem,disk); @@ -727,6 +743,8 @@ void LifeCycleManager::monitor_suspend_action(int vid) vm->set_etime(the_time); + vm->set_vm_info(); + vm->set_reason(History::STOP_RESUME); vmpool->update_history(vm); @@ -799,6 +817,8 @@ void LifeCycleManager::failure_action(VirtualMachine * vm) vm->set_etime(the_time); + vm->set_vm_info(); + vm->set_reason(History::ERROR); vmpool->update_history(vm);