Skip to content

Commit

Permalink
use config.to_prepare
Browse files Browse the repository at this point in the history
and no need guard DB things, RemoteExecutionFeature.register already
does
  • Loading branch information
evgeni committed Sep 23, 2024
1 parent 172bb55 commit 0444a74
Showing 1 changed file with 20 additions and 26 deletions.
46 changes: 20 additions & 26 deletions lib/foreman_rh_cloud/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,32 +157,26 @@ def self.register_scheduled_task(task_class, cronline)
end
end

initializer 'foreman_rh_cloud.register_rex_features', :before => :finisher_hook, :after => 'foreman_remote_execution.register_plugin' do |app|
app.reloader.to_prepare do
# skip database manipulations while tables do not exist, like in migrations
if ActiveRecord::Base.connection.data_source_exists?(ForemanTasks::Task.table_name)
RemoteExecutionFeature.register(
:rh_cloud_remediate_hosts,
N_('Apply Insights recommendations'),
description: N_('Run remediation playbook generated by Insights'),
host_action_button: false
)
RemoteExecutionFeature.register(
:rh_cloud_connector_run_playbook,
N_('Run RH Cloud playbook'),
description: N_('Run playbook genrated by Red Hat remediations app'),
host_action_button: false,
provided_inputs: ['playbook_url', 'report_url', 'correlation_id', 'report_interval']
)
RemoteExecutionFeature.register(
:ansible_configure_cloud_connector,
N_('Configure Cloud Connector on given hosts'),
:description => N_('Configure Cloud Connector on given hosts'),
:proxy_selector_override => ::RemoteExecutionProxySelector::INTERNAL_PROXY
)
end
rescue ActiveRecord::NoDatabaseError
end
config.to_prepare
RemoteExecutionFeature.register(
:rh_cloud_remediate_hosts,
N_('Apply Insights recommendations'),
description: N_('Run remediation playbook generated by Insights'),
host_action_button: false
)
RemoteExecutionFeature.register(
:rh_cloud_connector_run_playbook,
N_('Run RH Cloud playbook'),
description: N_('Run playbook genrated by Red Hat remediations app'),
host_action_button: false,
provided_inputs: ['playbook_url', 'report_url', 'correlation_id', 'report_interval']
)
RemoteExecutionFeature.register(
:ansible_configure_cloud_connector,
N_('Configure Cloud Connector on given hosts'),
:description => N_('Configure Cloud Connector on given hosts'),
:proxy_selector_override => ::RemoteExecutionProxySelector::INTERNAL_PROXY
)
end

initializer 'foreman_rh_cloud.register_scheduled_tasks', :before => :finisher_hook do |_app|
Expand Down

0 comments on commit 0444a74

Please sign in to comment.