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

Adjust power states on a service to handle children #14550

Conversation

syncrou
Copy link
Contributor

@syncrou syncrou commented Mar 28, 2017

For an atomic service with children.

  1. Iterate through the children if there are no service_resources on the parent
  2. Iterate through the children for power_states to adjust the power state and status for
    the entire service

https://bugzilla.redhat.com/show_bug.cgi?id=1416903

@syncrou
Copy link
Contributor Author

syncrou commented Mar 28, 2017

@miq-bot assign @gmcculloug

@miq-bot add_label bug, services

children.present?
end

def empty_child_resources?
Copy link
Member

Choose a reason for hiding this comment

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

Discussed with @syncrou and was originally thinking these methods could be remove, but are leaning toward replacing them with atomic? and composite? methods to match the terminology used for service_templates.

The difference with services is they can change between atomic and composite after they are created through automate or API calls. Therefore we need methods to determine what their current configuration is.

@syncrou syncrou force-pushed the 1416903_vm_power_opts_on_assoc_child_service branch 2 times, most recently from a17b1a6 to 6e8febd Compare April 5, 2017 15:45
elsif atomic? && (power_states[0] == POWER_STATE_MAP[action])
return update_power_status(action)
end
return update_power_status(action) if all_states_match?(action)
Copy link
Member

Choose a reason for hiding this comment

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

Could simplify to: all_states_match?(action) ? update_power_status(action) : false

each_group_resource do |svc_rsc|
sa << svc_rsc
end
end.map(&action_name.to_sym).uniq
Copy link
Member

Choose a reason for hiding this comment

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

Maybe set action_name to a symbol when setting the variable action_name = "#{action}_action".to_sym instead of during each call. Also, you end up calling compact on service_actions below, should that happen here?

I am feeling like this block should be broken out into a separate method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@gmcculloug - Are you thinking lines 208 - 211 should be broken out into their own method?

Copy link
Member

Choose a reason for hiding this comment

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

Lines 208 - 212 could be a method that returns service_actions.

@syncrou syncrou force-pushed the 1416903_vm_power_opts_on_assoc_child_service branch from 6e8febd to f2a06a8 Compare April 18, 2017 19:48
@miq-bot
Copy link
Member

miq-bot commented Apr 18, 2017

Checked commits syncrou/manageiq@ec58361~...f2a06a8 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
3 files checked, 0 offenses detected
Everything looks good. 🏆

@gmcculloug gmcculloug merged commit 30fc1b9 into ManageIQ:master Apr 18, 2017
@gmcculloug gmcculloug added this to the Sprint 59 Ending Apr 24, 2017 milestone Apr 18, 2017
@syncrou syncrou deleted the 1416903_vm_power_opts_on_assoc_child_service branch April 18, 2017 20:57
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.

3 participants