mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-26 06:50:09 +03:00
feature #1613: Total, free and used capacity for Datastore class
This commit is contained in:
parent
dc7d8d2334
commit
6ee32c6a0e
@ -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
|
||||
// *************************************************************************
|
||||
|
@ -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();
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user