On Fri, Jul 02, 2010 at 10:23:59AM +0100, mtaylor@redhat.com wrote:
From: martyntaylor mtaylor@redhat.com
src/app/services/data_service.rb | 44 ++++++++++++++++++++++--------------- 1 files changed, 26 insertions(+), 18 deletions(-)
diff --git a/src/app/services/data_service.rb b/src/app/services/data_service.rb index 9343fb1..d741574 100644 --- a/src/app/services/data_service.rb +++ b/src/app/services/data_service.rb @@ -62,24 +62,28 @@ class DataService
# Returns the Used and Maximum Resource Usage def self.quota_utilisation(parent, resource_name)
- quota = parent.quota
- case resource_name
when Quota::RESOURCE_RUNNING_INSTANCES
return QuotaUsagePoint.new(quota.running_instances, quota.maximum_running_instances)
when Quota::RESOURCE_RUNNING_MEMORY
return QuotaUsagePoint.new(quota.running_memory.to_f, quota.maximum_running_memory.to_f)
when Quota::RESOURCE_RUNNING_CPUS
return QuotaUsagePoint.new(quota.running_cpus.to_f, quota.maximum_running_cpus.to_f)
when Quota::RESOURCE_TOTAL_INSTANCES
return QuotaUsagePoint.new(quota.total_instances, quota.maximum_total_instances)
when Quota::RESOURCE_TOTAL_STORAGE
return QuotaUsagePoint.new(quota.total_storage.to_f, quota.maximum_total_storage.to_f)
when Quota::RESOURCE_OVERALL
return self.overall_usage(parent)
else
return nil
if parent
quota = parent.quota
if quota
case resource_name
when Quota::RESOURCE_RUNNING_INSTANCES
return QuotaUsagePoint.new(quota.running_instances, quota.maximum_running_instances)
when Quota::RESOURCE_RUNNING_MEMORY
return QuotaUsagePoint.new(quota.running_memory.to_f, quota.maximum_running_memory.to_f)
when Quota::RESOURCE_RUNNING_CPUS
return QuotaUsagePoint.new(quota.running_cpus.to_f, quota.maximum_running_cpus.to_f)
when Quota::RESOURCE_TOTAL_INSTANCES
return QuotaUsagePoint.new(quota.total_instances, quota.maximum_total_instances)
when Quota::RESOURCE_TOTAL_STORAGE
return QuotaUsagePoint.new(quota.total_storage.to_f, quota.maximum_total_storage.to_f)
when Quota::RESOURCE_OVERALL
return self.overall_usage(parent)
else
return nil
end
end
end
return nil end
def self.overall_usage(parent)
@@ -91,7 +95,11 @@ class DataService worst_case = nil usage_points.each do |usage_point| if worst_case
if ((100 / worst_case.max) * worst_case.used) < ((100 / usage_point.max) * usage_point.used)
if worst_case.max == Quota::NO_LIMIT
worst_case = usage_point
elsif usage_point.max == Quota::NO_LIMIT
# DO Nothing
elsif ((100 / worst_case.max) * worst_case.used) < ((100 / usage_point.max) * usage_point.used) worst_case = usage_point end else
-- 1.6.6.1
deltacloud-devel mailing list deltacloud-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/deltacloud-devel
NACK, this adds a bug which you correct in the next part of this patch series. It'd be better if it were cleaned up...I spent (a small amount of) time trying to debug this only to realize it was corrected in the next patch.
Otherwise, the first two in this series are OK imho. When you get part 3 fixed up, I'll be happy to review it.
Thx, S