diff --git a/include/History.h b/include/History.h index 689947bf62..772d3fb2b0 100644 --- a/include/History.h +++ b/include/History.h @@ -63,7 +63,7 @@ public: string& to_xml(string& xml) const; // ---------------------------------------- - // DataBase implementation variables + // DataBase implementation // ---------------------------------------- static const char * table; @@ -108,6 +108,8 @@ private: MigrationReason reason; + string vm_info; + // ------------------------------------------------------------------------- // Non-persistent history fields // ------------------------------------------------------------------------- @@ -173,6 +175,23 @@ private: */ int select_cb(void *nil, int num, char **values, char **names); + /** + * Function to print the History object into a string in + * XML format, to be stored in the DB. It includes the VM template info + * @param xml the resulting XML string + * @return a reference to the generated string + */ + string& to_db_xml(string& xml) const; + + /** + * Function to print the History object into a string in + * XML format. The VM info can be optionally included + * @param xml the resulting XML string + * @param database If it is true, the TEMPLATE element will be included + * @return a reference to the generated string + */ + string& to_xml(string& xml, bool database) const; + /** * Rebuilds the object from an xml node * @param node The xml node pointer diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 6f20419e33..8d7b2f68fe 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -199,7 +199,7 @@ public: /** * Sets the VM exit time - * @param _et VM exit time (when it arraived DONE/FAILED states) + * @param _et VM exit time (when it arrived DONE/FAILED states) */ void set_exit_time(time_t et) { @@ -434,6 +434,9 @@ public: */ void set_etime(time_t _etime) { + string xml; + history->vm_info = obj_template->to_xml(xml); + history->etime=_etime; }; @@ -443,6 +446,9 @@ 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/vm/History.cc b/src/vm/History.cc index 4fae85a24c..e1199d83e6 100644 --- a/src/vm/History.cc +++ b/src/vm/History.cc @@ -52,7 +52,8 @@ History::History( running_etime(0), epilog_stime(0), epilog_etime(0), - reason(NONE){}; + reason(NONE), + vm_info("