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

Add ext_management_system method to conversion host #18097

Merged
merged 3 commits into from
Oct 15, 2018

Conversation

ghost
Copy link

@ghost ghost commented Oct 15, 2018

When working with the conversion host, it might be useful to filter by EMS. For example, when throttling the migrations, one of the metrics is the number of concurrent tasks per EMS. So, getting the conversion hosts per EMS will be useful. This PR adds the ext_management_system method that returns the EMS of the resource. Currently, throttling is done in Automate and this PR requires it: ManageIQ/manageiq-content#441

Associated RHBZ: https://bugzilla.redhat.com/show_bug.cgi?id=1634029

@ghost
Copy link
Author

ghost commented Oct 15, 2018

@miq-bot add-label transformation, enhancement, hammer/yes
@miq-bot add-reviewer agrare

@@ -7,6 +7,10 @@ class ConversionHost < ApplicationRecord
has_many :service_template_transformation_plan_tasks, :dependent => :nullify
has_many :active_tasks, -> { where(:state => 'active') }, :class_name => ServiceTemplateTransformationPlanTask, :inverse_of => :conversion_host

def ext_management_system
resource.ext_management_system
Copy link
Member

Choose a reason for hiding this comment

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

You'd be better off using delegate :ext_management_system, :to => :resource

@agrare
Copy link
Member

agrare commented Oct 15, 2018

Ha I beat miq-bot by 1.5min!

@@ -6,6 +6,7 @@ class ConversionHost < ApplicationRecord
belongs_to :resource, :polymorphic => true
has_many :service_template_transformation_plan_tasks, :dependent => :nullify
has_many :active_tasks, -> { where(:state => 'active') }, :class_name => ServiceTemplateTransformationPlanTask, :inverse_of => :conversion_host
delegate :ext_management_system, :to => :resource
Copy link
Member

Choose a reason for hiding this comment

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

You might also want :allow_nil => true so that if the conversion host isn't linked to any inventory item this doesn't raise a NoMethodError but just returns nil

@miq-bot
Copy link
Member

miq-bot commented Oct 15, 2018

Checked commits fabiendupont/manageiq@7646495~...90da9fa with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. 🍪

@agrare agrare self-assigned this Oct 15, 2018
@agrare agrare merged commit 8bc0049 into ManageIQ:master Oct 15, 2018
@ghost ghost deleted the conversion_host_ems branch October 15, 2018 20:18
simaishi pushed a commit that referenced this pull request Oct 16, 2018
Add ext_management_system method to conversion host

(cherry picked from commit 8bc0049)

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

Hammer backport details:

$ git log -1
commit fe677b4829b43c2bb863967f03f93f9a81f20555
Author: Adam Grare <agrare@redhat.com>
Date:   Mon Oct 15 15:43:54 2018 -0400

    Merge pull request #18097 from fdupont-redhat/conversion_host_ems
    
    Add ext_management_system method to conversion host
    
    (cherry picked from commit 8bc00490381b6b84fb4f65d3b6577924d576b5fd)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1634029

@agrare agrare added this to the Sprint 97 Ending Oct 22, 2018 milestone Feb 14, 2019
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.

4 participants