Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use delegate for cpu_total_cores / cpu_cores_per_socket #12911

Merged
merged 1 commit into from
Dec 5, 2016

Conversation

kbrock
Copy link
Member

@kbrock kbrock commented Nov 30, 2016

The goal is to calculate columns like aggressive_vcpus_recommended_change_pct in the database.

These columns are calculated from cpu_total_cores among others.
Using a delegate here will define the arel for us so it can be a virtual attribute with sql.

(The final solution still requires all the other columns be converted to arel as well...)

related to #12733

https://bugzilla.redhat.com/show_bug.cgi?id=1395743
/cc @NickLaMuro FYI

@miq-bot
Copy link
Member

miq-bot commented Nov 30, 2016

Checked commit kbrock@be31c85 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
2 files checked, 0 offenses detected
Everything looks good. 🍪

@@ -157,8 +157,7 @@ class VmOrTemplate < ApplicationRecord
virtual_column :num_hard_disks, :type => :integer, :uses => {:hardware => :hard_disks}
virtual_column :num_disks, :type => :integer, :uses => {:hardware => :disks}
virtual_column :num_cpu, :type => :integer, :uses => :hardware
virtual_column :cpu_total_cores, :type => :integer, :uses => :hardware
virtual_column :cpu_cores_per_socket, :type => :integer, :uses => :hardware
virtual_delegate :cpu_total_cores, :cpu_cores_per_socket, :to => :hardware, :allow_nil => true, :default => 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Darga currently doesn't have #10476, which would allow for adding the :default option that you have here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks - removed from darga

@gtanzillo
Copy link
Member

👍 LGTM

@gtanzillo gtanzillo added this to the Sprint 50 Ending Dec 5, 2016 milestone Dec 5, 2016
@gtanzillo gtanzillo merged commit 91517e8 into ManageIQ:master Dec 5, 2016
@kbrock kbrock deleted the vm_hardware_delegates branch December 5, 2016 21:45
simaishi pushed a commit that referenced this pull request Mar 2, 2017
use delegate for cpu_total_cores / cpu_cores_per_socket
(cherry picked from commit 91517e8)

https://bugzilla.redhat.com/show_bug.cgi?id=1422647
@simaishi
Copy link
Contributor

simaishi commented Mar 2, 2017

Euwe backport details:

$ git log -1
commit 2a40d3523e9215cf630b39e29f5542c9e83120b1
Author: Gregg Tanzillo <gtanzill@redhat.com>
Date:   Mon Dec 5 15:39:20 2016 -0500

    Merge pull request #12911 from kbrock/vm_hardware_delegates
    
    use delegate for cpu_total_cores / cpu_cores_per_socket
    (cherry picked from commit 91517e8e080b1d6d64981e6334037fbec96d96b9)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1422647

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants