foreman_rh_cloud 3.0.21 → 3.0.21.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +7 -17
- data/lib/foreman_rh_cloud/engine.rb +10 -11
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/package.json +1 -1
- metadata +3 -7
- data/app/models/insights_client_report_status.rb +0 -58
- data/app/subscribers/foreman_rh_cloud/insights_subscriber.rb +0 -9
- data/test/models/insights_client_report_status_test.rb +0 -77
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d87599d8ef67eeeaa3e17e720dc990b58d4085caf7fb6491dab093c54770c8fd
|
4
|
+
data.tar.gz: 04b52a7412dddf8e6829d61555ec9315c7f3856fde32e976eb8c50638082a3bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ca381e6bcbf74d21a23ae825ebb6556be1afbe98c193fb33e58ef7fee6027142a809ed79b8cbcb3c8dce95200b0bd4528d497597a1f0411f703172ce1f9c123
|
7
|
+
data.tar.gz: 945faf0852d9ebce259e4da1bcebd079ef5a4fad87f503fc9ee694f4eae7e3ab36a7dc2390d54879a7da57d176aa22d8030a168d2715fe1f54a521b2258fbb37
|
@@ -10,28 +10,27 @@ module InsightsCloud::Api
|
|
10
10
|
|
11
11
|
skip_after_action :log_response_body, :only => [:forward_request]
|
12
12
|
skip_before_action :check_media_type, :only => [:forward_request]
|
13
|
-
after_action :update_host_insights_status, only: [:forward_request]
|
14
13
|
|
15
14
|
# The method that "proxies" requests over to Cloud
|
16
15
|
def forward_request
|
17
16
|
certs = candlepin_id_cert @organization
|
18
|
-
|
17
|
+
cloud_response = ::ForemanRhCloud::CloudRequestForwarder.new.forward_request(request, controller_name, @branch_id, certs)
|
19
18
|
|
20
|
-
if
|
19
|
+
if cloud_response.code == 401
|
21
20
|
return render json: {
|
22
21
|
:message => 'Authentication to the Insights Service failed.',
|
23
22
|
:headers => {},
|
24
23
|
}, status: :bad_gateway
|
25
24
|
end
|
26
25
|
|
27
|
-
if
|
28
|
-
return send_data
|
26
|
+
if cloud_response.headers[:content_disposition]
|
27
|
+
return send_data cloud_response, disposition: cloud_response.headers[:content_disposition], type: cloud_response.headers[:content_type]
|
29
28
|
end
|
30
29
|
|
31
|
-
assign_header(response,
|
32
|
-
assign_header(response,
|
30
|
+
assign_header(response, cloud_response, :x_resource_count, true)
|
31
|
+
assign_header(response, cloud_response, :x_rh_insights_request_id, false)
|
33
32
|
|
34
|
-
render json:
|
33
|
+
render json: cloud_response, status: cloud_response.code
|
35
34
|
end
|
36
35
|
|
37
36
|
def branch_info
|
@@ -70,14 +69,5 @@ module InsightsCloud::Api
|
|
70
69
|
@branch_id = cp_owner_id(@organization)
|
71
70
|
return render_message "Branch ID not found for organization #{@organization.title}", :status => 400 unless @branch_id
|
72
71
|
end
|
73
|
-
|
74
|
-
def update_host_insights_status
|
75
|
-
return unless request.path == '/redhat_access/r/insights/platform/ingress/v1/upload' ||
|
76
|
-
request.path.include?('/redhat_access/r/insights/uploads/')
|
77
|
-
|
78
|
-
data = @cloud_response.code.to_s.start_with?('2')
|
79
|
-
host_status = @host.get_status(InsightsClientReportStatus)
|
80
|
-
host_status.update(reported_at: Time.now.utc, status: host_status.to_status(data: data))
|
81
|
-
end
|
82
72
|
end
|
83
73
|
end
|
@@ -78,10 +78,7 @@ module ForemanRhCloud
|
|
78
78
|
|
79
79
|
register_global_js_file 'global'
|
80
80
|
|
81
|
-
register_custom_status
|
82
|
-
register_custom_status InsightsClientReportStatus
|
83
|
-
|
84
|
-
subscribe 'host_created.event.foreman', ForemanRhCloud::InsightsSubscriber
|
81
|
+
register_custom_status(InventorySync::InventoryStatus)
|
85
82
|
|
86
83
|
extend_page 'hosts/show' do |context|
|
87
84
|
context.add_pagelet :main_tabs,
|
@@ -133,13 +130,15 @@ module ForemanRhCloud
|
|
133
130
|
)
|
134
131
|
# skip object creation when admin user is not present, for example in test DB
|
135
132
|
if User.unscoped.find_by_login(User::ANONYMOUS_ADMIN).present?
|
136
|
-
|
137
|
-
ForemanTasks::
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
133
|
+
::ForemanTasks.dynflow.config.on_init(false) do |world|
|
134
|
+
unless ForemanTasks::RecurringLogic.joins(:tasks).merge(
|
135
|
+
ForemanTasks::Task.where(label: 'InventorySync::Async::InventoryScheduledSync')
|
136
|
+
).exists?
|
137
|
+
User.as_anonymous_admin do
|
138
|
+
recurring_logic = ForemanTasks::RecurringLogic.new_from_cronline("0 0 * * *")
|
139
|
+
recurring_logic.save!
|
140
|
+
recurring_logic.start(InventorySync::Async::InventoryScheduledSync)
|
141
|
+
end
|
143
142
|
end
|
144
143
|
end
|
145
144
|
end
|
data/package.json
CHANGED
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: 3.0.21
|
4
|
+
version: 3.0.21.1
|
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: 2021-
|
11
|
+
date: 2021-06-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|
@@ -160,7 +160,6 @@ files:
|
|
160
160
|
- app/helpers/foreman_inventory_upload_helper.rb
|
161
161
|
- app/helpers/foreman_inventory_upload_host_helper.rb
|
162
162
|
- app/models/concerns/rh_cloud_host.rb
|
163
|
-
- app/models/insights_client_report_status.rb
|
164
163
|
- app/models/insights_facet.rb
|
165
164
|
- app/models/insights_hit.rb
|
166
165
|
- app/models/insights_resolution.rb
|
@@ -175,7 +174,6 @@ files:
|
|
175
174
|
- app/services/foreman_rh_cloud/cloud_request_forwarder.rb
|
176
175
|
- app/services/foreman_rh_cloud/remediations_retriever.rb
|
177
176
|
- app/services/foreman_rh_cloud/template_renderer_helper.rb
|
178
|
-
- app/subscribers/foreman_rh_cloud/insights_subscriber.rb
|
179
177
|
- app/views/hosts/_insights_tab.html.erb
|
180
178
|
- app/views/job_templates/rh_cloud_remediations.erb
|
181
179
|
- app/views/layouts/foreman_rh_cloud/application.html.erb
|
@@ -247,7 +245,6 @@ files:
|
|
247
245
|
- test/jobs/insights_rules_sync_test.rb
|
248
246
|
- test/jobs/inventory_full_sync_test.rb
|
249
247
|
- test/jobs/upload_report_job_test.rb
|
250
|
-
- test/models/insights_client_report_status_test.rb
|
251
248
|
- test/test_plugin_helper.rb
|
252
249
|
- test/unit/archived_report_generator_test.rb
|
253
250
|
- test/unit/fact_helpers_test.rb
|
@@ -651,7 +648,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
651
648
|
- !ruby/object:Gem::Version
|
652
649
|
version: '0'
|
653
650
|
requirements: []
|
654
|
-
rubygems_version: 3.2.
|
651
|
+
rubygems_version: 3.2.3
|
655
652
|
signing_key:
|
656
653
|
specification_version: 4
|
657
654
|
summary: Summary of ForemanRhCloud.
|
@@ -669,7 +666,6 @@ test_files:
|
|
669
666
|
- test/jobs/insights_rules_sync_test.rb
|
670
667
|
- test/jobs/inventory_full_sync_test.rb
|
671
668
|
- test/jobs/upload_report_job_test.rb
|
672
|
-
- test/models/insights_client_report_status_test.rb
|
673
669
|
- test/test_plugin_helper.rb
|
674
670
|
- test/unit/archived_report_generator_test.rb
|
675
671
|
- test/unit/fact_helpers_test.rb
|
@@ -1,58 +0,0 @@
|
|
1
|
-
class InsightsClientReportStatus < HostStatus::Status
|
2
|
-
REPORT_INTERVAL = 48.hours
|
3
|
-
|
4
|
-
REPORTING = 0 # host_registration_insights = true & getting data
|
5
|
-
NO_REPORT = 1 # host_registration_insights = true & not getting data
|
6
|
-
NOT_MANAGED = 2 # host_registration_insights = false
|
7
|
-
NOT_MANAGED_WITH_DATA = 3 # host_registration_insights = false & getting data
|
8
|
-
|
9
|
-
def self.status_name
|
10
|
-
N_('Insights')
|
11
|
-
end
|
12
|
-
|
13
|
-
def to_label(_options = {})
|
14
|
-
case status
|
15
|
-
when REPORTING
|
16
|
-
N_('Reporting')
|
17
|
-
when NO_REPORT
|
18
|
-
N_('Not reporting')
|
19
|
-
when NOT_MANAGED
|
20
|
-
N_('Not reporting (not set by registration)')
|
21
|
-
when NOT_MANAGED_WITH_DATA
|
22
|
-
N_('Reporting (not set by registration)')
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def to_global(_options = {})
|
27
|
-
case status
|
28
|
-
when REPORTING
|
29
|
-
::HostStatus::Global::OK
|
30
|
-
when NO_REPORT
|
31
|
-
::HostStatus::Global::ERROR
|
32
|
-
when NOT_MANAGED
|
33
|
-
::HostStatus::Global::OK
|
34
|
-
when NOT_MANAGED_WITH_DATA
|
35
|
-
::HostStatus::Global::WARN
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
def to_status(data: false)
|
40
|
-
if insights_param
|
41
|
-
return REPORTING if data
|
42
|
-
return in_interval? ? REPORTING : NO_REPORT
|
43
|
-
end
|
44
|
-
|
45
|
-
data ? NOT_MANAGED_WITH_DATA : NOT_MANAGED
|
46
|
-
end
|
47
|
-
|
48
|
-
private
|
49
|
-
|
50
|
-
def in_interval?
|
51
|
-
return false unless reported_at
|
52
|
-
(Time.now.utc - reported_at).to_i < REPORT_INTERVAL.to_i
|
53
|
-
end
|
54
|
-
|
55
|
-
def insights_param
|
56
|
-
host.host_params_hash.dig('host_registration_insights', :value)
|
57
|
-
end
|
58
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'test_plugin_helper'
|
2
|
-
|
3
|
-
class InsightsClientReportStatusTest < ActiveSupport::TestCase
|
4
|
-
describe 'to_status' do
|
5
|
-
let(:host) { FactoryBot.create(:host, :managed) }
|
6
|
-
|
7
|
-
setup do
|
8
|
-
CommonParameter.where(name: 'host_registration_insights').destroy_all
|
9
|
-
end
|
10
|
-
|
11
|
-
test 'host_registration_insights = true & is getting data' do
|
12
|
-
FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true)
|
13
|
-
host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
|
14
|
-
|
15
|
-
assert_equal 0, host_status.to_status(data: true)
|
16
|
-
end
|
17
|
-
|
18
|
-
test 'host_registration_insights = true & no data in less than 48 hours' do
|
19
|
-
FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true)
|
20
|
-
host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
|
21
|
-
host_status.update(reported_at: 1.day.ago)
|
22
|
-
assert_equal 0, host_status.to_status
|
23
|
-
end
|
24
|
-
|
25
|
-
test 'host_registration_insights = true & no data in more than 48 hours' do
|
26
|
-
FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true)
|
27
|
-
host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
|
28
|
-
host_status.update(reported_at: 3.days.ago)
|
29
|
-
assert_equal 1, host_status.to_status
|
30
|
-
end
|
31
|
-
|
32
|
-
test 'host_registration_insights = false & no data' do
|
33
|
-
FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: false)
|
34
|
-
host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
|
35
|
-
assert_equal 2, host_status.to_status
|
36
|
-
end
|
37
|
-
|
38
|
-
test 'host_registration_insights = false & getting data' do
|
39
|
-
FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: false)
|
40
|
-
host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
|
41
|
-
assert_equal 3, host_status.to_status(data: true)
|
42
|
-
end
|
43
|
-
|
44
|
-
test 'host_registration_insights = nil & is getting data' do
|
45
|
-
host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
|
46
|
-
assert_equal 3, host_status.to_status(data: true)
|
47
|
-
end
|
48
|
-
|
49
|
-
test 'host_registration_insights = nil & no data in less than 48 hours' do
|
50
|
-
host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
|
51
|
-
host_status.update(reported_at: 1.day.ago)
|
52
|
-
assert_equal 2, host_status.to_status
|
53
|
-
end
|
54
|
-
|
55
|
-
test 'host_registration_insights = nil & no data in more than 48 hours' do
|
56
|
-
host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
|
57
|
-
host_status.update(reported_at: 3.days.ago)
|
58
|
-
assert_equal 2, host_status.to_status
|
59
|
-
end
|
60
|
-
|
61
|
-
test 'override param on host level from `false` to `true`' do
|
62
|
-
FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: false)
|
63
|
-
FactoryBot.create(:host_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true, host: host)
|
64
|
-
|
65
|
-
host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
|
66
|
-
assert_equal 0, host_status.to_status(data: true)
|
67
|
-
end
|
68
|
-
|
69
|
-
test 'override param on host level from `true` to `false`' do
|
70
|
-
FactoryBot.create(:common_parameter, name: 'host_registration_insights', key_type: 'boolean', value: true)
|
71
|
-
FactoryBot.create(:host_parameter, name: 'host_registration_insights', key_type: 'boolean', value: false, host: host)
|
72
|
-
|
73
|
-
host_status = Host.find_by_name(host.name).reload.get_status(InsightsClientReportStatus)
|
74
|
-
assert_equal 2, host_status.to_status
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|