diff --git a/include/Datastore.h b/include/Datastore.h index 5809ed8348..6ccd8b79a1 100644 --- a/include/Datastore.h +++ b/include/Datastore.h @@ -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); }; /** diff --git a/include/PoolObjectSQL.h b/include/PoolObjectSQL.h index 4b3ea70a0b..60e7c170af 100644 --- a/include/PoolObjectSQL.h +++ b/include/PoolObjectSQL.h @@ -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 diff --git a/src/host/Host.cc b/src/host/Host.cc index d87b69b5b5..0973237fea 100644 --- a/src/host/Host.cc +++ b/src/host/Host.cc @@ -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);