foreman_rh_cloud 3.0.25 → 4.0.21.1
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/reports_controller.rb +1 -3
- data/app/controllers/foreman_inventory_upload/tasks_controller.rb +13 -5
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +4 -4
- data/app/controllers/insights_cloud/api/machine_telemetries_controller.rb +3 -6
- data/app/controllers/insights_cloud/hits_controller.rb +3 -7
- data/app/models/insights_client_report_status.rb +22 -11
- data/app/services/foreman_rh_cloud/cloud_auth.rb +0 -16
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +14 -1
- data/app/services/foreman_rh_cloud/remediations_retriever.rb +4 -6
- data/app/subscribers/foreman_rh_cloud/insights_subscriber.rb +9 -0
- data/config/routes.rb +0 -19
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +0 -19
- data/lib/foreman_inventory_upload/generators/queries.rb +0 -1
- data/lib/foreman_inventory_upload/generators/slice.rb +5 -6
- data/lib/foreman_inventory_upload/generators/tags.rb +1 -3
- data/lib/foreman_inventory_upload.rb +1 -9
- data/lib/foreman_rh_cloud/engine.rb +10 -17
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/insights_cloud/async/insights_full_sync.rb +14 -9
- data/lib/insights_cloud/async/insights_resolutions_sync.rb +4 -10
- data/lib/insights_cloud/async/insights_rules_sync.rb +7 -7
- data/lib/inventory_sync/async/host_result.rb +0 -4
- data/lib/inventory_sync/async/inventory_full_sync.rb +1 -7
- data/lib/inventory_sync/async/inventory_hosts_sync.rb +2 -21
- data/lib/inventory_sync/async/inventory_scheduled_sync.rb +0 -12
- data/lib/inventory_sync/async/query_inventory_job.rb +5 -6
- data/lib/tasks/insights.rake +0 -15
- data/lib/tasks/rh_cloud_inventory.rake +1 -8
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +0 -41
- data/test/factories/inventory_upload_factories.rb +1 -1
- data/test/jobs/insights_full_sync_test.rb +0 -1
- data/test/jobs/insights_resolutions_sync_test.rb +0 -1
- data/test/jobs/insights_rules_sync_test.rb +0 -1
- data/test/jobs/inventory_full_sync_test.rb +0 -10
- data/test/models/insights_client_report_status_test.rb +72 -70
- data/test/test_plugin_helper.rb +0 -2
- data/test/unit/services/foreman_rh_cloud/cloud_request_forwarder_test.rb +3 -3
- data/test/unit/services/foreman_rh_cloud/template_renderer_helper_test.rb +0 -1
- data/test/unit/slice_generator_test.rb +27 -70
- data/test/unit/tags_generator_test.rb +0 -41
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +0 -11
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +0 -11
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/SyncButtonActions.js +63 -28
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/__tests__/__snapshots__/integrations.test.js.snap +3 -2
- data/webpack/InsightsCloudSync/Components/InsightsTable/InsightsTableActions.js +19 -19
- data/webpack/InsightsCloudSync/Components/InsightsTable/__tests__/__snapshots__/InsightsTableActions.test.js.snap +14 -14
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediateButton.js +0 -1
- data/webpack/InsightsCloudSync/Components/RemediationModal/RemediationModal.scss +0 -14
- data/webpack/InsightsCloudSync/Components/__tests__/__snapshots__/NoTokenEmptyState.test.js.snap +13 -20
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +1 -4
- data/webpack/InsightsCloudSync/InsightsCloudSyncActions.js +20 -44
- data/webpack/InsightsCloudSync/InsightsCloudSyncConstants.js +0 -2
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +2 -2
- data/webpack/InsightsCloudSync/__tests__/__snapshots__/InsightsCloudSyncActions.test.js.snap +7 -11
- metadata +4 -30
- data/app/controllers/api/v2/rh_cloud/inventory_controller.rb +0 -50
- data/app/controllers/concerns/inventory_upload/report_actions.rb +0 -26
- data/app/controllers/concerns/inventory_upload/task_actions.rb +0 -25
- data/app/helpers/foreman_insights_deprecations_helper.rb +0 -9
- data/app/helpers/foreman_insights_host_helper.rb +0 -19
- data/app/overrides/old_plugin_deprecation.rb +0 -20
- data/app/services/foreman_rh_cloud/cloud_request.rb +0 -14
- data/app/services/foreman_rh_cloud/insights_status_cleaner.rb +0 -17
- data/config/package-lock.json.plugin +0 -32774
- data/db/migrate/20210720000001_remove_old_insights_statuses.foreman_rh_cloud.rb +0 -6
- data/lib/insights_cloud/async/insights_client_status_aging.rb +0 -23
- data/lib/inventory_sync/async/inventory_self_host_sync.rb +0 -39
- data/test/controllers/inventory_upload/api/inventory_controller_test.rb +0 -53
- data/test/jobs/insights_client_status_aging_test.rb +0 -33
- data/test/jobs/inventory_hosts_sync_test.rb +0 -268
- data/test/jobs/inventory_scheduled_sync_test.rb +0 -22
- data/test/jobs/inventory_self_host_sync_test.rb +0 -104
- data/test/unit/services/foreman_rh_cloud/insights_status_cleaner_test.rb +0 -31
- data/webpack/common/ForemanTasks/ForemanTasksActions.js +0 -64
- data/webpack/common/ForemanTasks/ForemanTasksHelpers.js +0 -7
- data/webpack/common/ForemanTasks/index.js +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97882071192995f2da93032050b9ecdfa616dba407c8d032bfd29f6741ea9d56
|
4
|
+
data.tar.gz: 88bca49cea9ee2abac2d2dc9d608a33329ad9e214d57035424e8e24984691537
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 67dd2ada55ac862b2d57ddf893e7408d002c40c2f89a141e6bf8c115d6eeee32d19b156e7668751f591665f948fa04d628719e5f6f5ab9e4609c02f0a14a93f4
|
7
|
+
data.tar.gz: 54ded7bb163e4a38cd3fa4a62dfe101484b98e87c016514b985190f77a07c7556e980dd8574dc5fb70cacb3fcc521a37a1f4f2325e5360cdbb2ddd6f38816804
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
module ForemanInventoryUpload
|
4
4
|
class ReportsController < ::ApplicationController
|
5
|
-
include InventoryUpload::ReportActions
|
6
|
-
|
7
5
|
def last
|
8
6
|
label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(params[:organization_id])
|
9
7
|
output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
|
@@ -22,7 +20,7 @@ module ForemanInventoryUpload
|
|
22
20
|
def generate
|
23
21
|
organization_id = params[:organization_id]
|
24
22
|
|
25
|
-
|
23
|
+
ForemanInventoryUpload::Async::GenerateReportJob.perform_later(ForemanInventoryUpload.generated_reports_folder, organization_id)
|
26
24
|
|
27
25
|
render json: {
|
28
26
|
action_status: 'success',
|
@@ -1,17 +1,25 @@
|
|
1
1
|
module ForemanInventoryUpload
|
2
2
|
class TasksController < ::ApplicationController
|
3
|
-
include InventoryUpload::TaskActions
|
4
|
-
|
5
3
|
def create
|
6
4
|
selected_org = Organization.current
|
5
|
+
subscribed_hosts_ids = Set.new(
|
6
|
+
ForemanInventoryUpload::Generators::Queries.for_slice(
|
7
|
+
Host.unscoped.where(organization: selected_org)
|
8
|
+
).pluck(:id)
|
9
|
+
)
|
7
10
|
|
8
|
-
|
11
|
+
if subscribed_hosts_ids.empty?
|
12
|
+
return render json: {
|
13
|
+
message: N_('Nothing to sync, there are no hosts with subscription for this organization.'),
|
14
|
+
}, status: :method_not_allowed
|
15
|
+
else
|
16
|
+
task = ForemanTasks.async_task(InventorySync::Async::InventoryFullSync, selected_org)
|
17
|
+
end
|
18
|
+
return render json: { message: N_('there was an issue triggering the task') }, status: :internal_server_error unless task
|
9
19
|
|
10
20
|
render json: {
|
11
21
|
task: task,
|
12
22
|
}, status: :ok
|
13
|
-
rescue InventoryUpload::TaskActions::NothingToSyncError => error
|
14
|
-
render json: { message: error.message }, status: :internal_server_error
|
15
23
|
end
|
16
24
|
|
17
25
|
def show
|
@@ -1,7 +1,5 @@
|
|
1
1
|
module ForemanInventoryUpload
|
2
2
|
class UploadsController < ::ApplicationController
|
3
|
-
include InventoryUpload::ReportActions
|
4
|
-
|
5
3
|
def last
|
6
4
|
label = ForemanInventoryUpload::Async::UploadReportJob.output_label(params[:organization_id])
|
7
5
|
output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
|
@@ -12,9 +10,11 @@ module ForemanInventoryUpload
|
|
12
10
|
end
|
13
11
|
|
14
12
|
def download_file
|
15
|
-
filename
|
13
|
+
filename = ForemanInventoryUpload.facts_archive_name(params[:organization_id])
|
14
|
+
files = Dir["{#{ForemanInventoryUpload.uploads_file_path(filename)},#{ForemanInventoryUpload.done_file_path(filename)}}"]
|
16
15
|
|
17
|
-
send_file
|
16
|
+
return send_file files.first, disposition: 'attachment', filename: filename unless files.empty?
|
17
|
+
raise ::Foreman::Exception.new("The report file doesn't exist")
|
18
18
|
end
|
19
19
|
|
20
20
|
def enable_cloud_connector
|
@@ -5,7 +5,6 @@ module InsightsCloud::Api
|
|
5
5
|
include ::InsightsCloud::ClientAuthentication
|
6
6
|
include ::InsightsCloud::CandlepinCache
|
7
7
|
|
8
|
-
before_action :set_admin_user, only: [:forward_request]
|
9
8
|
before_action :cert_uuid, :ensure_org, :ensure_branch_id, :only => [:forward_request, :branch_info]
|
10
9
|
before_action :ensure_telemetry_enabled_for_consumer, :only => [:forward_request]
|
11
10
|
|
@@ -76,11 +75,9 @@ module InsightsCloud::Api
|
|
76
75
|
return unless request.path == '/redhat_access/r/insights/platform/ingress/v1/upload' ||
|
77
76
|
request.path.include?('/redhat_access/r/insights/uploads/')
|
78
77
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
@host.get_status(InsightsClientReportStatus).refresh!
|
83
|
-
@host.refresh_global_status!
|
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))
|
84
81
|
end
|
85
82
|
end
|
86
83
|
end
|
@@ -3,7 +3,7 @@ module InsightsCloud
|
|
3
3
|
include Foreman::Controller::AutoCompleteSearch
|
4
4
|
|
5
5
|
def index
|
6
|
-
hits = resource_base_search_and_page.preload(:host, :rule)
|
6
|
+
hits = resource_base_search_and_page.where(host: Host.authorized).preload(:host, :rule)
|
7
7
|
|
8
8
|
render json: {
|
9
9
|
hasToken: !Setting[:rh_cloud_token].empty?,
|
@@ -23,9 +23,9 @@ module InsightsCloud
|
|
23
23
|
|
24
24
|
def resolutions
|
25
25
|
if remediation_all_selected_param
|
26
|
-
hits =
|
26
|
+
hits = InsightsHit.with_playbook.search_for(params[:query])
|
27
27
|
else
|
28
|
-
hits = resource_base_search_and_page.
|
28
|
+
hits = resource_base_search_and_page.where(id: remediation_ids_param)
|
29
29
|
end
|
30
30
|
|
31
31
|
hits.preload(:host, rule: :resolutions)
|
@@ -74,9 +74,5 @@ module InsightsCloud
|
|
74
74
|
def remediation_all_selected_param
|
75
75
|
ActiveModel::Type::Boolean.new.cast(params[:isAllSelected])
|
76
76
|
end
|
77
|
-
|
78
|
-
def resource_base
|
79
|
-
super.where(host: Host.authorized)
|
80
|
-
end
|
81
77
|
end
|
82
78
|
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
class InsightsClientReportStatus < HostStatus::Status
|
2
2
|
REPORT_INTERVAL = 48.hours
|
3
3
|
|
4
|
-
REPORTING = 0
|
5
|
-
NO_REPORT = 1
|
6
|
-
|
7
|
-
|
8
|
-
scope :reporting, -> { where(status: REPORTING) }
|
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
|
9
8
|
|
10
9
|
def self.status_name
|
11
10
|
N_('Insights')
|
@@ -17,6 +16,10 @@ class InsightsClientReportStatus < HostStatus::Status
|
|
17
16
|
N_('Reporting')
|
18
17
|
when NO_REPORT
|
19
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)')
|
20
23
|
end
|
21
24
|
end
|
22
25
|
|
@@ -26,16 +29,20 @@ class InsightsClientReportStatus < HostStatus::Status
|
|
26
29
|
::HostStatus::Global::OK
|
27
30
|
when NO_REPORT
|
28
31
|
::HostStatus::Global::ERROR
|
32
|
+
when NOT_MANAGED
|
33
|
+
::HostStatus::Global::OK
|
34
|
+
when NOT_MANAGED_WITH_DATA
|
35
|
+
::HostStatus::Global::WARN
|
29
36
|
end
|
30
37
|
end
|
31
38
|
|
32
|
-
def to_status
|
33
|
-
|
34
|
-
|
39
|
+
def to_status(data: false)
|
40
|
+
if insights_param
|
41
|
+
return REPORTING if data
|
42
|
+
return in_interval? ? REPORTING : NO_REPORT
|
43
|
+
end
|
35
44
|
|
36
|
-
|
37
|
-
def relevant?(_options = {})
|
38
|
-
persisted?
|
45
|
+
data ? NOT_MANAGED_WITH_DATA : NOT_MANAGED
|
39
46
|
end
|
40
47
|
|
41
48
|
private
|
@@ -44,4 +51,8 @@ class InsightsClientReportStatus < HostStatus::Status
|
|
44
51
|
return false unless reported_at
|
45
52
|
(Time.now.utc - reported_at).to_i < REPORT_INTERVAL.to_i
|
46
53
|
end
|
54
|
+
|
55
|
+
def insights_param
|
56
|
+
host.host_params_hash.dig('host_registration_insights', :value)
|
57
|
+
end
|
47
58
|
end
|
@@ -2,12 +2,6 @@ module ForemanRhCloud
|
|
2
2
|
module CloudAuth
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
|
-
include CloudRequest
|
6
|
-
|
7
|
-
def cloud_auth_available?
|
8
|
-
Setting[:rh_cloud_token].present?
|
9
|
-
end
|
10
|
-
|
11
5
|
def rh_credentials
|
12
6
|
@rh_credentials ||= query_refresh_token
|
13
7
|
end
|
@@ -30,15 +24,5 @@ module ForemanRhCloud
|
|
30
24
|
Foreman::Logging.exception('Unable to authenticate using rh_cloud_token setting', e)
|
31
25
|
raise ::Foreman::WrappedException.new(e, N_('Unable to authenticate using rh_cloud_token setting'))
|
32
26
|
end
|
33
|
-
|
34
|
-
def execute_cloud_request(params)
|
35
|
-
final_params = {
|
36
|
-
headers: {
|
37
|
-
Authorization: "Bearer #{rh_credentials}",
|
38
|
-
},
|
39
|
-
}.deep_merge(params)
|
40
|
-
|
41
|
-
super(final_params)
|
42
|
-
end
|
43
27
|
end
|
44
28
|
end
|
@@ -2,7 +2,7 @@ require 'rest-client'
|
|
2
2
|
|
3
3
|
module ForemanRhCloud
|
4
4
|
class CloudRequestForwarder
|
5
|
-
include ForemanRhCloud::
|
5
|
+
include ::ForemanRhCloud::CloudAuth
|
6
6
|
|
7
7
|
def forward_request(original_request, controller_name, branch_id, certs)
|
8
8
|
forward_params = prepare_forward_params(original_request, branch_id)
|
@@ -22,6 +22,7 @@ module ForemanRhCloud
|
|
22
22
|
def prepare_request_opts(original_request, forward_payload, forward_params, certs)
|
23
23
|
base_params = {
|
24
24
|
method: original_request.method,
|
25
|
+
verify_ssl: ForemanRhCloud.verify_ssl_method,
|
25
26
|
payload: forward_payload,
|
26
27
|
headers: {
|
27
28
|
params: forward_params,
|
@@ -32,6 +33,10 @@ module ForemanRhCloud
|
|
32
33
|
base_params.merge(path_params(original_request.path, certs))
|
33
34
|
end
|
34
35
|
|
36
|
+
def execute_cloud_request(request_opts)
|
37
|
+
RestClient::Request.execute request_opts
|
38
|
+
end
|
39
|
+
|
35
40
|
def prepare_forward_payload(original_request, controller_name)
|
36
41
|
forward_payload = original_request.request_parameters[controller_name]
|
37
42
|
|
@@ -56,6 +61,10 @@ module ForemanRhCloud
|
|
56
61
|
|
57
62
|
def path_params(request_path, certs)
|
58
63
|
case request_path
|
64
|
+
when metadata_request?
|
65
|
+
{
|
66
|
+
url: ForemanRhCloud.base_url + request_path.sub('/redhat_access/r/insights', '/api'),
|
67
|
+
}
|
59
68
|
when platform_request?
|
60
69
|
{
|
61
70
|
url: ForemanRhCloud.cert_base_url + request_path.sub('/redhat_access/r/insights/platform', '/api'),
|
@@ -72,6 +81,10 @@ module ForemanRhCloud
|
|
72
81
|
end
|
73
82
|
end
|
74
83
|
|
84
|
+
def metadata_request?
|
85
|
+
->(request_path) { request_path.include? '/static' }
|
86
|
+
end
|
87
|
+
|
75
88
|
def platform_request?
|
76
89
|
->(request_path) { request_path.include? '/platform' }
|
77
90
|
end
|
@@ -12,11 +12,6 @@ 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
|
-
|
20
15
|
response = query_playbook
|
21
16
|
|
22
17
|
logger.debug("Got playbook response: #{response.body}")
|
@@ -67,11 +62,14 @@ module ForemanRhCloud
|
|
67
62
|
end
|
68
63
|
|
69
64
|
def query_playbook
|
70
|
-
|
65
|
+
RestClient::Request.execute(
|
71
66
|
method: :post,
|
72
67
|
url: InsightsCloud.playbook_url,
|
68
|
+
verify_ssl: ForemanRhCloud.verify_ssl_method,
|
69
|
+
proxy: ForemanRhCloud.transformed_http_proxy_string(logger: logger),
|
73
70
|
headers: {
|
74
71
|
content_type: :json,
|
72
|
+
Authorization: "Bearer #{rh_credentials}",
|
75
73
|
},
|
76
74
|
payload: playbook_request.to_json
|
77
75
|
)
|
data/config/routes.rb
CHANGED
@@ -40,23 +40,4 @@ Rails.application.routes.draw do
|
|
40
40
|
match '/*path', :constraints => lambda { |req| !req.path.include?('view/api') }, to: 'machine_telemetries#forward_request', via: [:get, :post, :delete,:put, :patch]
|
41
41
|
end
|
42
42
|
end
|
43
|
-
|
44
|
-
# API routes
|
45
|
-
|
46
|
-
namespace :api, :defaults => {:format => 'json'} do
|
47
|
-
scope '(:apiv)', :module => :v2, :defaults => {:apiv => 'v2'}, :apiv => /v1|v2/, :constraints => ApiConstraints.new(:version => 2, :default => true) do
|
48
|
-
resources :organizations, :only => [:show] do
|
49
|
-
namespace 'rh_cloud' do
|
50
|
-
get 'report', to: 'inventory#download_file'
|
51
|
-
post 'report', to: 'inventory#generate_report'
|
52
|
-
|
53
|
-
post 'inventory_sync', to: 'inventory#sync_inventory_status'
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
namespace 'rh_cloud' do
|
58
|
-
post 'enable_connector', to: 'inventory#enable_cloud_connector'
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
43
|
end
|
@@ -10,8 +10,6 @@ module ForemanInventoryUpload
|
|
10
10
|
CLOUD_AZURE = 'azure'
|
11
11
|
CLOUD_ALIBABA = 'alibaba'
|
12
12
|
|
13
|
-
UUID_REGEX = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i
|
14
|
-
|
15
13
|
def fact_value(host, fact_name)
|
16
14
|
value_record = host.fact_values.find do |fact_value|
|
17
15
|
fact_value.fact_name_id == ForemanInventoryUpload::Generators::Queries.fact_names[fact_name]
|
@@ -106,23 +104,6 @@ module ForemanInventoryUpload
|
|
106
104
|
def obfuscate_ip(ip, ips_dict)
|
107
105
|
"10.230.230.#{ips_dict.count + 1}"
|
108
106
|
end
|
109
|
-
|
110
|
-
def bios_uuid(host)
|
111
|
-
value = fact_value(host, 'dmi::system::uuid') || ''
|
112
|
-
uuid_value(value)
|
113
|
-
end
|
114
|
-
|
115
|
-
def uuid_value(value)
|
116
|
-
uuid_match = UUID_REGEX.match(value)
|
117
|
-
uuid_match&.to_s
|
118
|
-
end
|
119
|
-
|
120
|
-
def uuid_value!(value)
|
121
|
-
uuid = uuid_value(value)
|
122
|
-
raise Foreman::Exception.new(N_('Value %{value} is not a valid UUID') % {value: value}) if value && uuid.empty?
|
123
|
-
|
124
|
-
uuid
|
125
|
-
end
|
126
107
|
end
|
127
108
|
end
|
128
109
|
end
|
@@ -25,7 +25,7 @@ module ForemanInventoryUpload
|
|
25
25
|
|
26
26
|
def report_slice(hosts_batch)
|
27
27
|
@stream.object do
|
28
|
-
@stream.simple_field('report_slice_id',
|
28
|
+
@stream.simple_field('report_slice_id', @slice_id)
|
29
29
|
@stream.array_field('hosts', :last) do
|
30
30
|
first = true
|
31
31
|
hosts_batch.each do |host|
|
@@ -45,11 +45,10 @@ module ForemanInventoryUpload
|
|
45
45
|
@stream.object do
|
46
46
|
@stream.simple_field('fqdn', fqdn(host))
|
47
47
|
@stream.simple_field('account', account_id(host.organization).to_s)
|
48
|
-
@stream.simple_field('subscription_manager_id',
|
49
|
-
@stream.simple_field('satellite_id',
|
50
|
-
@stream.simple_field('bios_uuid',
|
51
|
-
@stream.simple_field('vm_uuid',
|
52
|
-
@stream.simple_field('insights_id', uuid_value(fact_value(host, 'insights_id')))
|
48
|
+
@stream.simple_field('subscription_manager_id', host.subscription_facet&.uuid)
|
49
|
+
@stream.simple_field('satellite_id', host.subscription_facet&.uuid)
|
50
|
+
@stream.simple_field('bios_uuid', fact_value(host, 'dmi::system::uuid'))
|
51
|
+
@stream.simple_field('vm_uuid', fact_value(host, 'virt::uuid'))
|
53
52
|
report_ip_addresses(host, host_ips_cache)
|
54
53
|
report_mac_addresses(host)
|
55
54
|
@stream.object_field('system_profile') do
|
@@ -19,9 +19,7 @@ module ForemanInventoryUpload
|
|
19
19
|
def generate_parameters
|
20
20
|
return [] unless Setting[:include_parameter_tags]
|
21
21
|
|
22
|
-
(@host.host_inherited_params_objects || [])
|
23
|
-
.map { |item| [item.name, item.value] }
|
24
|
-
.select { |_name, value| value.present? || value.is_a?(FalseClass) }
|
22
|
+
(@host.host_inherited_params_objects || []).map { |item| [item.name, item.value] }
|
25
23
|
end
|
26
24
|
|
27
25
|
private
|
@@ -70,16 +70,8 @@ module ForemanInventoryUpload
|
|
70
70
|
folder
|
71
71
|
end
|
72
72
|
|
73
|
-
def self.inventory_base_url
|
74
|
-
ForemanRhCloud.base_url + "/api/inventory/v1/hosts"
|
75
|
-
end
|
76
|
-
|
77
73
|
def self.inventory_export_url
|
78
74
|
tags = URI.encode("satellite/satellite_instance_id=#{Foreman.instance_id}")
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
def self.inventory_self_url
|
83
|
-
inventory_base_url + "?hostname_or_id=#{ForemanRhCloud.foreman_host.fqdn}"
|
75
|
+
ForemanRhCloud.base_url + "/api/inventory/v1/hosts?tags=#{tags}"
|
84
76
|
end
|
85
77
|
end
|
@@ -6,18 +6,6 @@ module ForemanRhCloud
|
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
engine_name 'foreman_rh_cloud'
|
8
8
|
|
9
|
-
def self.register_scheduled_task(task_class, cronline)
|
10
|
-
return if ForemanTasks::RecurringLogic.joins(:tasks)
|
11
|
-
.merge(ForemanTasks::Task.where(label: task_class.name))
|
12
|
-
.exists?
|
13
|
-
|
14
|
-
User.as_anonymous_admin do
|
15
|
-
recurring_logic = ForemanTasks::RecurringLogic.new_from_cronline(cronline)
|
16
|
-
recurring_logic.save!
|
17
|
-
recurring_logic.start(task_class)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
9
|
initializer 'foreman_rh_cloud.load_default_settings', :before => :load_config_initializers do
|
22
10
|
require_dependency File.expand_path('../../app/models/setting/rh_cloud.rb', __dir__)
|
23
11
|
end
|
@@ -93,9 +81,7 @@ module ForemanRhCloud
|
|
93
81
|
register_custom_status InventorySync::InventoryStatus
|
94
82
|
register_custom_status InsightsClientReportStatus
|
95
83
|
|
96
|
-
|
97
|
-
overview_buttons_provider :insights_host_overview_buttons
|
98
|
-
end
|
84
|
+
subscribe 'host_created.event.foreman', ForemanRhCloud::InsightsSubscriber
|
99
85
|
|
100
86
|
extend_page 'hosts/show' do |context|
|
101
87
|
context.add_pagelet :main_tabs,
|
@@ -148,8 +134,15 @@ module ForemanRhCloud
|
|
148
134
|
# skip object creation when admin user is not present, for example in test DB
|
149
135
|
if User.unscoped.find_by_login(User::ANONYMOUS_ADMIN).present?
|
150
136
|
::ForemanTasks.dynflow.config.on_init(false) do |world|
|
151
|
-
|
152
|
-
|
137
|
+
unless ForemanTasks::RecurringLogic.joins(:tasks).merge(
|
138
|
+
ForemanTasks::Task.where(label: 'InventorySync::Async::InventoryScheduledSync')
|
139
|
+
).exists?
|
140
|
+
User.as_anonymous_admin do
|
141
|
+
recurring_logic = ForemanTasks::RecurringLogic.new_from_cronline("0 0 * * *")
|
142
|
+
recurring_logic.save!
|
143
|
+
recurring_logic.start(InventorySync::Async::InventoryScheduledSync)
|
144
|
+
end
|
145
|
+
end
|
153
146
|
end
|
154
147
|
end
|
155
148
|
end
|