Since cpus is now it's own table, we no longer have a "num_cpus" column to order by in available_vm_resources. Thanks to Scott Seago, replace this with a LEFT OUTER JOIN combined with a select to count the cpus for a particular host.
Chris Lalancette
2008-Jul-10 17:00 UTC
[Ovirt-devel] [PATCH] Since cpus is now it's own table, we no longer have a "num_cpus" column to
Signed-off-by: Chris Lalancette <clalance at redhat.com> --- wui/src/app/models/vm_resource_pool.rb | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/wui/src/app/models/vm_resource_pool.rb b/wui/src/app/models/vm_resource_pool.rb index 85e3661..de8bcb3 100644 --- a/wui/src/app/models/vm_resource_pool.rb +++ b/wui/src/app/models/vm_resource_pool.rb @@ -97,6 +97,9 @@ class VmResourcePool < Pool :conditions => "hardware_pool_id = #{hw_pool.id}") host_mem_limit = (memhost.nil? ? 0 : memhost.memory) cpuhost = Host.find(:first, :order => "num_cpus DESC", + :select => "hosts.id, count (cpus) as num_cpus", + :joins => "LEFT OUTER JOIN cpus ON hosts.id = cpus.host_id", + :group => "hosts.id", :conditions => "hardware_pool_id = #{hw_pool.id}") host_cpu_limit = cpuhost.nil? ? 0 : cpuhost.num_cpus resources[:memory] = host_mem_limit if resources[:memory].nil? or host_mem_limit < resources[:memory] -- 1.5.5.1
Chris Lalancette wrote:> Since cpus is now it's own table, we no longer have a "num_cpus" column to > order by in available_vm_resources. Thanks to Scott Seago, replace this with > a LEFT OUTER JOIN combined with a select to count the cpus for a particular > host. > > _______________________________________________ > Ovirt-devel mailing list > Ovirt-devel at redhat.com > https://www.redhat.com/mailman/listinfo/ovirt-develIgnore this; I was playing around with git-send-email, and it obviously did something different than what I thought it would do. Chris Lalancette