foreman_rh_cloud 5.0.37 → 5.0.38
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +0 -7
- data/config/package-lock.json +41822 -0
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud/async/cloud_connector_announce_task.rb +44 -0
- data/package.json +6 -6
- data/test/jobs/cloud_connector_announce_task_test.rb +125 -0
- metadata +13 -9
@@ -0,0 +1,44 @@
|
|
1
|
+
module InsightsCloud
|
2
|
+
module Async
|
3
|
+
class CloudConnectorAnnounceTask < ::Actions::EntryAction
|
4
|
+
def self.subscribe
|
5
|
+
Actions::RemoteExecution::RunHostsJob
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.connector_feature_id
|
9
|
+
@connector_feature_id ||= RemoteExecutionFeature.feature!(ForemanRhCloud::CloudConnector::CLOUD_CONNECTOR_FEATURE).id
|
10
|
+
end
|
11
|
+
|
12
|
+
def plan(job_invocation)
|
13
|
+
return unless connector_playbook_job?(job_invocation)
|
14
|
+
|
15
|
+
plan_self
|
16
|
+
end
|
17
|
+
|
18
|
+
def finalize
|
19
|
+
Organization.unscoped.each do |org|
|
20
|
+
presence = ForemanRhCloud::CloudPresence.new(org, logger)
|
21
|
+
presence.announce_to_sources
|
22
|
+
rescue StandardError => ex
|
23
|
+
logger.warn(ex)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def rescue_strategy_for_self
|
28
|
+
Dynflow::Action::Rescue::Skip
|
29
|
+
end
|
30
|
+
|
31
|
+
def connector_playbook_job?(job_invocation)
|
32
|
+
job_invocation&.remote_execution_feature_id == connector_feature_id
|
33
|
+
end
|
34
|
+
|
35
|
+
def connector_feature_id
|
36
|
+
self.class.connector_feature_id
|
37
|
+
end
|
38
|
+
|
39
|
+
def logger
|
40
|
+
action_logger
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "foreman_rh_cloud",
|
3
|
-
"version": "5.0.
|
3
|
+
"version": "5.0.38",
|
4
4
|
"description": "Inventory Upload =============",
|
5
5
|
"main": "index.js",
|
6
6
|
"scripts": {
|
@@ -22,14 +22,14 @@
|
|
22
22
|
"url": "http://projects.theforeman.org/projects/foreman_rh_cloud/issues"
|
23
23
|
},
|
24
24
|
"peerDependencies": {
|
25
|
-
"@theforeman/vendor": "
|
25
|
+
"@theforeman/vendor": ">=8.16.0"
|
26
26
|
},
|
27
27
|
"devDependencies": {
|
28
28
|
"@babel/core": "~7.7.0",
|
29
|
-
"@theforeman/builder": "
|
30
|
-
"@theforeman/stories": "
|
31
|
-
"@theforeman/test": "
|
32
|
-
"@theforeman/eslint-plugin-foreman": "
|
29
|
+
"@theforeman/builder": ">=8.16.0",
|
30
|
+
"@theforeman/stories": ">=8.16.0",
|
31
|
+
"@theforeman/test": ">=8.16.0",
|
32
|
+
"@theforeman/eslint-plugin-foreman": ">=8.16.0",
|
33
33
|
"babel-eslint": "~10.0.0",
|
34
34
|
"eslint": "~6.7.2",
|
35
35
|
"eslint-plugin-spellcheck": "~0.0.17",
|
@@ -0,0 +1,125 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'test_plugin_helper'
|
3
|
+
require 'foreman_tasks/test_helpers'
|
4
|
+
require "#{ForemanTasks::Engine.root}/test/support/dummy_dynflow_action"
|
5
|
+
|
6
|
+
class CloudConnectorAnnounceTaskTest < ActiveSupport::TestCase
|
7
|
+
include ForemanTasks::TestHelpers::WithInThreadExecutor
|
8
|
+
|
9
|
+
setup do
|
10
|
+
RemoteExecutionFeature.register(
|
11
|
+
:ansible_configure_cloud_connector,
|
12
|
+
N_('Configure Cloud Connector on given hosts'),
|
13
|
+
:description => N_('Configure Cloud Connector on given hosts'),
|
14
|
+
:proxy_selector_override => ::RemoteExecutionProxySelector::INTERNAL_PROXY
|
15
|
+
)
|
16
|
+
|
17
|
+
@job_invocation = generate_job_invocation(:ansible_configure_cloud_connector)
|
18
|
+
|
19
|
+
# reset connector feature ID cache
|
20
|
+
InsightsCloud::Async::CloudConnectorAnnounceTask.instance_variable_set(:@connector_feature_id, nil)
|
21
|
+
end
|
22
|
+
|
23
|
+
test 'It executes cloud presence announcer' do
|
24
|
+
ForemanRhCloud::CloudPresence.any_instance.expects(:announce_to_sources).times(Organization.unscoped.count)
|
25
|
+
|
26
|
+
ForemanTasks.sync_task(InsightsCloud::Async::CloudConnectorAnnounceTask, @job_invocation)
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def generate_job_invocation(feature_name)
|
32
|
+
job_template = FactoryBot.build(
|
33
|
+
:job_template,
|
34
|
+
:template => 'BLEH'
|
35
|
+
)
|
36
|
+
feature = RemoteExecutionFeature.feature!(feature_name).id
|
37
|
+
|
38
|
+
job_invocation = FactoryBot.create(
|
39
|
+
:job_invocation,
|
40
|
+
remote_execution_feature_id: feature,
|
41
|
+
task_id: FactoryBot.create(:dynflow_task).id
|
42
|
+
)
|
43
|
+
|
44
|
+
job_template.template_inputs << playbook_url_input = FactoryBot.build(:template_input,
|
45
|
+
:name => 'playbook_url',
|
46
|
+
:input_type => 'user',
|
47
|
+
:required => true)
|
48
|
+
job_template.template_inputs << report_url_input = FactoryBot.build(:template_input,
|
49
|
+
:name => 'report_url',
|
50
|
+
:input_type => 'user',
|
51
|
+
:required => true)
|
52
|
+
job_template.template_inputs << correlation_id_input = FactoryBot.build(:template_input,
|
53
|
+
:name => 'correlation_id',
|
54
|
+
:input_type => 'user',
|
55
|
+
:required => true)
|
56
|
+
job_template.template_inputs << report_interval_input = FactoryBot.build(:template_input,
|
57
|
+
:name => 'report_interval',
|
58
|
+
:input_type => 'user',
|
59
|
+
:required => true)
|
60
|
+
|
61
|
+
template_invocation = FactoryBot.build(:template_invocation,
|
62
|
+
:template => job_template,
|
63
|
+
:job_invocation => job_invocation
|
64
|
+
)
|
65
|
+
|
66
|
+
template_invocation.input_values << FactoryBot.create(
|
67
|
+
:template_invocation_input_value,
|
68
|
+
:template_invocation => template_invocation,
|
69
|
+
:template_input => playbook_url_input,
|
70
|
+
:value => 'http://example.com/TEST_PLAYBOOK'
|
71
|
+
)
|
72
|
+
template_invocation.input_values << FactoryBot.create(
|
73
|
+
:template_invocation_input_value,
|
74
|
+
:template_invocation => template_invocation,
|
75
|
+
:template_input => report_url_input,
|
76
|
+
:value => 'http://example.com/TEST_REPORT'
|
77
|
+
)
|
78
|
+
template_invocation.input_values << FactoryBot.create(
|
79
|
+
:template_invocation_input_value,
|
80
|
+
:template_invocation => template_invocation,
|
81
|
+
:template_input => correlation_id_input,
|
82
|
+
:value => 'TEST_CORRELATION'
|
83
|
+
)
|
84
|
+
template_invocation.input_values << FactoryBot.create(
|
85
|
+
:template_invocation_input_value,
|
86
|
+
:template_invocation => template_invocation,
|
87
|
+
:template_input => report_interval_input,
|
88
|
+
:value => '1'
|
89
|
+
)
|
90
|
+
|
91
|
+
@host1 = FactoryBot.create(:host, :with_insights_hits, name: 'host1')
|
92
|
+
@host1.insights.uuid = 'TEST_UUID1'
|
93
|
+
@host1.insights.save!
|
94
|
+
@host2 = FactoryBot.create(:host, :with_insights_hits, name: 'host2')
|
95
|
+
@host2.insights.uuid = 'TEST_UUID2'
|
96
|
+
@host2.insights.save!
|
97
|
+
|
98
|
+
targeting = FactoryBot.create(:targeting, hosts: [@host1, @host2])
|
99
|
+
job_invocation.targeting = targeting
|
100
|
+
job_invocation.save!
|
101
|
+
|
102
|
+
job_invocation.template_invocations << FactoryBot.create(
|
103
|
+
:template_invocation,
|
104
|
+
run_host_job_task: FactoryBot.create(:dynflow_task),
|
105
|
+
host_id: @host1.id
|
106
|
+
)
|
107
|
+
job_invocation.template_invocations << FactoryBot.create(
|
108
|
+
:template_invocation,
|
109
|
+
run_host_job_task: FactoryBot.create(:dynflow_task),
|
110
|
+
host_id: @host2.id
|
111
|
+
)
|
112
|
+
|
113
|
+
fake_output = (1..5).map do |i|
|
114
|
+
{ 'timestamp' => (Time.now - (5 - i)).to_f, 'output' => "#{i}\n" }
|
115
|
+
end
|
116
|
+
Support::DummyDynflowAction.any_instance.stubs(:live_output).returns(fake_output)
|
117
|
+
Support::DummyDynflowAction.any_instance.stubs(:exit_status).returns(0)
|
118
|
+
|
119
|
+
job_invocation
|
120
|
+
end
|
121
|
+
|
122
|
+
def read_jsonl(jsonl)
|
123
|
+
jsonl.lines.map { |l| JSON.parse(l) }
|
124
|
+
end
|
125
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_rh_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.38
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foreman Red Hat Cloud team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-06-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|
@@ -182,6 +182,7 @@ files:
|
|
182
182
|
- app/views/layouts/foreman_rh_cloud/application.html.erb
|
183
183
|
- config/Gemfile.lock.gh_test
|
184
184
|
- config/database.yml.example
|
185
|
+
- config/package-lock.json
|
185
186
|
- config/package-lock.json.gh_test
|
186
187
|
- config/package-lock.json.plugin
|
187
188
|
- config/rh_cert-api_chain.pem
|
@@ -221,6 +222,7 @@ files:
|
|
221
222
|
- lib/foreman_rh_cloud/engine.rb
|
222
223
|
- lib/foreman_rh_cloud/version.rb
|
223
224
|
- lib/insights_cloud.rb
|
225
|
+
- lib/insights_cloud/async/cloud_connector_announce_task.rb
|
224
226
|
- lib/insights_cloud/async/connector_playbook_execution_reporter_task.rb
|
225
227
|
- lib/insights_cloud/async/insights_client_status_aging.rb
|
226
228
|
- lib/insights_cloud/async/insights_full_sync.rb
|
@@ -255,6 +257,7 @@ files:
|
|
255
257
|
- test/controllers/uploads_settings_controller_test.rb
|
256
258
|
- test/factories/insights_factories.rb
|
257
259
|
- test/factories/inventory_upload_factories.rb
|
260
|
+
- test/jobs/cloud_connector_announce_task_test.rb
|
258
261
|
- test/jobs/connector_playbook_execution_reporter_task_test.rb
|
259
262
|
- test/jobs/insights_client_status_aging_test.rb
|
260
263
|
- test/jobs/insights_full_sync_test.rb
|
@@ -672,7 +675,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
672
675
|
- !ruby/object:Gem::Version
|
673
676
|
version: '0'
|
674
677
|
requirements: []
|
675
|
-
rubygems_version: 3.
|
678
|
+
rubygems_version: 3.2.22
|
676
679
|
signing_key:
|
677
680
|
specification_version: 4
|
678
681
|
summary: Summary of ForemanRhCloud.
|
@@ -688,33 +691,34 @@ test_files:
|
|
688
691
|
- test/controllers/uploads_settings_controller_test.rb
|
689
692
|
- test/factories/insights_factories.rb
|
690
693
|
- test/factories/inventory_upload_factories.rb
|
691
|
-
- test/jobs/
|
692
|
-
- test/jobs/inventory_scheduled_sync_test.rb
|
693
|
-
- test/jobs/upload_report_job_test.rb
|
694
|
+
- test/jobs/cloud_connector_announce_task_test.rb
|
694
695
|
- test/jobs/connector_playbook_execution_reporter_task_test.rb
|
696
|
+
- test/jobs/insights_client_status_aging_test.rb
|
695
697
|
- test/jobs/insights_full_sync_test.rb
|
696
698
|
- test/jobs/insights_resolutions_sync_test.rb
|
697
699
|
- test/jobs/insights_rules_sync_test.rb
|
698
700
|
- test/jobs/inventory_full_sync_test.rb
|
699
701
|
- test/jobs/inventory_hosts_sync_test.rb
|
702
|
+
- test/jobs/inventory_scheduled_sync_test.rb
|
700
703
|
- test/jobs/inventory_self_host_sync_test.rb
|
704
|
+
- test/jobs/upload_report_job_test.rb
|
701
705
|
- test/models/insights_client_report_status_test.rb
|
702
706
|
- test/test_plugin_helper.rb
|
703
707
|
- test/unit/archived_report_generator_test.rb
|
704
708
|
- test/unit/fact_helpers_test.rb
|
709
|
+
- test/unit/foreman_rh_cloud_self_host_test.rb
|
705
710
|
- test/unit/insights_facet_test.rb
|
706
711
|
- test/unit/metadata_generator_test.rb
|
712
|
+
- test/unit/playbook_progress_generator_test.rb
|
707
713
|
- test/unit/rh_cloud_http_proxy_test.rb
|
708
714
|
- test/unit/rh_cloud_permissions_test.rb
|
709
715
|
- test/unit/services/foreman_rh_cloud/branch_info_test.rb
|
710
|
-
- test/unit/services/foreman_rh_cloud/insights_status_cleaner_test.rb
|
711
716
|
- test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb
|
712
717
|
- test/unit/services/foreman_rh_cloud/cloud_status_service_test.rb
|
713
718
|
- test/unit/services/foreman_rh_cloud/hit_remediations_retriever_test.rb
|
719
|
+
- test/unit/services/foreman_rh_cloud/insights_status_cleaner_test.rb
|
714
720
|
- test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb
|
715
721
|
- test/unit/services/foreman_rh_cloud/url_remediations_retriever_test.rb
|
716
722
|
- test/unit/shell_process_job_test.rb
|
717
723
|
- test/unit/slice_generator_test.rb
|
718
724
|
- test/unit/tags_generator_test.rb
|
719
|
-
- test/unit/foreman_rh_cloud_self_host_test.rb
|
720
|
-
- test/unit/playbook_progress_generator_test.rb
|