[Ovirt-devel] Re: [patch] correct availability graph units

Hugh O. Brock hbrock at redhat.com
Sat Jun 7 05:09:51 UTC 2008


On Fri, Jun 06, 2008 at 10:52:25PM -0400, Scott Seago wrote:
>
>>
>> This is a hack, but in light of the difficulty in getting memory out of 
>> the db properly, 
>> ACK
>>
>> --Hugh
>>   
> Slightly less hackish hack applied. Less hackish in that we're using the 
> same hack already elsewhere -- built-in _to_mb conversions in the model 
> classes.
>
> Scott

> >From d96ab501f059fc38a0fb2b793f9ce55be8f020bc Mon Sep 17 00:00:00 2001
> From: Scott Seago <sseago at redhat.com>
> Date: Fri, 6 Jun 2008 22:48:53 -0400
> Subject: [PATCH] a slightly less hackish way of fixing the MB ram units on the summary graphs. Still not ideal, but it's consistent with what we're doing elsewhere, as we're already using the kb_to_mb (and vice versa) conversions in the model
> 
> 
> Signed-off-by: Scott Seago <sseago at redhat.com>
> ---
>  wui/src/app/controllers/graph_controller.rb |   12 +++---------
>  wui/src/app/models/pool.rb                  |    3 +++
>  2 files changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/wui/src/app/controllers/graph_controller.rb b/wui/src/app/controllers/graph_controller.rb
> index b02c93d..21f38f7 100644
> --- a/wui/src/app/controllers/graph_controller.rb
> +++ b/wui/src/app/controllers/graph_controller.rb
> @@ -25,8 +25,8 @@ class GraphController < ApplicationController
>          total= pools.inject(0){ |sum, pool| sum+pool.hosts.total_cpus }
>        elsif @target == 'memory'
>          @label = "MB of Memory"
> -        used= vmpools.inject(0){ |sum, pool| sum+pool.allocated_resources[:current][:memory] }
> -        total= pools.inject(0){ |sum, pool| sum+pool.hosts.total_memory }
> +        used= vmpools.inject(0){ |sum, pool| sum+pool.allocated_resources[:current][:memory_in_mb] }
> +        total= pools.inject(0){ |sum, pool| sum+pool.hosts.total_memory_in_mb }
>        end
>      elsif ['vcpu', 'vram'].include? (@target)
>        pool = VmResourcePool.find(@id)
> @@ -36,7 +36,7 @@ class GraphController < ApplicationController
>          resource_key = :cpus
>        elsif @target == 'vram'
>          @label = "MB of VMemory"
> -        resource_key = :memory
> +        resource_key = :memory_in_mb
>        end
>        unlimited = false
>        total=0
> @@ -52,12 +52,6 @@ class GraphController < ApplicationController
>        total = 0 if unlimited
>      end
>  
> -    # bit of a hack to convert memory from kb to mb
> -    if @target == 'memory' || @target == 'vram'
> -        used  /= 1024
> -        total /= 1024
> -    end
> -
>      @availability_graph_data = { 'Used' => used, 'Total' => total, 'Available' => total - used}
>    end
>  
> diff --git a/wui/src/app/models/pool.rb b/wui/src/app/models/pool.rb
> index ca3b1f9..4a21c4a 100644
> --- a/wui/src/app/models/pool.rb
> +++ b/wui/src/app/models/pool.rb
> @@ -31,6 +31,9 @@ class Pool < ActiveRecord::Base
>      def total_memory
>        find(:all).inject(0){ |sum, host| sum + host.memory }
>      end
> +    def total_memory_in_mb
> +      find(:all).inject(0){ |sum, host| sum + host.memory_in_mb }
> +    end
>    end
>  
>    has_many :storage_pools, :dependent => :nullify, :order => "id ASC", :foreign_key => 'hardware_pool_id' do
> -- 
> 1.5.4.1
> 

ACK

I was hoping you had a solution along these lines but I didn't know the details... thanks.

--Hugh




More information about the ovirt-devel mailing list