diff --git a/include/Host.h b/include/Host.h index 3d0e810613..0be4b79619 100644 --- a/include/Host.h +++ b/include/Host.h @@ -279,7 +279,72 @@ public: // ------------------------------------------------------------------------ // Share functions // ------------------------------------------------------------------------ + + /** + * + * + */ + int get_share_disk_usage() + { + return host_share.disk_usage; + } + + int get_share_mem_usage() + { + return host_share.mem_usage; + } + + int get_share_cpu_usage() + { + return host_share.cpu_usage; + } + + int get_share_max_disk() + { + return host_share.max_disk; + } + + int get_share_max_mem() + { + return host_share.max_mem; + } + + int get_share_max_cpu() + { + return host_share.max_cpu; + } + + int get_share_free_disk() + { + return host_share.free_disk; + } + + int get_share_free_mem() + { + return host_share.free_mem; + } + + int get_share_free_cpu() + { + return host_share.free_cpu; + } + + int get_share_used_disk() + { + return host_share.used_disk; + } + + int get_share_used_mem() + { + return host_share.used_mem; + } + + int get_share_used_cpu() + { + return host_share.used_cpu; + } + /** * Adds a new VM to the given share by icrementing the cpu,mem and disk * counters @@ -373,7 +438,7 @@ private: * The Host template, holds the Host attributes. */ HostTemplate host_template; - + /** * The Share represents the logical capacity associated with the host */ diff --git a/include/HostShare.h b/include/HostShare.h index b0f2c7e82f..0afcefcd6c 100644 --- a/include/HostShare.h +++ b/include/HostShare.h @@ -59,7 +59,7 @@ public: mem_usage += mem; disk_usage += disk; - running_vms++; + running_vms++; } /** diff --git a/src/scheduler/SchedulerHost.cc b/src/scheduler/SchedulerHost.cc index cdc97486c7..ed98344a70 100644 --- a/src/scheduler/SchedulerHost.cc +++ b/src/scheduler/SchedulerHost.cc @@ -31,10 +31,10 @@ void SchedulerHost::get_capacity(int& cpu, int& memory, int threshold) { int total_cpu; - get_template_attribute("FREEMEMORY",memory); - get_template_attribute("FREECPU",cpu); - - get_template_attribute("TOTALCPU",total_cpu); + memory = get_share_free_mem(); + cpu = get_share_free_cpu(); + + total_cpu = get_share_max_cpu(); /* eg. 96.7 >= 0.9 * 100, We need to round */ if ( cpu >= threshold * total_cpu )