Feature #407: Host code cleanup and better error checks

This commit is contained in:
Carlos Martín committed 2011-03-01 17:36:42 +01:00
1 parent b05e609649
commit 2eee00a1e3
4 files changed
+28 -35

No files matched your search

-14
View File
@@ -443,20 +443,6 @@ private:
// DataBase implementation (Private)
// *************************************************************************
enum ColNames
{
OID = 0,
HOST_NAME = 1,
STATE = 2,
IM_MAD = 3,
VM_MAD = 4,
TM_MAD = 5,
LAST_MON_TIME = 6,
CLUSTER = 7,
TEMPLATE = 8,
LIMIT = 9
};
static const char * db_names;
static const char * db_bootstrap;
+1 -1
View File
@@ -6,7 +6,7 @@ TWD_DIR="../../src"
BASE_DIR=$PWD
TESTS="$TWD_DIR/vnm/test \
$TWD_DIR/scheduler/src/xml/test \
$TWD_DIR/xml/test \
$TWD_DIR/scheduler/src/pool/test \
$TWD_DIR/common/test \
$TWD_DIR/host/test \
+7 -7
View File
@@ -245,11 +245,6 @@ int Host::from_xml(const string& xml)
state = static_cast<HostState>( int_state );
if (rc != 0)
{
return -1;
}
// Get associated classes
ObjectXML::get_nodes("/HOST/HOST_SHARE", content);
@@ -258,7 +253,7 @@ int Host::from_xml(const string& xml)
return -1;
}
host_share.from_xml_node( content[0] );
rc += host_share.from_xml_node( content[0] );
content.clear();
@@ -269,7 +264,12 @@ int Host::from_xml(const string& xml)
return -1;
}
host_template.from_xml_node( content[0] );
rc += host_template.from_xml_node( content[0] );
if (rc != 0)
{
return -1;
}
return 0;
}
+20 -13
View File
@@ -89,26 +89,33 @@ string& HostShare::to_xml(string& xml) const
int HostShare::from_xml_node(const xmlNodePtr node)
{
int rc = 0;
// Initialize the internal XML object
ObjectXML::update_from_node(node);
xpath(disk_usage, "/HOST_SHARE/DISK_USAGE", -1);
xpath(mem_usage, "/HOST_SHARE/MEM_USAGE", -1);
xpath(cpu_usage, "/HOST_SHARE/CPU_USAGE", -1);
rc += xpath(disk_usage, "/HOST_SHARE/DISK_USAGE", -1);
rc += xpath(mem_usage, "/HOST_SHARE/MEM_USAGE", -1);
rc += xpath(cpu_usage, "/HOST_SHARE/CPU_USAGE", -1);
xpath(max_disk, "/HOST_SHARE/MAX_DISK", -1);
xpath(max_mem , "/HOST_SHARE/MAX_MEM", -1);
xpath(max_cpu , "/HOST_SHARE/MAX_CPU", -1);
rc += xpath(max_disk, "/HOST_SHARE/MAX_DISK", -1);
rc += xpath(max_mem , "/HOST_SHARE/MAX_MEM", -1);
rc += xpath(max_cpu , "/HOST_SHARE/MAX_CPU", -1);
xpath(free_disk, "/HOST_SHARE/FREE_DISK", -1);
xpath(free_mem , "/HOST_SHARE/FREE_MEM", -1);
xpath(free_cpu , "/HOST_SHARE/FREE_CPU", -1);
rc += xpath(free_disk, "/HOST_SHARE/FREE_DISK", -1);
rc += xpath(free_mem , "/HOST_SHARE/FREE_MEM", -1);
rc += xpath(free_cpu , "/HOST_SHARE/FREE_CPU", -1);
xpath(used_disk, "/HOST_SHARE/USED_DISK", -1);
xpath(used_mem , "/HOST_SHARE/USED_MEM", -1);
xpath(used_cpu , "/HOST_SHARE/USED_CPU", -1);
rc += xpath(used_disk, "/HOST_SHARE/USED_DISK", -1);
rc += xpath(used_mem , "/HOST_SHARE/USED_MEM", -1);
rc += xpath(used_cpu , "/HOST_SHARE/USED_CPU", -1);
xpath(running_vms,"/HOST_SHARE/RUNNING_VMS",-1);
rc += xpath(running_vms,"/HOST_SHARE/RUNNING_VMS",-1);
if (rc != 0)
{
return -1;
}
return 0;
}