mirror of
https://github.com/OpenNebula/one.git
synced 2024-12-22 13:33:52 +03:00
Feature #1099: Add VM template information to the History records once they are "closed"
This commit is contained in:
parent
c178601623
commit
70d5c75d04
@ -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
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
@ -52,7 +52,8 @@ History::History(
|
||||
running_etime(0),
|
||||
epilog_stime(0),
|
||||
epilog_etime(0),
|
||||
reason(NONE){};
|
||||
reason(NONE),
|
||||
vm_info("<TEMPLATE/>"){};
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
@ -77,7 +78,8 @@ History::History(
|
||||
running_etime(0),
|
||||
epilog_stime(0),
|
||||
epilog_etime(0),
|
||||
reason(NONE)
|
||||
reason(NONE),
|
||||
vm_info("<TEMPLATE/>")
|
||||
{
|
||||
non_persistent_data();
|
||||
};
|
||||
@ -150,7 +152,7 @@ int History::insert_replace(SqlDB *db, bool replace)
|
||||
return 0;
|
||||
}
|
||||
|
||||
sql_xml = db->escape_str(to_xml(xml_body).c_str());
|
||||
sql_xml = db->escape_str(to_db_xml(xml_body).c_str());
|
||||
|
||||
if ( sql_xml == 0 )
|
||||
{
|
||||
@ -262,6 +264,20 @@ ostream& operator<<(ostream& os, const History& history)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string& History::to_xml(string& xml) const
|
||||
{
|
||||
return to_xml(xml, false);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string& History::to_db_xml(string& xml) const
|
||||
{
|
||||
return to_xml(xml, true);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string& History::to_xml(string& xml, bool database) const
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
@ -281,7 +297,14 @@ string& History::to_xml(string& xml) const
|
||||
"<RETIME>" << running_etime << "</RETIME>"<<
|
||||
"<ESTIME>" << epilog_stime << "</ESTIME>"<<
|
||||
"<EETIME>" << epilog_etime << "</EETIME>"<<
|
||||
"<REASON>" << reason << "</REASON>"<<
|
||||
"<REASON>" << reason << "</REASON>";
|
||||
|
||||
if ( database )
|
||||
{
|
||||
oss << vm_info;
|
||||
}
|
||||
|
||||
oss <<
|
||||
"</HISTORY>";
|
||||
|
||||
xml = oss.str();
|
||||
|
Loading…
Reference in New Issue
Block a user