-
Notifications
You must be signed in to change notification settings - Fork 24
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
Conversation
lib/foreman_puppet_enc/engine.rb
Outdated
@@ -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"] |
There was a problem hiding this comment.
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?
def change | ||
HostConfigGroups.where(:host_type => 'Host::Managed/Base').update_all(:host_type => 'ForemanPuppetEnc::HostFacet') |
There was a problem hiding this comment.
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:
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 |
@ezr-ondrej I think I've addressed all your comments, let me know if there is something else :) |
Thanks @shiramax !! :) |
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
Added to the plugin in theforeman/foreman_puppet#12
No description provided.