foreman_rh_cloud 4.0.24 → 4.0.26
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/api/v2/rh_cloud/inventory_controller.rb +4 -1
- data/app/controllers/foreman_inventory_upload/cloud_status_controller.rb +26 -0
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +23 -7
- data/app/controllers/insights_cloud/hits_controller.rb +0 -1
- data/app/models/insights_client_report_status.rb +8 -23
- data/app/services/foreman_rh_cloud/cloud_auth.rb +4 -0
- data/app/services/foreman_rh_cloud/cloud_ping_service.rb +83 -0
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +15 -3
- data/app/services/foreman_rh_cloud/insights_status_cleaner.rb +17 -0
- data/app/services/foreman_rh_cloud/remediations_retriever.rb +5 -0
- data/config/Gemfile.lock.gh_test +74 -84
- data/config/rh_cert-api_chain.pem +74 -0
- data/config/routes.rb +3 -1
- data/db/migrate/20210720000001_remove_old_insights_statuses.foreman_rh_cloud.rb +6 -0
- data/lib/foreman_inventory_upload/generators/queries.rb +0 -16
- data/lib/foreman_inventory_upload/generators/tags.rb +3 -1
- data/lib/foreman_rh_cloud/engine.rb +2 -3
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +4 -0
- data/lib/insights_cloud/async/insights_client_status_aging.rb +13 -3
- data/lib/insights_cloud/async/insights_full_sync.rb +9 -0
- data/lib/insights_cloud/async/insights_generate_notifications.rb +4 -0
- data/lib/insights_cloud/async/insights_resolutions_sync.rb +16 -2
- data/lib/insights_cloud/async/insights_rules_sync.rb +15 -2
- data/lib/insights_cloud.rb +4 -0
- data/lib/inventory_sync/async/inventory_full_sync.rb +9 -0
- data/lib/inventory_sync/async/inventory_hosts_sync.rb +9 -0
- data/lib/inventory_sync/async/inventory_scheduled_sync.rb +4 -0
- data/lib/inventory_sync/async/inventory_self_host_sync.rb +13 -0
- data/lib/inventory_sync/async/query_inventory_job.rb +4 -0
- data/lib/tasks/insights.rake +15 -0
- data/lib/tasks/rh_cloud_inventory.rake +2 -9
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +20 -39
- data/test/controllers/inventory_upload/cloud_status_controller_test.rb +44 -0
- data/test/jobs/insights_client_status_aging_test.rb +7 -7
- data/test/jobs/insights_full_sync_test.rb +1 -0
- data/test/jobs/insights_resolutions_sync_test.rb +11 -1
- data/test/jobs/insights_rules_sync_test.rb +1 -0
- data/test/jobs/inventory_full_sync_test.rb +10 -0
- data/test/jobs/inventory_hosts_sync_test.rb +1 -0
- data/test/jobs/inventory_self_host_sync_test.rb +1 -0
- data/test/models/insights_client_report_status_test.rb +70 -72
- data/test/test_plugin_helper.rb +53 -0
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +29 -34
- data/test/unit/services/foreman_rh_cloud/cloud_status_service_test.rb +66 -0
- data/test/unit/services/foreman_rh_cloud/insights_status_cleaner_test.rb +31 -0
- data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +1 -0
- data/test/unit/tags_generator_test.rb +41 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/EmptyState.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/EmptyState/__tests__/__snapshots__/EmptyState.test.js.snap +1 -2
- data/webpack/ForemanInventoryUpload/Components/FileDownload/FileDownload.js +3 -1
- data/webpack/ForemanInventoryUpload/Components/FileDownload/__tests__/__snapshots__/FileDownload.test.js.snap +2 -1
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilter.js +1 -2
- data/webpack/ForemanInventoryUpload/Components/InventoryFilter/InventoryFilterConstants.js +3 -1
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.scss +0 -4
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js +12 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +10 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.js +144 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/CloudPingModal/index.scss +5 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Toast.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +4 -3
- data/webpack/ForemanInventoryUpload/ForemanInventoryConstants.js +2 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +3 -1
- data/webpack/InsightsCloudSync/Components/InsightsHeader/InsightsHeader.scss +5 -1
- data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +6 -6
- data/webpack/InsightsCloudSync/Components/InsightsSettings/InsightsSettings.js +9 -5
- data/webpack/InsightsCloudSync/Components/InsightsSettings/__tests__/__snapshots__/InsightsSettings.test.js.snap +6 -6
- data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +1 -14
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +4 -22
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +25 -4
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableSelectors.js +0 -3
- data/webpack/InsightsCloudSync/Components/InsightsTable/Pagination.js +51 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/SelectAllAlert.js +1 -1
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +3 -68
- data/webpack/InsightsCloudSync/Components/InsightsTable/table.scss +10 -0
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.js +11 -10
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.scss +14 -0
- data/webpack/InsightsCloudSync/Components/RemediationModal/index.js +0 -2
- data/webpack/InsightsCloudSync/Components/ToolbarDropdown.js +32 -0
- data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +5 -5
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +19 -13
- data/webpack/InsightsCloudSync/InsightsCloudSync.scss +82 -2
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +16 -6
- data/webpack/InsightsHostDetailsTab/InsightsTab.js +3 -2
- data/webpack/InsightsHostDetailsTab/InsightsTab.scss +4 -4
- data/webpack/InsightsHostDetailsTab/components/ListItem/ListItem.js +9 -7
- data/webpack/common/Switcher/HelpLabel.js +1 -1
- data/webpack/common/Switcher/SwitcherPF4.js +1 -1
- data/webpack/common/Switcher/SwitcherPF4.scss +6 -7
- data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +1 -1
- data/webpack/common/Switcher/__tests__/__snapshots__/SwitcherPF4.test.js.snap +1 -1
- metadata +18 -25
- data/app/subscribers/foreman_rh_cloud/insights_subscriber.rb +0 -9
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.fixtures.js +0 -1
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/InsightsSyncSwitcher.js +0 -45
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/InsightsSyncSwitcher.test.js +0 -17
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/__tests__/__snapshots__/InsightsSyncSwitcher.test.js.snap +0 -38
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/index.js +0 -1
- data/webpack/InsightsCloudSync/Components/InsightsSyncSwitcher/insightsSyncSwitcher.scss +0 -3
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediateButton.js +0 -59
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 713d1737fd81e7a54efa8a300fe4c0765c1d2a31b796218bcc1f447b473921af
|
|
4
|
+
data.tar.gz: a47efbe51980f47c71e57af619f73a08d214f7af3bb84632946189a1aabe81f3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c7419f0e5583f02038cf784e38d67f15dd0dfa3a392a72cd19000c0f51f41fc97a29ed2e9387bfee4e1fe7a91addb563db53167c98343b640f52e3b17a729387
|
|
7
|
+
data.tar.gz: 2eb4fea115c546084e2365807e87933e60a102f1ec7455cfc5a368a1ae5a20587bf7c12206e40816a2893c19d02a035a2cee3c2262982a53f88542599bda629d
|
|
@@ -7,6 +7,7 @@ module Api
|
|
|
7
7
|
include InventoryUpload::TaskActions
|
|
8
8
|
|
|
9
9
|
api :GET, "/organizations/:organization_id/rh_cloud/report", N_("Download latest report")
|
|
10
|
+
param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request")
|
|
10
11
|
def download_file
|
|
11
12
|
filename, file = report_file(params[:organization_id])
|
|
12
13
|
|
|
@@ -16,6 +17,7 @@ module Api
|
|
|
16
17
|
end
|
|
17
18
|
|
|
18
19
|
api :POST, "/organizations/:organization_id/rh_cloud/report", N_("Start report generation")
|
|
20
|
+
param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request")
|
|
19
21
|
def generate_report
|
|
20
22
|
organization_id = params[:organization_id]
|
|
21
23
|
|
|
@@ -27,6 +29,7 @@ module Api
|
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
api :POST, "/organizations/:organization_id/rh_cloud/inventory_sync", N_("Start inventory synchronization")
|
|
32
|
+
param :organization_id, Integer, required: true, desc: N_("Set the current organization context for the request")
|
|
30
33
|
def sync_inventory_status
|
|
31
34
|
selected_org = Organization.find(params[:organization_id])
|
|
32
35
|
|
|
@@ -39,7 +42,7 @@ module Api
|
|
|
39
42
|
render json: { message: error.message }, status: :bad_request
|
|
40
43
|
end
|
|
41
44
|
|
|
42
|
-
api :POST, "rh_cloud/enable_connector", N_("Enable cloud connector")
|
|
45
|
+
api :POST, "/rh_cloud/enable_connector", N_("Enable cloud connector")
|
|
43
46
|
def enable_cloud_connector
|
|
44
47
|
cloud_connector = ForemanRhCloud::CloudConnector.new
|
|
45
48
|
render json: cloud_connector.install.to_json
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module ForemanInventoryUpload
|
|
2
|
+
class CloudStatusController < ::ApplicationController
|
|
3
|
+
def index
|
|
4
|
+
organizations = User.current.my_organizations
|
|
5
|
+
|
|
6
|
+
ping_service = ForemanRhCloud::CloudPingService.new(organizations, logger)
|
|
7
|
+
ping_result = ping_service.ping
|
|
8
|
+
ping_result[:cert_auth] = ping_result[:cert_auth].map do |org, status_hash|
|
|
9
|
+
status_hash.merge(
|
|
10
|
+
{
|
|
11
|
+
org_id: org.id,
|
|
12
|
+
org_name: org.name,
|
|
13
|
+
}
|
|
14
|
+
)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
render json: {
|
|
18
|
+
ping: ping_result,
|
|
19
|
+
}, status: :ok
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def logger
|
|
23
|
+
Foreman::Logging.logger('app')
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -25,6 +25,14 @@ module InsightsCloud::Api
|
|
|
25
25
|
}, status: :bad_gateway
|
|
26
26
|
end
|
|
27
27
|
|
|
28
|
+
if @cloud_response.code >= 300
|
|
29
|
+
return render json: {
|
|
30
|
+
:message => 'Cloud request failed',
|
|
31
|
+
:headers => {},
|
|
32
|
+
:response => @cloud_response,
|
|
33
|
+
}, status: @cloud_response.code
|
|
34
|
+
end
|
|
35
|
+
|
|
28
36
|
if @cloud_response.headers[:content_disposition]
|
|
29
37
|
return send_data @cloud_response, disposition: @cloud_response.headers[:content_disposition], type: @cloud_response.headers[:content_type]
|
|
30
38
|
end
|
|
@@ -49,13 +57,19 @@ module InsightsCloud::Api
|
|
|
49
57
|
private
|
|
50
58
|
|
|
51
59
|
def ensure_telemetry_enabled_for_consumer
|
|
52
|
-
|
|
60
|
+
unless (config = telemetry_config(@host))
|
|
61
|
+
logger.debug("Rejected telemetry forwarding for host #{@host.name}, insights param is set to: #{config}")
|
|
62
|
+
render_message 'Telemetry is not enabled for this host', :status => 403
|
|
63
|
+
end
|
|
64
|
+
config
|
|
53
65
|
end
|
|
54
66
|
|
|
55
|
-
def telemetry_config
|
|
56
|
-
|
|
57
|
-
|
|
67
|
+
def telemetry_config(host)
|
|
68
|
+
param_value = nil
|
|
69
|
+
User.as_anonymous_admin do
|
|
70
|
+
param_value = host.host_param(InsightsCloud.enable_client_param)
|
|
58
71
|
end
|
|
72
|
+
param_value
|
|
59
73
|
end
|
|
60
74
|
|
|
61
75
|
def cert_uuid
|
|
@@ -76,9 +90,11 @@ module InsightsCloud::Api
|
|
|
76
90
|
return unless request.path == '/redhat_access/r/insights/platform/ingress/v1/upload' ||
|
|
77
91
|
request.path.include?('/redhat_access/r/insights/uploads/')
|
|
78
92
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
93
|
+
return unless @cloud_response.code.to_s.start_with?('2')
|
|
94
|
+
|
|
95
|
+
# create insights status if it wasn't there in the first place and refresh its reporting date
|
|
96
|
+
@host.get_status(InsightsClientReportStatus).refresh!
|
|
97
|
+
@host.refresh_global_status!
|
|
82
98
|
end
|
|
83
99
|
end
|
|
84
100
|
end
|
|
@@ -9,7 +9,6 @@ module InsightsCloud
|
|
|
9
9
|
hasToken: !Setting[:rh_cloud_token].empty?,
|
|
10
10
|
hits: hits.map { |hit| hit.attributes.merge(hostname: hit.host&.name, has_playbook: hit.has_playbook?) },
|
|
11
11
|
itemCount: hits.count,
|
|
12
|
-
isExperimentalMode: Setting[:lab_features],
|
|
13
12
|
}, status: :ok
|
|
14
13
|
end
|
|
15
14
|
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
class InsightsClientReportStatus < HostStatus::Status
|
|
2
2
|
REPORT_INTERVAL = 48.hours
|
|
3
3
|
|
|
4
|
-
REPORTING = 0
|
|
5
|
-
NO_REPORT = 1
|
|
6
|
-
NOT_MANAGED = 2 # host_registration_insights = false
|
|
7
|
-
NOT_MANAGED_WITH_DATA = 3 # host_registration_insights = false & getting data
|
|
4
|
+
REPORTING = 0
|
|
5
|
+
NO_REPORT = 1
|
|
8
6
|
|
|
9
7
|
scope :stale, -> { where.not(reported_at: (Time.now - REPORT_INTERVAL)..Time.now) }
|
|
10
8
|
scope :reporting, -> { where(status: REPORTING) }
|
|
11
|
-
scope :not_managed_with_data, -> { where(status: NOT_MANAGED_WITH_DATA) }
|
|
12
9
|
|
|
13
10
|
def self.status_name
|
|
14
11
|
N_('Insights')
|
|
@@ -20,10 +17,6 @@ class InsightsClientReportStatus < HostStatus::Status
|
|
|
20
17
|
N_('Reporting')
|
|
21
18
|
when NO_REPORT
|
|
22
19
|
N_('Not reporting')
|
|
23
|
-
when NOT_MANAGED
|
|
24
|
-
N_('Not reporting (not set by registration)')
|
|
25
|
-
when NOT_MANAGED_WITH_DATA
|
|
26
|
-
N_('Reporting (not set by registration)')
|
|
27
20
|
end
|
|
28
21
|
end
|
|
29
22
|
|
|
@@ -33,20 +26,16 @@ class InsightsClientReportStatus < HostStatus::Status
|
|
|
33
26
|
::HostStatus::Global::OK
|
|
34
27
|
when NO_REPORT
|
|
35
28
|
::HostStatus::Global::ERROR
|
|
36
|
-
when NOT_MANAGED
|
|
37
|
-
::HostStatus::Global::OK
|
|
38
|
-
when NOT_MANAGED_WITH_DATA
|
|
39
|
-
::HostStatus::Global::WARN
|
|
40
29
|
end
|
|
41
30
|
end
|
|
42
31
|
|
|
43
|
-
def to_status
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return in_interval? ? REPORTING : NO_REPORT
|
|
47
|
-
end
|
|
32
|
+
def to_status
|
|
33
|
+
in_interval? ? REPORTING : NO_REPORT
|
|
34
|
+
end
|
|
48
35
|
|
|
49
|
-
|
|
36
|
+
# prevent creation of the status on global refresh, but show it if the record already exists
|
|
37
|
+
def relevant?(_options = {})
|
|
38
|
+
persisted?
|
|
50
39
|
end
|
|
51
40
|
|
|
52
41
|
private
|
|
@@ -55,8 +44,4 @@ class InsightsClientReportStatus < HostStatus::Status
|
|
|
55
44
|
return false unless reported_at
|
|
56
45
|
(Time.now.utc - reported_at).to_i < REPORT_INTERVAL.to_i
|
|
57
46
|
end
|
|
58
|
-
|
|
59
|
-
def insights_param
|
|
60
|
-
host.host_params_hash.dig('host_registration_insights', :value)
|
|
61
|
-
end
|
|
62
47
|
end
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
require 'rest-client'
|
|
2
|
+
|
|
3
|
+
module ForemanRhCloud
|
|
4
|
+
class CloudPingService
|
|
5
|
+
class TokenPing
|
|
6
|
+
include ForemanRhCloud::CloudAuth
|
|
7
|
+
|
|
8
|
+
attr_accessor :logger
|
|
9
|
+
|
|
10
|
+
def initialize(logger)
|
|
11
|
+
@logger = logger
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def ping
|
|
15
|
+
execute_cloud_request(
|
|
16
|
+
method: :get,
|
|
17
|
+
url: ForemanRhCloud.base_url + "/api/inventory/v1/hosts?per_page=1",
|
|
18
|
+
headers: {
|
|
19
|
+
content_type: :json,
|
|
20
|
+
}
|
|
21
|
+
)
|
|
22
|
+
rescue StandardError => ex
|
|
23
|
+
ex
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class CertPing
|
|
28
|
+
include ForemanRhCloud::CloudRequest
|
|
29
|
+
include InsightsCloud::CandlepinCache
|
|
30
|
+
|
|
31
|
+
attr_accessor :logger
|
|
32
|
+
|
|
33
|
+
def initialize(org, logger)
|
|
34
|
+
@org = org
|
|
35
|
+
@logger = logger
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def ping
|
|
39
|
+
certs = candlepin_id_cert(@org)
|
|
40
|
+
return StandardError.new('certificate missing') unless certs
|
|
41
|
+
|
|
42
|
+
execute_cloud_request(
|
|
43
|
+
method: :get,
|
|
44
|
+
url: ForemanRhCloud.cert_base_url + "/api/apicast-tests/ping",
|
|
45
|
+
headers: {
|
|
46
|
+
content_type: :json,
|
|
47
|
+
},
|
|
48
|
+
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
|
49
|
+
ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key])
|
|
50
|
+
)
|
|
51
|
+
rescue StandardError => ex
|
|
52
|
+
ex
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
def initialize(organizations, logger)
|
|
57
|
+
@organizations = organizations
|
|
58
|
+
@logger = logger
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def ping
|
|
62
|
+
token_response = TokenPing.new(@logger).ping
|
|
63
|
+
{
|
|
64
|
+
token_auth: {
|
|
65
|
+
success: token_response.is_a?(RestClient::Response),
|
|
66
|
+
error: (token_response.is_a?(Exception) ? token_response.inspect : nil),
|
|
67
|
+
},
|
|
68
|
+
cert_auth: Hash[
|
|
69
|
+
@organizations.map do |org|
|
|
70
|
+
cert_response = CertPing.new(org, @logger).ping
|
|
71
|
+
[
|
|
72
|
+
org,
|
|
73
|
+
{
|
|
74
|
+
success: cert_response.is_a?(RestClient::Response),
|
|
75
|
+
error: (cert_response.is_a?(Exception) ? cert_response.inspect : nil),
|
|
76
|
+
},
|
|
77
|
+
]
|
|
78
|
+
end
|
|
79
|
+
],
|
|
80
|
+
}
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
@@ -17,6 +17,8 @@ module ForemanRhCloud
|
|
|
17
17
|
logger.debug("Sending request to: #{request_opts[:url]}")
|
|
18
18
|
|
|
19
19
|
execute_cloud_request(request_opts)
|
|
20
|
+
rescue RestClient::Exception => error_response
|
|
21
|
+
error_response.response
|
|
20
22
|
end
|
|
21
23
|
|
|
22
24
|
def prepare_request_opts(original_request, forward_payload, forward_params, certs)
|
|
@@ -62,12 +64,18 @@ module ForemanRhCloud
|
|
|
62
64
|
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
|
63
65
|
ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
|
|
64
66
|
}
|
|
67
|
+
when connection_test_request?
|
|
68
|
+
{
|
|
69
|
+
url: ForemanRhCloud.cert_base_url + '/api/apicast-tests/ping',
|
|
70
|
+
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
|
71
|
+
ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
|
|
72
|
+
}
|
|
65
73
|
else # Legacy insights API
|
|
66
74
|
{
|
|
67
75
|
url: ForemanRhCloud.legacy_insights_url + request_path.sub('/redhat_access/r/insights', '/r/insights'),
|
|
68
76
|
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
|
69
77
|
ssl_client_key: OpenSSL::PKey::RSA.new(certs[:key]),
|
|
70
|
-
ssl_ca_file:
|
|
78
|
+
ssl_ca_file: ForemanRhCloud.legacy_insights_ca,
|
|
71
79
|
}
|
|
72
80
|
end
|
|
73
81
|
end
|
|
@@ -76,6 +84,10 @@ module ForemanRhCloud
|
|
|
76
84
|
->(request_path) { request_path.include? '/platform' }
|
|
77
85
|
end
|
|
78
86
|
|
|
87
|
+
def connection_test_request?
|
|
88
|
+
->(request_path) { request_path =~ /redhat_access\/r\/insights\/?$/ }
|
|
89
|
+
end
|
|
90
|
+
|
|
79
91
|
def prepare_forward_cloud_url(base_url, request_path)
|
|
80
92
|
cloud_path = request_path.sub('/redhat_access/r/insights/platform/', '')
|
|
81
93
|
.sub('/redhat_access/r/insights/', '')
|
|
@@ -84,11 +96,11 @@ module ForemanRhCloud
|
|
|
84
96
|
end
|
|
85
97
|
|
|
86
98
|
def core_app_name
|
|
87
|
-
|
|
99
|
+
BranchInfo.new.core_app_name
|
|
88
100
|
end
|
|
89
101
|
|
|
90
102
|
def core_app_version
|
|
91
|
-
|
|
103
|
+
BranchInfo.new.core_app_version
|
|
92
104
|
end
|
|
93
105
|
|
|
94
106
|
def http_user_agent(original_request)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module ForemanRhCloud
|
|
2
|
+
class InsightsStatusCleaner
|
|
3
|
+
def clean(host_search)
|
|
4
|
+
host_ids = Host.search_for(host_search).pluck(:id)
|
|
5
|
+
|
|
6
|
+
# delete all insights status records for the hosts
|
|
7
|
+
deleted_count = InsightsClientReportStatus.where(host_id: host_ids).delete_all
|
|
8
|
+
|
|
9
|
+
# refresh global status
|
|
10
|
+
Host.where(id: host_ids).preload(:host_statuses).find_in_batches do |hosts|
|
|
11
|
+
hosts.each { |host| host.refresh_global_status! }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
deleted_count
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -12,6 +12,11 @@ module ForemanRhCloud
|
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def create_playbook
|
|
15
|
+
unless cloud_auth_available?
|
|
16
|
+
logger.debug('Cloud authentication is not available, cannot continue')
|
|
17
|
+
return
|
|
18
|
+
end
|
|
19
|
+
|
|
15
20
|
response = query_playbook
|
|
16
21
|
|
|
17
22
|
logger.debug("Got playbook response: #{response.body}")
|
data/config/Gemfile.lock.gh_test
CHANGED
|
@@ -4,7 +4,6 @@ PATH
|
|
|
4
4
|
foreman_rh_cloud (3.0.15)
|
|
5
5
|
foreman_ansible
|
|
6
6
|
katello
|
|
7
|
-
redhat_access
|
|
8
7
|
|
|
9
8
|
PATH
|
|
10
9
|
remote: ../katello
|
|
@@ -41,66 +40,66 @@ PATH
|
|
|
41
40
|
GEM
|
|
42
41
|
remote: https://rubygems.org/
|
|
43
42
|
specs:
|
|
44
|
-
actioncable (6.0.3.
|
|
45
|
-
actionpack (= 6.0.3.
|
|
43
|
+
actioncable (6.0.3.6)
|
|
44
|
+
actionpack (= 6.0.3.6)
|
|
46
45
|
nio4r (~> 2.0)
|
|
47
46
|
websocket-driver (>= 0.6.1)
|
|
48
|
-
actionmailbox (6.0.3.
|
|
49
|
-
actionpack (= 6.0.3.
|
|
50
|
-
activejob (= 6.0.3.
|
|
51
|
-
activerecord (= 6.0.3.
|
|
52
|
-
activestorage (= 6.0.3.
|
|
53
|
-
activesupport (= 6.0.3.
|
|
47
|
+
actionmailbox (6.0.3.6)
|
|
48
|
+
actionpack (= 6.0.3.6)
|
|
49
|
+
activejob (= 6.0.3.6)
|
|
50
|
+
activerecord (= 6.0.3.6)
|
|
51
|
+
activestorage (= 6.0.3.6)
|
|
52
|
+
activesupport (= 6.0.3.6)
|
|
54
53
|
mail (>= 2.7.1)
|
|
55
|
-
actionmailer (6.0.3.
|
|
56
|
-
actionpack (= 6.0.3.
|
|
57
|
-
actionview (= 6.0.3.
|
|
58
|
-
activejob (= 6.0.3.
|
|
54
|
+
actionmailer (6.0.3.6)
|
|
55
|
+
actionpack (= 6.0.3.6)
|
|
56
|
+
actionview (= 6.0.3.6)
|
|
57
|
+
activejob (= 6.0.3.6)
|
|
59
58
|
mail (~> 2.5, >= 2.5.4)
|
|
60
59
|
rails-dom-testing (~> 2.0)
|
|
61
|
-
actionpack (6.0.3.
|
|
62
|
-
actionview (= 6.0.3.
|
|
63
|
-
activesupport (= 6.0.3.
|
|
60
|
+
actionpack (6.0.3.6)
|
|
61
|
+
actionview (= 6.0.3.6)
|
|
62
|
+
activesupport (= 6.0.3.6)
|
|
64
63
|
rack (~> 2.0, >= 2.0.8)
|
|
65
64
|
rack-test (>= 0.6.3)
|
|
66
65
|
rails-dom-testing (~> 2.0)
|
|
67
66
|
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
|
68
|
-
actiontext (6.0.3.
|
|
69
|
-
actionpack (= 6.0.3.
|
|
70
|
-
activerecord (= 6.0.3.
|
|
71
|
-
activestorage (= 6.0.3.
|
|
72
|
-
activesupport (= 6.0.3.
|
|
67
|
+
actiontext (6.0.3.6)
|
|
68
|
+
actionpack (= 6.0.3.6)
|
|
69
|
+
activerecord (= 6.0.3.6)
|
|
70
|
+
activestorage (= 6.0.3.6)
|
|
71
|
+
activesupport (= 6.0.3.6)
|
|
73
72
|
nokogiri (>= 1.8.5)
|
|
74
|
-
actionview (6.0.3.
|
|
75
|
-
activesupport (= 6.0.3.
|
|
73
|
+
actionview (6.0.3.6)
|
|
74
|
+
activesupport (= 6.0.3.6)
|
|
76
75
|
builder (~> 3.1)
|
|
77
76
|
erubi (~> 1.4)
|
|
78
77
|
rails-dom-testing (~> 2.0)
|
|
79
78
|
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
|
80
|
-
activejob (6.0.3.
|
|
81
|
-
activesupport (= 6.0.3.
|
|
79
|
+
activejob (6.0.3.6)
|
|
80
|
+
activesupport (= 6.0.3.6)
|
|
82
81
|
globalid (>= 0.3.6)
|
|
83
|
-
activemodel (6.0.3.
|
|
84
|
-
activesupport (= 6.0.3.
|
|
85
|
-
activerecord (6.0.3.
|
|
86
|
-
activemodel (= 6.0.3.
|
|
87
|
-
activesupport (= 6.0.3.
|
|
88
|
-
activerecord-import (1.0.
|
|
82
|
+
activemodel (6.0.3.6)
|
|
83
|
+
activesupport (= 6.0.3.6)
|
|
84
|
+
activerecord (6.0.3.6)
|
|
85
|
+
activemodel (= 6.0.3.6)
|
|
86
|
+
activesupport (= 6.0.3.6)
|
|
87
|
+
activerecord-import (1.0.8)
|
|
89
88
|
activerecord (>= 3.2)
|
|
90
89
|
activerecord-nulldb-adapter (0.7.0)
|
|
91
90
|
activerecord (>= 5.2.0, < 6.3)
|
|
92
|
-
activerecord-session_store (
|
|
93
|
-
actionpack (>= 4.
|
|
94
|
-
activerecord (>= 4.
|
|
91
|
+
activerecord-session_store (2.0.0)
|
|
92
|
+
actionpack (>= 5.2.4.1)
|
|
93
|
+
activerecord (>= 5.2.4.1)
|
|
95
94
|
multi_json (~> 1.11, >= 1.11.2)
|
|
96
|
-
rack (>=
|
|
97
|
-
railties (>= 4.
|
|
98
|
-
activestorage (6.0.3.
|
|
99
|
-
actionpack (= 6.0.3.
|
|
100
|
-
activejob (= 6.0.3.
|
|
101
|
-
activerecord (= 6.0.3.
|
|
102
|
-
marcel (~> 0.
|
|
103
|
-
activesupport (6.0.3.
|
|
95
|
+
rack (>= 2.0.8, < 3)
|
|
96
|
+
railties (>= 5.2.4.1)
|
|
97
|
+
activestorage (6.0.3.6)
|
|
98
|
+
actionpack (= 6.0.3.6)
|
|
99
|
+
activejob (= 6.0.3.6)
|
|
100
|
+
activerecord (= 6.0.3.6)
|
|
101
|
+
marcel (~> 1.0.0)
|
|
102
|
+
activesupport (6.0.3.6)
|
|
104
103
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
|
105
104
|
i18n (>= 0.7, < 2)
|
|
106
105
|
minitest (~> 5.1)
|
|
@@ -109,7 +108,7 @@ GEM
|
|
|
109
108
|
addressable (2.7.0)
|
|
110
109
|
public_suffix (>= 2.0.2, < 5.0)
|
|
111
110
|
algebrick (0.7.5)
|
|
112
|
-
amazing_print (1.
|
|
111
|
+
amazing_print (1.3.0)
|
|
113
112
|
ancestry (3.2.1)
|
|
114
113
|
activerecord (>= 4.2.0)
|
|
115
114
|
anemone (0.7.2)
|
|
@@ -136,13 +135,13 @@ GEM
|
|
|
136
135
|
benchmark-ips (2.8.4)
|
|
137
136
|
binding_of_caller (1.0.0)
|
|
138
137
|
debug_inspector (>= 0.0.1)
|
|
139
|
-
bootsnap (1.7.
|
|
138
|
+
bootsnap (1.7.3)
|
|
140
139
|
msgpack (~> 1.0)
|
|
141
140
|
bootstrap-sass (3.4.1)
|
|
142
141
|
autoprefixer-rails (>= 5.2.1)
|
|
143
142
|
sassc (>= 2.0.0)
|
|
144
143
|
builder (3.2.4)
|
|
145
|
-
bullet (6.1.
|
|
144
|
+
bullet (6.1.4)
|
|
146
145
|
activesupport (>= 3.0.0)
|
|
147
146
|
uniform_notifier (~> 1.11)
|
|
148
147
|
byebug (11.1.3)
|
|
@@ -168,7 +167,7 @@ GEM
|
|
|
168
167
|
coffee-script-source
|
|
169
168
|
execjs
|
|
170
169
|
coffee-script-source (1.12.2)
|
|
171
|
-
concurrent-ruby (1.1.
|
|
170
|
+
concurrent-ruby (1.1.9)
|
|
172
171
|
concurrent-ruby-edge (0.6.0)
|
|
173
172
|
concurrent-ruby (~> 1.1.6)
|
|
174
173
|
connection_pool (2.2.3)
|
|
@@ -180,12 +179,12 @@ GEM
|
|
|
180
179
|
daemons (1.3.1)
|
|
181
180
|
database_cleaner (1.99.0)
|
|
182
181
|
deacon (1.0.0)
|
|
183
|
-
debug_inspector (1.
|
|
182
|
+
debug_inspector (1.1.0)
|
|
184
183
|
declarative (0.0.20)
|
|
185
184
|
declarative-option (0.1.0)
|
|
186
|
-
deep_cloneable (3.
|
|
185
|
+
deep_cloneable (3.1.0)
|
|
187
186
|
activerecord (>= 3.1.0, < 7)
|
|
188
|
-
deface (1.
|
|
187
|
+
deface (1.8.1)
|
|
189
188
|
nokogiri (>= 1.6)
|
|
190
189
|
polyglot
|
|
191
190
|
rails (>= 5.2)
|
|
@@ -338,7 +337,7 @@ GEM
|
|
|
338
337
|
http-cookie (1.0.3)
|
|
339
338
|
domain_name (~> 0.5)
|
|
340
339
|
httpclient (2.8.3)
|
|
341
|
-
i18n (1.8.
|
|
340
|
+
i18n (1.8.10)
|
|
342
341
|
concurrent-ruby (~> 1.0)
|
|
343
342
|
immigrant (0.3.6)
|
|
344
343
|
activerecord (>= 3.0)
|
|
@@ -369,16 +368,14 @@ GEM
|
|
|
369
368
|
nokogiri (>= 1.5.9)
|
|
370
369
|
mail (2.7.1)
|
|
371
370
|
mini_mime (>= 0.1.1)
|
|
372
|
-
marcel (0.
|
|
373
|
-
mimemagic (~> 0.3.2)
|
|
371
|
+
marcel (1.0.0)
|
|
374
372
|
maruku (0.7.3)
|
|
375
373
|
memoist (0.16.2)
|
|
376
374
|
method_source (1.0.0)
|
|
377
375
|
mime-types (3.3.1)
|
|
378
376
|
mime-types-data (~> 3.2015)
|
|
379
|
-
mime-types-data (3.
|
|
380
|
-
|
|
381
|
-
mini_mime (1.0.2)
|
|
377
|
+
mime-types-data (3.2021.0225)
|
|
378
|
+
mini_mime (1.0.3)
|
|
382
379
|
mini_portile2 (2.5.0)
|
|
383
380
|
minitest (5.10.3)
|
|
384
381
|
minitest-reporters (1.4.3)
|
|
@@ -404,8 +401,8 @@ GEM
|
|
|
404
401
|
net-ssh (>= 2.6.5, < 7.0.0)
|
|
405
402
|
net-ssh (4.2.0)
|
|
406
403
|
netrc (0.11.0)
|
|
407
|
-
nio4r (2.5.
|
|
408
|
-
nokogiri (1.11.
|
|
404
|
+
nio4r (2.5.7)
|
|
405
|
+
nokogiri (1.11.2)
|
|
409
406
|
mini_portile2 (~> 2.5.0)
|
|
410
407
|
racc (~> 1.4)
|
|
411
408
|
oauth (0.5.5)
|
|
@@ -415,7 +412,7 @@ GEM
|
|
|
415
412
|
json (>= 1, < 3)
|
|
416
413
|
paint (2.2.1)
|
|
417
414
|
parallel (1.20.1)
|
|
418
|
-
parallel_tests (3.
|
|
415
|
+
parallel_tests (3.6.0)
|
|
419
416
|
parallel
|
|
420
417
|
parse-cron (0.1.4)
|
|
421
418
|
parser (3.0.0.0)
|
|
@@ -492,20 +489,20 @@ GEM
|
|
|
492
489
|
rack
|
|
493
490
|
rack-test (1.1.0)
|
|
494
491
|
rack (>= 1.0, < 3)
|
|
495
|
-
rails (6.0.3.
|
|
496
|
-
actioncable (= 6.0.3.
|
|
497
|
-
actionmailbox (= 6.0.3.
|
|
498
|
-
actionmailer (= 6.0.3.
|
|
499
|
-
actionpack (= 6.0.3.
|
|
500
|
-
actiontext (= 6.0.3.
|
|
501
|
-
actionview (= 6.0.3.
|
|
502
|
-
activejob (= 6.0.3.
|
|
503
|
-
activemodel (= 6.0.3.
|
|
504
|
-
activerecord (= 6.0.3.
|
|
505
|
-
activestorage (= 6.0.3.
|
|
506
|
-
activesupport (= 6.0.3.
|
|
492
|
+
rails (6.0.3.6)
|
|
493
|
+
actioncable (= 6.0.3.6)
|
|
494
|
+
actionmailbox (= 6.0.3.6)
|
|
495
|
+
actionmailer (= 6.0.3.6)
|
|
496
|
+
actionpack (= 6.0.3.6)
|
|
497
|
+
actiontext (= 6.0.3.6)
|
|
498
|
+
actionview (= 6.0.3.6)
|
|
499
|
+
activejob (= 6.0.3.6)
|
|
500
|
+
activemodel (= 6.0.3.6)
|
|
501
|
+
activerecord (= 6.0.3.6)
|
|
502
|
+
activestorage (= 6.0.3.6)
|
|
503
|
+
activesupport (= 6.0.3.6)
|
|
507
504
|
bundler (>= 1.3.0)
|
|
508
|
-
railties (= 6.0.3.
|
|
505
|
+
railties (= 6.0.3.6)
|
|
509
506
|
sprockets-rails (>= 2.0.0)
|
|
510
507
|
rails-controller-testing (1.0.5)
|
|
511
508
|
actionpack (>= 5.0.1.rc1)
|
|
@@ -519,9 +516,9 @@ GEM
|
|
|
519
516
|
rails-i18n (6.0.0)
|
|
520
517
|
i18n (>= 0.7, < 2)
|
|
521
518
|
railties (>= 6.0.0, < 7)
|
|
522
|
-
railties (6.0.3.
|
|
523
|
-
actionpack (= 6.0.3.
|
|
524
|
-
activesupport (= 6.0.3.
|
|
519
|
+
railties (6.0.3.6)
|
|
520
|
+
actionpack (= 6.0.3.6)
|
|
521
|
+
activesupport (= 6.0.3.6)
|
|
525
522
|
method_source
|
|
526
523
|
rake (>= 0.8.7)
|
|
527
524
|
thor (>= 0.20.3, < 2.0)
|
|
@@ -541,13 +538,6 @@ GEM
|
|
|
541
538
|
rdoc (6.3.0)
|
|
542
539
|
record_tag_helper (1.0.1)
|
|
543
540
|
actionview (>= 5)
|
|
544
|
-
redhat_access (2.2.18)
|
|
545
|
-
angular-rails-templates (>= 0.0.4)
|
|
546
|
-
foreman-tasks
|
|
547
|
-
katello
|
|
548
|
-
redhat_access_lib (>= 1.1.5)
|
|
549
|
-
redhat_access_lib (1.1.5)
|
|
550
|
-
rest-client (>= 1.6.3)
|
|
551
541
|
redis (4.1.4)
|
|
552
542
|
regexp_parser (1.8.2)
|
|
553
543
|
representable (3.0.4)
|
|
@@ -628,8 +618,8 @@ GEM
|
|
|
628
618
|
tilt
|
|
629
619
|
scoped_search (4.1.9)
|
|
630
620
|
activerecord (>= 4.2.0)
|
|
631
|
-
sd_notify (0.1.
|
|
632
|
-
secure_headers (6.3.
|
|
621
|
+
sd_notify (0.1.1)
|
|
622
|
+
secure_headers (6.3.2)
|
|
633
623
|
selenium-webdriver (3.142.7)
|
|
634
624
|
childprocess (>= 0.5, < 4.0)
|
|
635
625
|
rubyzip (>= 1.2.2)
|
|
@@ -716,7 +706,7 @@ PLATFORMS
|
|
|
716
706
|
|
|
717
707
|
DEPENDENCIES
|
|
718
708
|
activerecord-nulldb-adapter
|
|
719
|
-
activerecord-session_store (>=
|
|
709
|
+
activerecord-session_store (>= 2.0.0, < 3)
|
|
720
710
|
amazing_print (~> 1.1)
|
|
721
711
|
ancestry (>= 3.0.7, < 4, != 3.2.0)
|
|
722
712
|
apipie-dsl (>= 2.2.6)
|