From be32ba5526058084c00bc3c80469076ec1a9e6db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn?= Date: Fri, 2 Dec 2011 19:52:35 +0100 Subject: [PATCH] Improve xml consistency, all elements are written even if they are empty --- src/vm/VirtualMachine.cc | 4 ++++ src/vnm/Leases.cc | 4 ---- src/vnm/VirtualNetwork.cc | 21 +++++++++++++++++++-- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/vm/VirtualMachine.cc b/src/vm/VirtualMachine.cc index a4619d6a4a..c3737af3fd 100644 --- a/src/vm/VirtualMachine.cc +++ b/src/vm/VirtualMachine.cc @@ -1258,6 +1258,10 @@ string& VirtualMachine::to_xml_extended(string& xml, bool extended) const oss << ""; } + else + { + oss << ""; + } oss << ""; diff --git a/src/vnm/Leases.cc b/src/vnm/Leases.cc index 17dc998d07..12de451987 100644 --- a/src/vnm/Leases.cc +++ b/src/vnm/Leases.cc @@ -429,15 +429,11 @@ string& Leases::to_xml(string& xml) const ostringstream os; string lease_xml; - os << ""; - for(it=leases.begin();it!=leases.end();it++) { os << it->second->to_xml(lease_xml); } - os << ""; - xml = os.str(); return xml; diff --git a/src/vnm/VirtualNetwork.cc b/src/vnm/VirtualNetwork.cc index 520ba533b5..a1bdb86264 100644 --- a/src/vnm/VirtualNetwork.cc +++ b/src/vnm/VirtualNetwork.cc @@ -521,19 +521,36 @@ string& VirtualNetwork::to_xml_extended(string& xml, bool extended) const { os << "" << phydev << ""; } + else + { + os << ""; + } if (!vlan_id.empty()) { os << "" << vlan_id << ""; } + else + { + os << ""; + } os << "" << public_obj << "" << ""<< 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->to_xml(leases_xml) << + ""; + } + else + { + os << ""; + } } os << "";