mirror of
https://github.com/OpenNebula/one.git
synced 2025-02-27 13:57:23 +03:00
B: Solves issues when loading VM template in history records
This commit is contained in:
parent
7448957fa0
commit
a2ad9662a7
@ -316,15 +316,21 @@ public:
|
||||
*/
|
||||
friend std::ostream& operator<<(std::ostream& os, ObjectXML& oxml)
|
||||
{
|
||||
xmlChar * mem;
|
||||
int size;
|
||||
xmlNodePtr root_node = xmlDocGetRootElement(oxml.xml);
|
||||
|
||||
xmlDocDumpMemory(oxml.xml,&mem,&size);
|
||||
if ( root_node == 0 )
|
||||
{
|
||||
return os;
|
||||
}
|
||||
|
||||
std::string str(reinterpret_cast<char *>(mem));
|
||||
xmlBufferPtr buffer = xmlBufferCreate();
|
||||
|
||||
xmlNodeDump(buffer, oxml.xml, root_node, 0, 0);
|
||||
|
||||
std::string str(reinterpret_cast<char *>(buffer->content));
|
||||
os << str;
|
||||
|
||||
xmlFree(mem);
|
||||
xmlBufferFree(buffer);
|
||||
|
||||
return os;
|
||||
};
|
||||
|
@ -380,11 +380,8 @@ int History::rebuild_attributes()
|
||||
// -------------------------------------------------------------------------
|
||||
ObjectXML::get_nodes("/HISTORY/VM", content);
|
||||
|
||||
if (content.empty())
|
||||
if (!content.empty())
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
ObjectXML vm_info_xml(content[0]);
|
||||
|
||||
ostringstream oss;
|
||||
@ -396,6 +393,7 @@ int History::rebuild_attributes()
|
||||
ObjectXML::free_nodes(content);
|
||||
|
||||
content.clear();
|
||||
}
|
||||
|
||||
non_persistent_data();
|
||||
|
||||
|
@ -505,10 +505,12 @@ int VirtualMachine::select(SqlDB * db)
|
||||
return rc;
|
||||
}
|
||||
|
||||
//Get History Records. Current history is built in from_xml() (if any).
|
||||
//Get History Records.
|
||||
if( hasHistory() )
|
||||
{
|
||||
last_seq = history->seq - 1;
|
||||
last_seq = history->seq;
|
||||
|
||||
delete history_records[last_seq];
|
||||
|
||||
for (int i = last_seq; i >= 0; i--)
|
||||
{
|
||||
@ -525,6 +527,10 @@ int VirtualMachine::select(SqlDB * db)
|
||||
history_records[i] = hp;
|
||||
|
||||
if ( i == last_seq )
|
||||
{
|
||||
history = hp;
|
||||
}
|
||||
else if ( i == last_seq - 1 )
|
||||
{
|
||||
previous_history = hp;
|
||||
}
|
||||
@ -2117,18 +2123,15 @@ int VirtualMachine::from_xml(const string &xml_str)
|
||||
// -------------------------------------------------------------------------
|
||||
// Last history entry
|
||||
// -------------------------------------------------------------------------
|
||||
ObjectXML::get_nodes("/VM/HISTORY_RECORDS/HISTORY", content);
|
||||
int last_seq;
|
||||
|
||||
if (!content.empty())
|
||||
if ( xpath(last_seq,"/VM/HISTORY_RECORDS/HISTORY/SEQ", -1) == 0 &&
|
||||
last_seq != -1 )
|
||||
{
|
||||
history = new History(oid);
|
||||
rc += history->from_xml_node(content[0]);
|
||||
history = new History(oid, last_seq);
|
||||
|
||||
history_records.resize(history->seq + 1);
|
||||
history_records[history->seq] = history;
|
||||
|
||||
ObjectXML::free_nodes(content);
|
||||
content.clear();
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
|
Loading…
x
Reference in New Issue
Block a user