From df833812cc7797d7f1b6e5a923b5869d30e212d5 Mon Sep 17 00:00:00 2001 From: Lucy Fu Date: Wed, 11 Dec 2024 16:47:54 -0500 Subject: [PATCH] Fixes #38084 - Add new REX job templates for bootc upgrade/switch/rollback --- .../foreman/job_templates/bootc_action.erb | 25 +++++++++++++++++++ .../foreman/job_templates/bootc_rollback.erb | 13 ++++++++++ .../foreman/job_templates/bootc_status.erb | 13 ++++++++++ .../foreman/job_templates/bootc_switch.erb | 13 ++++++++++ .../foreman/job_templates/bootc_upgrade.erb | 13 ++++++++++ db/seeds.d/75-job_templates.rb | 3 ++- lib/katello/plugin.rb | 4 +++ 7 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 app/views/foreman/job_templates/bootc_action.erb create mode 100644 app/views/foreman/job_templates/bootc_rollback.erb create mode 100644 app/views/foreman/job_templates/bootc_status.erb create mode 100644 app/views/foreman/job_templates/bootc_switch.erb create mode 100644 app/views/foreman/job_templates/bootc_upgrade.erb diff --git a/app/views/foreman/job_templates/bootc_action.erb b/app/views/foreman/job_templates/bootc_action.erb new file mode 100644 index 00000000000..e5619d4adef --- /dev/null +++ b/app/views/foreman/job_templates/bootc_action.erb @@ -0,0 +1,25 @@ +<%# +kind: job_template +name: Bootc Action - Script Default +model: JobTemplate +job_category: Katello +description_format: 'bootc %{action} %{options}' +provider_type: script +feature: katello_bootc_action +template_inputs: +- name: action + description: 'The bootc action: upgrade, switch, rollback or status' + input_type: user + options: "upgrade\nswitch\nrollback\nstatus" + required: true +- name: options + description: Additional options for bootc action + input_type: user + required: false +- name: target + description: Target for bootc switch action + input_type: user + required: false +%> + +bootc <%= input('action') %> <%= input('options') %> <%= input('target') %> diff --git a/app/views/foreman/job_templates/bootc_rollback.erb b/app/views/foreman/job_templates/bootc_rollback.erb new file mode 100644 index 00000000000..9a24dc9b480 --- /dev/null +++ b/app/views/foreman/job_templates/bootc_rollback.erb @@ -0,0 +1,13 @@ +<%# +kind: job_template +name: Bootc Rollback - Katello Script Default +job_category: Katello +description_format: 'bootc rollback' +feature: katello_bootc_rollback +provider_type: script +foreign_input_sets: +- template: Bootc Action - Script Default + exclude: action, options, target +%> + +<%= render_template('Bootc Action - Script Default', :action => 'rollback') %> diff --git a/app/views/foreman/job_templates/bootc_status.erb b/app/views/foreman/job_templates/bootc_status.erb new file mode 100644 index 00000000000..dc1244ad58e --- /dev/null +++ b/app/views/foreman/job_templates/bootc_status.erb @@ -0,0 +1,13 @@ +<%# +kind: job_template +name: Bootc Status - Katello Script Default +job_category: Katello +description_format: 'bootc status %{options}' +feature: katello_bootc_status +provider_type: script +foreign_input_sets: +- template: Bootc Action - Script Default + exclude: action, target +%> + +<%= render_template('Bootc Action - Script Default', :action => 'status') %> diff --git a/app/views/foreman/job_templates/bootc_switch.erb b/app/views/foreman/job_templates/bootc_switch.erb new file mode 100644 index 00000000000..e5ece63db42 --- /dev/null +++ b/app/views/foreman/job_templates/bootc_switch.erb @@ -0,0 +1,13 @@ +<%# +kind: job_template +name: Bootc Switch - Katello Script Default +job_category: Katello +description_format: 'bootc switch %{options} %{target}' +feature: katello_bootc_switch +provider_type: script +foreign_input_sets: +- template: Bootc Action - Script Default + exclude: action +%> + +<%= render_template('Bootc Action - Script Default', :action => 'switch') %> diff --git a/app/views/foreman/job_templates/bootc_upgrade.erb b/app/views/foreman/job_templates/bootc_upgrade.erb new file mode 100644 index 00000000000..e726a870385 --- /dev/null +++ b/app/views/foreman/job_templates/bootc_upgrade.erb @@ -0,0 +1,13 @@ +<%# +kind: job_template +name: Bootc Upgrade - Katello Script Default +job_category: Katello +description_format: 'bootc upgrade %{options}' +feature: katello_bootc_upgrade +provider_type: script +foreign_input_sets: +- template: Bootc Action - Script Default + exclude: action, target +%> + +<%= render_template('Bootc Action - Script Default', :action => 'upgrade') %> diff --git a/db/seeds.d/75-job_templates.rb b/db/seeds.d/75-job_templates.rb index 385bc3f3ae6..0accbd8cdba 100644 --- a/db/seeds.d/75-job_templates.rb +++ b/db/seeds.d/75-job_templates.rb @@ -1,8 +1,9 @@ User.as_anonymous_admin do JobTemplate.without_auditing do + root_action_files = Dir[File.join("#{Katello::Engine.root}/app/views/foreman/job_templates/**/*_action.erb")] template_files = Dir[File.join("#{Katello::Engine.root}/app/views/foreman/job_templates/**/*.erb")] template_files.reject! { |file| file.end_with?('_ansible_default.erb') } unless Katello.with_ansible? - template_files.each do |template| + (root_action_files + (template_files - root_action_files)).each do |template| sync = !Rails.env.test? && Setting[:remote_execution_sync_templates] template = JobTemplate.import_raw!(File.read(template), :default => true, :lock => true, :update => sync) diff --git a/lib/katello/plugin.rb b/lib/katello/plugin.rb index 4c5ee25098e..6cfd4c387d0 100644 --- a/lib/katello/plugin.rb +++ b/lib/katello/plugin.rb @@ -696,6 +696,10 @@ def katello_template_setting_values(name) RemoteExecutionFeature.register(:katello_module_stream_action, N_("Katello: Module Stream Actions"), :description => N_("Perform a module stream action via Katello interface"), :provided_inputs => ['action', 'module_spec', 'options']) + RemoteExecutionFeature.register(:katello_bootc_upgrade, N_("Katello: Bootc Upgrade"), :description => N_("Bootc upgrade via Katello interface")) + RemoteExecutionFeature.register(:katello_bootc_switch, N_("Katello: Bootc Switch"), :description => N_("Bootc switch via Katello interface")) + RemoteExecutionFeature.register(:katello_bootc_rollback, N_("Katello: Bootc Rollback"), :description => N_("Bootc rollback via Katello interface")) + RemoteExecutionFeature.register(:katello_bootc_status, N_("Katello: Bootc Status"), :description => N_("Bootc status via Katello interface")) allowed_template_helpers :errata RemoteExecutionProvider.singleton_class.prepend(Katello::Concerns::RemoteExecutionProviderExtensions)