diff --git a/include/Datastore.h b/include/Datastore.h index e6fd9a43c5..9fcb93da7d 100644 --- a/include/Datastore.h +++ b/include/Datastore.h @@ -149,6 +149,19 @@ public: */ int replace_template(const string& tmpl_str, string& error); + /** + * Set monitor information for the Datastore + * @param total_mb + * @param free_mb + * @param used_mb + */ + void update_monitor(unsigned int total, unsigned int free, unsigned int used) + { + total_mb = total; + free_mb = free; + used_mb = used; + } + private: // ------------------------------------------------------------------------- @@ -186,6 +199,21 @@ private: */ Image::DiskType disk_type; + /** + * Total datastore capacity in MB + */ + unsigned int total_mb; + + /** + * Available datastore capacity in MB + */ + unsigned int free_mb; + + /** + * Used datastore capacity in MB + */ + unsigned int used_mb; + // ************************************************************************* // Constructor // ************************************************************************* diff --git a/src/datastore/Datastore.cc b/src/datastore/Datastore.cc index 2a445fd50c..47be96efc1 100644 --- a/src/datastore/Datastore.cc +++ b/src/datastore/Datastore.cc @@ -52,7 +52,10 @@ Datastore::Datastore( ds_mad(""), tm_mad(""), base_path(ds_location), - type(IMAGE_DS) + type(IMAGE_DS), + total_mb(0), + free_mb(0), + used_mb(0) { if (ds_template != 0) { @@ -331,6 +334,9 @@ string& Datastore::to_xml(string& xml) const "<DISK_TYPE>" << disk_type << "</DISK_TYPE>" << "<CLUSTER_ID>" << cluster_id << "</CLUSTER_ID>" << "<CLUSTER>" << cluster << "</CLUSTER>" << + "<TOTAL_MB>" << total_mb << "</TOTAL_MB>" << + "<FREE_MB>" << free_mb << "</FREE_MB>" << + "<USED_MB>" << used_mb << "</USED_MB>" << collection_xml << obj_template->to_xml(template_xml) << "</DATASTORE>"; @@ -369,6 +375,10 @@ int Datastore::from_xml(const string& xml) rc += xpath(cluster_id, "/DATASTORE/CLUSTER_ID", -1); rc += xpath(cluster, "/DATASTORE/CLUSTER", "not_found"); + rc += xpath(total_mb, "/DATASTORE/TOTAL_MB", 0); + rc += xpath(free_mb, "/DATASTORE/FREE_MB", 0); + rc += xpath(used_mb, "/DATASTORE/USED_MB", 0); + // Permissions rc += perms_from_xml();