-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
katello depends on REX these days, so we can drop that helper
- Loading branch information
Showing
12 changed files
with
105 additions
and
140 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,75 +1,70 @@ | ||
module Katello | ||
if Katello.with_remote_execution? | ||
class RemoteExecutionController < JobInvocationsController | ||
include ::Api::V2::BulkHostsExtension | ||
include Concerns::Api::V2::HostErrataExtensions | ||
class RemoteExecutionController < JobInvocationsController | ||
include ::Api::V2::BulkHostsExtension | ||
include Concerns::Api::V2::HostErrataExtensions | ||
|
||
def new | ||
@composer = prepare_composer | ||
end | ||
|
||
def create | ||
@composer = prepare_composer | ||
if params[:customize] != 'true' && @composer.save | ||
@composer.trigger | ||
redirect_to job_invocation_path(@composer.job_invocation) | ||
else | ||
render :action => 'new' | ||
end | ||
end | ||
def new | ||
@composer = prepare_composer | ||
end | ||
|
||
# to overcome the isolated namespace engine difficulties with paths | ||
helper Rails.application.routes.url_helpers | ||
def _routes | ||
Rails.application.routes | ||
def create | ||
@composer = prepare_composer | ||
if params[:customize] != 'true' && @composer.save | ||
@composer.trigger | ||
redirect_to job_invocation_path(@composer.job_invocation) | ||
else | ||
render :action => 'new' | ||
end | ||
end | ||
|
||
private | ||
# to overcome the isolated namespace engine difficulties with paths | ||
helper Rails.application.routes.url_helpers | ||
def _routes | ||
Rails.application.routes | ||
end | ||
|
||
def prepare_composer | ||
JobInvocationComposer.for_feature(feature_name, hosts, inputs) | ||
end | ||
private | ||
|
||
def hosts | ||
bulk_host_ids = ActiveSupport::JSON.decode(params[:bulk_host_ids]).deep_symbolize_keys | ||
def prepare_composer | ||
JobInvocationComposer.for_feature(feature_name, hosts, inputs) | ||
end | ||
|
||
find_bulk_hosts('edit_hosts', bulk_host_ids) | ||
end | ||
def hosts | ||
bulk_host_ids = ActiveSupport::JSON.decode(params[:bulk_host_ids]).deep_symbolize_keys | ||
|
||
def errata_inputs | ||
if ::Foreman::Cast.to_bool(params[:install_all]) | ||
Erratum.installable_for_hosts(hosts).pluck(:errata_id).join(',') | ||
elsif params[:bulk_errata_ids] | ||
find_bulk_errata_ids(hosts, params[:bulk_errata_ids]).join(',') | ||
else | ||
params[:name] | ||
end | ||
end | ||
find_bulk_hosts('edit_hosts', bulk_host_ids) | ||
end | ||
|
||
def inputs | ||
case feature_name | ||
when 'katello_errata_install' | ||
{ :errata => errata_inputs } | ||
when 'katello_service_restart' | ||
{ :helper => params[:name] } | ||
when 'katello_module_stream_action' | ||
fail HttpErrors::NotFound, _('module streams not found') if params[:module_spec].blank? | ||
fail HttpErrors::NotFound, _('actions not found') if params[:module_stream_action].blank? | ||
inputs = { :module_spec => params[:module_spec], :action => params[:module_stream_action] } | ||
inputs[:options] = params[:options] if params[:options] | ||
inputs | ||
else | ||
{ :package => params[:name] } | ||
end | ||
def errata_inputs | ||
if ::Foreman::Cast.to_bool(params[:install_all]) | ||
Erratum.installable_for_hosts(hosts).pluck(:errata_id).join(',') | ||
elsif params[:bulk_errata_ids] | ||
find_bulk_errata_ids(hosts, params[:bulk_errata_ids]).join(',') | ||
else | ||
params[:name] | ||
end | ||
end | ||
|
||
def feature_name | ||
# getting packageInstall from UI, translating to 'katello_package_install' feature | ||
"katello_#{params[:remote_action].underscore}" | ||
def inputs | ||
case feature_name | ||
when 'katello_errata_install' | ||
{ :errata => errata_inputs } | ||
when 'katello_service_restart' | ||
{ :helper => params[:name] } | ||
when 'katello_module_stream_action' | ||
fail HttpErrors::NotFound, _('module streams not found') if params[:module_spec].blank? | ||
fail HttpErrors::NotFound, _('actions not found') if params[:module_stream_action].blank? | ||
inputs = { :module_spec => params[:module_spec], :action => params[:module_stream_action] } | ||
inputs[:options] = params[:options] if params[:options] | ||
inputs | ||
else | ||
{ :package => params[:name] } | ||
end | ||
end | ||
else | ||
class RemoteExecutionController < ApplicationController | ||
|
||
def feature_name | ||
# getting packageInstall from UI, translating to 'katello_package_install' feature | ||
"katello_#{params[:remote_action].underscore}" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,10 @@ | ||
if Katello.with_remote_execution? | ||
User.as_anonymous_admin do | ||
JobTemplate.without_auditing do | ||
module_template = JobTemplate.find_by(name: 'Module Action - Script Default') | ||
if module_template | ||
module_template.sync_feature('katello_module_stream_action') | ||
module_template.organizations << Organization.unscoped.all if module_template.organizations.empty? | ||
module_template.locations << Location.unscoped.all if module_template.locations.empty? | ||
end | ||
User.as_anonymous_admin do | ||
JobTemplate.without_auditing do | ||
module_template = JobTemplate.find_by(name: 'Module Action - Script Default') | ||
if module_template | ||
module_template.sync_feature('katello_module_stream_action') | ||
module_template.organizations << Organization.unscoped.all if module_template.organizations.empty? | ||
module_template.locations << Location.unscoped.all if module_template.locations.empty? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,18 @@ | ||
if Katello.with_remote_execution? | ||
User.as_anonymous_admin do | ||
JobTemplate.without_auditing do | ||
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| | ||
sync = !Rails.env.test? && Setting[:remote_execution_sync_templates] | ||
# import! was renamed to import_raw! around 1.3.1 | ||
if JobTemplate.respond_to?('import_raw!') | ||
template = JobTemplate.import_raw!(File.read(template), :default => true, :lock => true, :update => sync) | ||
else | ||
template = JobTemplate.import!(File.read(template), :default => true, :lock => true, :update => sync) | ||
end | ||
|
||
template.organizations << Organization.unscoped.all if template&.organizations&.empty? | ||
template.locations << Location.unscoped.all if template&.locations&.empty? | ||
User.as_anonymous_admin do | ||
JobTemplate.without_auditing do | ||
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| | ||
sync = !Rails.env.test? && Setting[:remote_execution_sync_templates] | ||
# import! was renamed to import_raw! around 1.3.1 | ||
if JobTemplate.respond_to?('import_raw!') | ||
template = JobTemplate.import_raw!(File.read(template), :default => true, :lock => true, :update => sync) | ||
else | ||
template = JobTemplate.import!(File.read(template), :default => true, :lock => true, :update => sync) | ||
end | ||
|
||
template.organizations << Organization.unscoped.all if template&.organizations&.empty? | ||
template.locations << Location.unscoped.all if template&.locations&.empty? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters