foreman_rh_cloud 4.0.25.1 → 5.0.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/api/v2/rh_cloud/inventory_controller.rb +4 -1
- data/app/controllers/concerns/inventory_upload/report_actions.rb +1 -1
- data/app/controllers/foreman_inventory_upload/reports_controller.rb +1 -1
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +8 -0
- data/app/controllers/insights_cloud/hits_controller.rb +1 -1
- data/app/models/insights_hit.rb +4 -0
- data/app/models/setting/rh_cloud.rb +0 -1
- data/app/models/task_output_line.rb +2 -0
- data/app/models/task_output_status.rb +2 -0
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +14 -2
- data/config/Gemfile.lock.gh_test +169 -152
- data/config/database.yml.example +2 -2
- data/config/package-lock.json.plugin +10551 -7500
- data/config/routes.rb +1 -1
- data/db/migrate/20211027000001_create_task_output.foreman_rh_cloud.rb +18 -0
- data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +11 -7
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +24 -12
- data/lib/foreman_inventory_upload/async/progress_output.rb +5 -28
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +20 -5
- data/lib/foreman_inventory_upload/async/shell_process.rb +17 -4
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +22 -13
- data/lib/foreman_inventory_upload/generators/queries.rb +1 -0
- data/lib/foreman_inventory_upload/generators/tags.rb +1 -2
- data/lib/foreman_rh_cloud/engine.rb +4 -10
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +12 -1
- data/lib/insights_cloud/async/insights_client_status_aging.rb +4 -0
- data/lib/insights_cloud/async/insights_full_sync.rb +4 -0
- data/lib/insights_cloud/async/insights_generate_notifications.rb +4 -0
- data/lib/insights_cloud/async/insights_resolutions_sync.rb +7 -2
- data/lib/insights_cloud/async/insights_rules_sync.rb +10 -2
- data/lib/insights_cloud/async/insights_scheduled_sync.rb +11 -7
- data/lib/inventory_sync/async/host_result.rb +0 -5
- data/lib/inventory_sync/async/inventory_full_sync.rb +18 -9
- data/lib/inventory_sync/async/inventory_hosts_sync.rb +6 -6
- data/lib/inventory_sync/async/inventory_scheduled_sync.rb +4 -0
- data/lib/inventory_sync/async/inventory_self_host_sync.rb +4 -0
- data/lib/inventory_sync/async/query_inventory_job.rb +4 -0
- data/lib/tasks/rh_cloud_inventory.rake +2 -2
- data/package.json +8 -13
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +16 -39
- data/test/controllers/insights_sync/settings_controller_test.rb +2 -2
- data/test/controllers/uploads_settings_controller_test.rb +2 -2
- data/test/factories/inventory_upload_factories.rb +14 -0
- data/test/jobs/insights_full_sync_test.rb +2 -2
- data/test/jobs/insights_resolutions_sync_test.rb +11 -2
- data/test/jobs/insights_rules_sync_test.rb +2 -2
- data/test/jobs/inventory_full_sync_test.rb +31 -5
- data/test/jobs/inventory_hosts_sync_test.rb +16 -1
- data/test/jobs/inventory_scheduled_sync_test.rb +2 -2
- data/test/jobs/inventory_self_host_sync_test.rb +1 -1
- data/test/jobs/upload_report_job_test.rb +6 -4
- data/test/test_plugin_helper.rb +0 -2
- data/test/unit/foreman_rh_cloud_self_host_test.rb +28 -0
- data/test/unit/rh_cloud_http_proxy_test.rb +1 -1
- data/test/unit/services/foreman_rh_cloud/branch_info_test.rb +1 -1
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +26 -0
- data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +1 -1
- data/test/unit/shell_process_job_test.rb +3 -1
- data/test/unit/slice_generator_test.rb +39 -7
- data/test/unit/tags_generator_test.rb +20 -20
- data/webpack/ForemanInventoryUpload/Components/AccountList/accountList.scss +8 -0
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageHeader.scss +17 -4
- data/webpack/ForemanInventoryUpload/Components/PageHeader/PageTitle.js +29 -17
- data/webpack/ForemanInventoryUpload/Components/PageHeader/__tests__/__snapshots__/PageTitle.test.js.snap +58 -47
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +12 -10
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +10 -10
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +1 -1
- data/webpack/ForemanRhCloudFills.js +7 -0
- data/webpack/InsightsCloudSync/Components/InsightsHeader/index.js +0 -2
- data/webpack/InsightsCloudSync/Components/InsightsSettings/insightsSettings.scss +1 -0
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTable.js +22 -6
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +23 -16
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableConstants.js +49 -2
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableHelpers.js +31 -14
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTable.test.js.snap +19 -2
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +0 -1
- data/webpack/InsightsCloudSync/Components/InsightsTable/table.scss +11 -13
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.scss +0 -14
- data/webpack/InsightsCloudSync/Components/ToolbarDropdown.js +13 -0
- data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/InsightsHeader.test.js.snap +0 -1
- data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +24 -13
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +2 -0
- data/webpack/InsightsCloudSync/InsightsCloudSyncHelpers.js +8 -0
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +2 -1
- data/webpack/InsightsHostDetailsTab/InsightsTab.scss +4 -0
- data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +104 -0
- data/webpack/__mocks__/foremanReact/components/Head.js +11 -0
- data/webpack/common/DropdownToggle.js +24 -0
- data/webpack/common/Switcher/HelpLabel.js +1 -1
- data/webpack/common/Switcher/__tests__/__snapshots__/HelpLabel.test.js.snap +1 -1
- data/webpack/common/Switcher/__tests__/__snapshots__/SwitcherPF4.test.js.snap +1 -0
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a77b9dd6b10d3bf354a1ea4888ac4c829a66de66da4f432860e76ffe1b2a887
|
4
|
+
data.tar.gz: 81913ea4f9745d2c2e08d2c6b5117395c3b360b1879acdd21c8b83fabeccb4a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 026bf10d2031f225aa64539059ed9fea96254a04e4dfb305db0ffc3ca7c0c3c9676b5d331a78cdf98320c3175765a1d862e7be707f4f69ef0f95a8149977119f
|
7
|
+
data.tar.gz: c8b159a4c8f86bfcf710094b3b6e49b06b00d0d8448f8d853ee0777bf356cd6a3165c497b98f9bba3106f1c1ac234f49f297ff3cf58b548fcb2d462c04eb4f33
|
@@ -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
|
@@ -11,7 +11,7 @@ module InventoryUpload
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def start_report_generation(organization_id)
|
14
|
-
ForemanInventoryUpload::Async::GenerateReportJob
|
14
|
+
ForemanTasks.async_task(ForemanInventoryUpload::Async::GenerateReportJob, ForemanInventoryUpload.generated_reports_folder, organization_id)
|
15
15
|
end
|
16
16
|
|
17
17
|
def report_file(organization_id)
|
@@ -7,7 +7,7 @@ module ForemanInventoryUpload
|
|
7
7
|
def last
|
8
8
|
label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(params[:organization_id])
|
9
9
|
output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
|
10
|
-
task_label = ForemanInventoryUpload::Async::GenerateAllReportsJob.
|
10
|
+
task_label = ForemanInventoryUpload::Async::GenerateAllReportsJob.name
|
11
11
|
scheduled = ForemanTasks::Task.where(
|
12
12
|
:label => task_label,
|
13
13
|
:state => 'scheduled'
|
@@ -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
|
@@ -7,7 +7,7 @@ module InsightsCloud
|
|
7
7
|
|
8
8
|
render json: {
|
9
9
|
hasToken: !Setting[:rh_cloud_token].empty?,
|
10
|
-
hits: hits.map { |hit| hit.attributes.merge(hostname: hit.host&.name, has_playbook: hit.has_playbook
|
10
|
+
hits: hits.map { |hit| hit.attributes.merge(hostname: hit.host&.name, has_playbook: hit.has_playbook?, host_uuid: hit.host_uuid) },
|
11
11
|
itemCount: hits.count,
|
12
12
|
}, status: :ok
|
13
13
|
end
|
data/app/models/insights_hit.rb
CHANGED
@@ -12,7 +12,6 @@ class Setting::RhCloud < Setting
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.default_settings
|
15
|
-
return unless ActiveRecord::Base.connection.table_exists?('settings')
|
16
15
|
[
|
17
16
|
set('allow_auto_inventory_upload', N_('Enable automatic upload of your host inventory to the Red Hat cloud'), true, N_('Automatic inventory upload')),
|
18
17
|
set('allow_auto_insights_sync', N_('Enable automatic synchronization of Insights recommendations from the Red Hat cloud'), false, N_('Synchronize recommendations Automatically')),
|
@@ -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,6 +64,12 @@ 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'),
|
@@ -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)
|