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 config Groups Model #12

Merged
merged 2 commits into from
Sep 14, 2020
Merged

Add config Groups Model #12

merged 2 commits into from
Sep 14, 2020

Conversation

shiramax
Copy link
Contributor

No description provided.

@@ -3,6 +3,8 @@ class Engine < ::Rails::Engine
engine_name 'foreman_puppet_enc'
isolate_namespace ForemanPuppetEnc

config.autoload_paths += Dir["#{config.root}/app/models/concerns"]
Copy link
Member

Choose a reason for hiding this comment

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

Have you tested we need to do this?

@ezr-ondrej ezr-ondrej linked an issue Jul 29, 2020 that may be closed by this pull request
Comment on lines 2 to 3
def change
HostConfigGroups.where(:host_type => 'Host::Managed/Base').update_all(:host_type => 'ForemanPuppetEnc::HostFacet')
Copy link
Member

@ezr-ondrej ezr-ondrej Aug 3, 2020

Choose a reason for hiding this comment

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

I believe this won't be as easy, because we need to change the id column as well. Now we would assume, that the same host_id is referencing to the facet_table, but that is not the case.
Here is proposed (pseudo = untested) code:

Suggested change
def change
HostConfigGroups.where(:host_type => 'Host::Managed/Base').update_all(:host_type => 'ForemanPuppetEnc::HostFacet')
def up
group_ids = HostConfigGroups.where(host_type: %w[Host::Base Host::Managed]).pluck(:config_group_id, :host_id)
group_ids = group_ids.each_with_object(Hash.new([])) {|(cfg_id, host_id), memo| memo[host_id] += [cfg_id] }
group_ids.each do |host_id, cfg_ids| do
facet = ForemanPuppetEnc::HostFacet.create(host_id: host_id)
HostConfigGroups.where(host_type: %w[Host::Base Host::Managed], host_id: host_id).update_all(host_type: 'ForemanPuppetEnc::HostFacet', host_id: facet.id)
end
end

@shiramax
Copy link
Contributor Author

@ezr-ondrej I think I've addressed all your comments, let me know if there is something else :)

@ezr-ondrej
Copy link
Member

Thanks @shiramax !! :)

ezr-ondrej pushed a commit to shiramax/foreman that referenced this pull request Jan 31, 2021
ezr-ondrej pushed a commit to shiramax/foreman that referenced this pull request Jan 31, 2021
ezr-ondrej pushed a commit to shiramax/foreman that referenced this pull request Jan 31, 2021
ezr-ondrej pushed a commit to shiramax/foreman that referenced this pull request Jan 31, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jan 31, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Feb 17, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Mar 10, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Mar 10, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Apr 1, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Apr 1, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Apr 14, 2021
kamils-iRonin pushed a commit to kamils-iRonin/foreman that referenced this pull request Apr 20, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request May 6, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request May 17, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request May 17, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request May 23, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request May 25, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request May 26, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jun 18, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jun 24, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jun 25, 2021
kamils-iRonin pushed a commit to kamils-iRonin/foreman that referenced this pull request Jun 28, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jun 30, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jul 1, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jul 7, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jul 11, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jul 14, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jul 16, 2021
ezr-ondrej pushed a commit to ezr-ondrej/foreman that referenced this pull request Jul 18, 2021
tbrisker pushed a commit to theforeman/foreman that referenced this pull request Jul 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Extract ConfigGroup
2 participants