1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-26 06:50:09 +03:00

Feature #1678: small refactor

This commit is contained in:
Carlos Martín 2013-10-22 17:20:23 +02:00
parent 51124a9d12
commit bf8c8f1646
3 changed files with 20 additions and 10 deletions

View File

@ -174,15 +174,11 @@ public:
{
string err;
monitor_data.get("TOTAL_MB", total_mb);
monitor_data.get("FREE_MB", free_mb);
monitor_data.get("USED_MB", used_mb);
monitor_data.erase("TOTAL_MB");
monitor_data.erase("FREE_MB");
monitor_data.erase("USED_MB");
obj_template->merge(&monitor_data, err);
erase_template_attribute("TOTAL_MB", total_mb);
erase_template_attribute("FREE_MB", free_mb);
erase_template_attribute("USED_MB", used_mb);
};
/**

View File

@ -381,6 +381,21 @@ public:
return obj_template->erase(name);
}
/**
* Gets and removes a boolean based attribute (single)
* @param name of the attribute
* @param value of the attribute (a boolean), will be false if not defined or
* not a single attribute
* @return the number of attributes erased
*/
int erase_template_attribute(
const char * name,
bool& value)
{
obj_template->get(name,value);
return obj_template->erase(name);
}
/**
* Gets an int based attribute (single)
* @param name of the attribute

View File

@ -341,8 +341,7 @@ int Host::update_info(string &parse_str,
// Correlate VM information with the list of running VMs //
// ---------------------------------------------------------------------- //
get_template_attribute("VM_POLL", with_vm_info);
remove_template_attribute("VM_POLL");
erase_template_attribute("VM_POLL", with_vm_info);
obj_template->remove("VM", vm_att);