1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-26 10:03:37 +03:00

Improve xml consistency, all elements are written even if they are empty

This commit is contained in:
Carlos Martín 2011-12-02 19:52:35 +01:00
parent 487ec888b5
commit be32ba5526
3 changed files with 23 additions and 6 deletions

View File

@ -1258,6 +1258,10 @@ string& VirtualMachine::to_xml_extended(string& xml, bool extended) const
oss << "</HISTORY_RECORDS>";
}
else
{
oss << "<HISTORY_RECORDS/>";
}
oss << "</VM>";

View File

@ -429,15 +429,11 @@ string& Leases::to_xml(string& xml) const
ostringstream os;
string lease_xml;
os << "<LEASES>";
for(it=leases.begin();it!=leases.end();it++)
{
os << it->second->to_xml(lease_xml);
}
os << "</LEASES>";
xml = os.str();
return xml;

View File

@ -521,19 +521,36 @@ string& VirtualNetwork::to_xml_extended(string& xml, bool extended) const
{
os << "<PHYDEV>" << phydev << "</PHYDEV>";
}
else
{
os << "<PHYDEV/>";
}
if (!vlan_id.empty())
{
os << "<VLAN_ID>" << vlan_id << "</VLAN_ID>";
}
else
{
os << "<VLAN_ID/>";
}
os << "<PUBLIC>" << public_obj << "</PUBLIC>" <<
"<TOTAL_LEASES>"<< total_leases << "</TOTAL_LEASES>"<<
obj_template->to_xml(template_xml);
if (extended && leases != 0)
if (extended)
{
os << leases->to_xml(leases_xml);
if (leases != 0)
{
os << "<LEASES>" <<
leases->to_xml(leases_xml) <<
"</LEASES>";
}
else
{
os << "<LEASES/>";
}
}
os << "</VNET>";