Skip to content

Commit

Permalink
Handle new debian profiles upload
Browse files Browse the repository at this point in the history
  • Loading branch information
sbernhard committed Oct 13, 2023
1 parent 2429eae commit 2e60fb4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ def update_kernel_version(version, release, old_kernel_version)
end
end

def kernelcare?
!installed_packages.select { |package| package.name == 'kernelcare' }.empty? ||
!installed_debs.select { |package| package.name == 'kernelcare' }.empty?
end

class ::Host::Managed::Jail < Safemode::Jail
allow :installed_debs
allow :installed_debs, :kernelcare?
end

protected
Expand Down Expand Up @@ -138,10 +143,5 @@ def sync_deb_kernel_associations(new_patched_kernel_ids, old_kernel_ids)
self.installed_deb_ids = new_installed_debs.concat(new_patched_kernel_ids)
save!
end

def kernelcare?
!installed_packages.select { |package| package.name == 'kernelcare' }.empty? ||
!installed_debs.select { |package| package.name == 'kernelcare' }.empty?
end
end
end
14 changes: 14 additions & 0 deletions app/services/concerns/foreman_kernel_care/profiles_uploader.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module ForemanKernelCare
module ProfilesUploader
extend ActiveSupport::Concern

def import_deb_package_profile(profile)
if @host.kernelcare?
composer = ::JobInvocationComposer.for_feature(:kernel_version, @host)
composer.triggering.mode = :future
composer.trigger!
end
super(profile)
end
end
end
2 changes: 2 additions & 0 deletions lib/foreman_kernel_care/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class Engine < ::Rails::Engine
engine_name 'foreman_kernel_care'

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

initializer 'foreman_kernel_care.register_plugin', :before => :finisher_hook do |_app|
Foreman::Plugin.register :foreman_kernel_care do
Expand All @@ -19,6 +20,7 @@ class Engine < ::Rails::Engine
# make sure the plugin is initialized before katello loads the host extensions
initializer 'foreman_kernel_care.load_kernelcare_override', :before => :finisher_hook, :after => ['katello.register_plugin', 'foreman_tasks.register_plugin'] do
::Katello::Concerns::HostManagedExtensions.prepend ForemanKernelCare::HostManagedExtensions
::Katello::Host::ProfilesUploader.prepend ForemanKernelCare::ProfilesUploader
::ForemanTasks::Api::TasksController.prepend ForemanKernelCare::ForemanTasks
end

Expand Down

0 comments on commit 2e60fb4

Please sign in to comment.