foreman_rh_cloud 12.2.10 → 13.0.0
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/assets/javascripts/foreman_rh_cloud/locale/fr/foreman_rh_cloud.js +17 -50
- data/app/assets/javascripts/foreman_rh_cloud/locale/ja/foreman_rh_cloud.js +17 -50
- data/app/assets/javascripts/foreman_rh_cloud/locale/ka/foreman_rh_cloud.js +16 -49
- data/app/assets/javascripts/foreman_rh_cloud/locale/ko/foreman_rh_cloud.js +17 -50
- data/app/assets/javascripts/foreman_rh_cloud/locale/zh_CN/foreman_rh_cloud.js +17 -50
- data/app/controllers/concerns/insights_cloud/package_profile_upload_extensions.rb +3 -2
- data/app/models/insights_hit.rb +1 -1
- data/app/services/foreman_rh_cloud/cert_auth.rb +3 -13
- data/app/services/foreman_rh_cloud/gateway_request.rb +26 -0
- data/app/services/foreman_rh_cloud/insights_api_forwarder.rb +1 -3
- data/app/services/foreman_rh_cloud/tags_auth.rb +1 -2
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +8 -13
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +4 -4
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +5 -6
- data/lib/foreman_inventory_upload/generators/fact_helpers.rb +2 -2
- data/lib/foreman_inventory_upload/generators/slice.rb +3 -3
- data/lib/foreman_inventory_upload/scripts/uploader.sh.erb +1 -7
- data/lib/foreman_rh_cloud/engine.rb +15 -33
- data/lib/foreman_rh_cloud/plugin.rb +9 -9
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/tasks/rh_cloud_inventory.rake +31 -14
- data/locale/foreman_rh_cloud.pot +152 -219
- data/locale/fr/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/fr/foreman_rh_cloud.po +18 -50
- data/locale/ja/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ja/foreman_rh_cloud.po +18 -50
- data/locale/ka/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ka/foreman_rh_cloud.po +17 -49
- data/locale/ko/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/ko/foreman_rh_cloud.po +18 -50
- data/locale/zh_CN/LC_MESSAGES/foreman_rh_cloud.mo +0 -0
- data/locale/zh_CN/foreman_rh_cloud.po +18 -50
- data/package.json +1 -1
- data/test/jobs/upload_report_job_test.rb +1 -2
- data/test/unit/fact_helpers_test.rb +0 -47
- data/test/unit/slice_generator_test.rb +0 -57
- data/webpack/ForemanRhCloudFills.js +2 -6
- data/webpack/ForemanRhCloudHelpers.js +0 -4
- data/webpack/InsightsHostDetailsTab/InsightsTab.scss +0 -4
- data/webpack/InsightsHostDetailsTab/InsightsTotalRiskChart.js +23 -59
- data/webpack/InsightsHostDetailsTab/NewHostDetailsTab.js +16 -3
- data/webpack/__tests__/ForemanRhCloudHelpers.test.js +1 -16
- data/webpack/__tests__/__snapshots__/ForemanRhCloudHelpers.test.js.snap +0 -6
- metadata +4 -10
- data/lib/foreman_inventory_upload/async/create_missing_insights_facets.rb +0 -29
- data/lib/foreman_inventory_upload/async/generate_host_report.rb +0 -20
- data/lib/foreman_inventory_upload/async/host_inventory_report_job.rb +0 -39
- data/lib/foreman_inventory_upload/async/single_host_report_job.rb +0 -20
- data/test/jobs/queue_for_upload_job_test.rb +0 -63
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTotalRiskChart.test.js +0 -194
@@ -83,27 +83,6 @@ module ForemanRhCloud
|
|
83
83
|
:description => N_('Configure Cloud Connector on given hosts'),
|
84
84
|
:proxy_selector_override => ::RemoteExecutionProxySelector::INTERNAL_PROXY
|
85
85
|
)
|
86
|
-
|
87
|
-
ScopedSearch::AutoCompleteBuilder.class_eval do
|
88
|
-
# Insights rule IDs always contain a pipe character.
|
89
|
-
# example: hardening_ssh_config_perms|OPENSSH_HARDENING_CONFIG_PERMS
|
90
|
-
# We need to override this method of scoped_search so that autocomplete
|
91
|
-
# will correctly put the value in quotes (otherwise the "|" will be
|
92
|
-
# interpreted as an OR.)
|
93
|
-
# The only change from scoped_search code is adding the | to the regex in the final map.
|
94
|
-
def complete_value_from_db(field, special_values, val)
|
95
|
-
count = 20 - special_values.count
|
96
|
-
completer_scope(field)
|
97
|
-
.where(@options[:value_filter])
|
98
|
-
.where(value_conditions(field.quoted_field, val))
|
99
|
-
.select(field.quoted_field)
|
100
|
-
.limit(count)
|
101
|
-
.distinct
|
102
|
-
.map(&field.field)
|
103
|
-
.compact
|
104
|
-
.map { |v| v.to_s =~ /\s|\|/ ? "\"#{v.gsub('"', '\"')}\"" : v }
|
105
|
-
end
|
106
|
-
end
|
107
86
|
end
|
108
87
|
|
109
88
|
# Ideally this code belongs to an initializer. The problem is that Katello controllers are not initialized completely until after the end of the to_prepare blocks
|
@@ -115,20 +94,23 @@ module ForemanRhCloud
|
|
115
94
|
if defined?(Katello) && !Foreman.in_setup_db_rake?
|
116
95
|
Katello::Api::V2::OrganizationsController.include Foreman::Controller::SmartProxyAuth
|
117
96
|
# patch the callbacks order for :download_debug_certificate, since local_find_taxonomy has to run after the user is already initialized
|
118
|
-
Katello::Api::V2::OrganizationsController.
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
97
|
+
Katello::Api::V2::OrganizationsController.skip_before_action(:local_find_taxonomy, only: :download_debug_certificate)
|
98
|
+
Katello::Api::V2::OrganizationsController.add_smart_proxy_filters(
|
99
|
+
[:index, :download_debug_certificate],
|
100
|
+
features: ForemanRhCloud.on_prem_smart_proxy_features
|
101
|
+
)
|
102
|
+
Katello::Api::V2::OrganizationsController.before_action(:local_find_taxonomy, only: :download_debug_certificate)
|
103
|
+
|
124
104
|
Katello::Api::V2::RepositoriesController.include Foreman::Controller::SmartProxyAuth
|
125
105
|
# patch the callbacks order for :index, since find_product has to run after the user is already initialized
|
126
|
-
Katello::Api::V2::RepositoriesController.
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
106
|
+
Katello::Api::V2::RepositoriesController.skip_before_action(:find_product, only: :index)
|
107
|
+
Katello::Api::V2::RepositoriesController.skip_before_action(:find_optional_organization, only: :index)
|
108
|
+
Katello::Api::V2::RepositoriesController.add_smart_proxy_filters(
|
109
|
+
:index,
|
110
|
+
features: ForemanRhCloud.on_prem_smart_proxy_features
|
111
|
+
)
|
112
|
+
Katello::Api::V2::RepositoriesController.before_action(:find_product, only: :index)
|
113
|
+
Katello::Api::V2::RepositoriesController.before_action(:find_optional_organization, only: :index)
|
132
114
|
end
|
133
115
|
end
|
134
116
|
|
@@ -13,15 +13,15 @@ module ForemanRhCloud
|
|
13
13
|
|
14
14
|
settings do
|
15
15
|
category(:rh_cloud, N_('Insights')) do
|
16
|
-
setting('allow_auto_inventory_upload', type: :boolean, description: N_('Enable automatic upload of your host inventory to the Red Hat cloud
|
17
|
-
setting('allow_auto_insights_sync', type: :boolean, description: N_('Enable automatic synchronization of Insights recommendations from the Red Hat cloud
|
18
|
-
setting('allow_auto_insights_mismatch_delete', type: :boolean, description: N_('Enable automatic deletion of mismatched host records from the Red Hat cloud
|
19
|
-
setting('obfuscate_inventory_hostnames', type: :boolean, description: N_('Obfuscate host names sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host names are not included in the report.)
|
20
|
-
setting('obfuscate_inventory_ips', type: :boolean, description: N_('Obfuscate ipv4 addresses sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host IPv4 addresses are not included in the report.)
|
21
|
-
setting('exclude_installed_packages', type: :boolean, description: N_('Exclude installed packages from being uploaded to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored and installed packages are always excluded.)
|
22
|
-
setting('include_parameter_tags', type: :boolean, description: N_('Should import include parameter tags from Foreman?
|
23
|
-
setting('rhc_instance_id', type: :string, description: N_('RHC daemon id
|
24
|
-
setting('insights_minimal_data_collection', type: :boolean, default: false, full_name: N_('Minimal data collection'), description: N_('Only include the minimum required data in inventory reports for uploading to Red Hat cloud. When this is true, installed packages are excluded from the report regardless of the exclude_installed_packages setting, and host names and IPv4 addresses are excluded from the report regardless of obfuscation settings.
|
16
|
+
setting('allow_auto_inventory_upload', type: :boolean, description: N_('Enable automatic upload of your host inventory to the Red Hat cloud'), default: true, full_name: N_('Automatic inventory upload'))
|
17
|
+
setting('allow_auto_insights_sync', type: :boolean, description: N_('Enable automatic synchronization of Insights recommendations from the Red Hat cloud'), default: true, full_name: N_('Synchronize recommendations Automatically'))
|
18
|
+
setting('allow_auto_insights_mismatch_delete', type: :boolean, description: N_('Enable automatic deletion of mismatched host records from the Red Hat cloud'), default: false, full_name: N_('Automatic mismatch deletion'))
|
19
|
+
setting('obfuscate_inventory_hostnames', type: :boolean, description: N_('Obfuscate host names sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host names are not included in the report.)'), default: false, full_name: N_('Obfuscate host names'))
|
20
|
+
setting('obfuscate_inventory_ips', type: :boolean, description: N_('Obfuscate ipv4 addresses sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host IPv4 addresses are not included in the report.)'), default: false, full_name: N_('Obfuscate host ipv4 addresses.'))
|
21
|
+
setting('exclude_installed_packages', type: :boolean, description: N_('Exclude installed packages from being uploaded to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored and installed packages are always excluded.)'), default: false, full_name: N_("Exclude installed packages"))
|
22
|
+
setting('include_parameter_tags', type: :boolean, description: N_('Should import include parameter tags from Foreman?'), default: false, full_name: N_('Include parameters in insights-client reports'))
|
23
|
+
setting('rhc_instance_id', type: :string, description: N_('RHC daemon id'), default: nil, full_name: N_('ID of the RHC(Yggdrasil) daemon'))
|
24
|
+
setting('insights_minimal_data_collection', type: :boolean, default: false, full_name: N_('Minimal data collection'), description: N_('Only include the minimum required data in inventory reports for uploading to Red Hat cloud. When this is true, installed packages are excluded from the report regardless of the exclude_installed_packages setting, and host names and IPv4 addresses are excluded from the report regardless of obfuscation settings.'))
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -9,20 +9,22 @@ namespace :rh_cloud_inventory do
|
|
9
9
|
else
|
10
10
|
organizations = [Organization.where(:id => ENV['organization_id']).first]
|
11
11
|
end
|
12
|
+
disconnected = ForemanRhCloud.with_iop_smart_proxy?
|
12
13
|
User.as_anonymous_admin do
|
13
14
|
organizations.each do |organization|
|
14
15
|
ForemanTasks.async_task(
|
15
16
|
ForemanInventoryUpload::Async::GenerateReportJob,
|
16
17
|
ForemanInventoryUpload.generated_reports_folder,
|
17
|
-
organization.id
|
18
|
+
organization.id,
|
19
|
+
disconnected
|
18
20
|
)
|
19
21
|
puts "Generated and uploaded inventory report for organization '#{organization.name}'"
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|
23
25
|
desc 'Generate inventory report to be sent to Red Hat cloud'
|
24
|
-
task generate:
|
25
|
-
|
26
|
+
task generate: :environment do
|
27
|
+
organizations = [ENV['organization_id']]
|
26
28
|
base_folder = ENV['target'] || Dir.pwd
|
27
29
|
filter = ENV['hosts_filter']
|
28
30
|
|
@@ -32,22 +34,36 @@ namespace :rh_cloud_inventory do
|
|
32
34
|
puts "Using #{base_folder} for the output"
|
33
35
|
end
|
34
36
|
|
35
|
-
if
|
37
|
+
if organizations.empty?
|
36
38
|
puts "Must specify organization_id"
|
37
39
|
return
|
38
40
|
end
|
39
41
|
|
40
42
|
User.as_anonymous_admin do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
organizations.each do |organization|
|
44
|
+
target = File.join(base_folder, ForemanInventoryUpload.facts_archive_name(organization, filter))
|
45
|
+
archived_report_generator = ForemanInventoryUpload::Generators::ArchivedReport.new(target, Logger.new(STDOUT))
|
46
|
+
archived_report_generator.render(organization: organization, filter: filter)
|
47
|
+
puts "Successfully generated #{target} for organization id #{organization}"
|
48
|
+
|
49
|
+
next unless ForemanRhCloud.with_iop_smart_proxy?
|
50
|
+
|
51
|
+
puts 'Creating missing insights facets'
|
52
|
+
hosts_without_facets = ForemanInventoryUpload::Generators::Queries.for_org(organization, hosts_query: 'null? insights_uuid')
|
53
|
+
hosts_without_facets.each do |batch|
|
54
|
+
facets = batch.pluck(:id, 'katello_subscription_facets.uuid').map do |host_id, uuid|
|
55
|
+
{
|
56
|
+
host_id: host_id,
|
57
|
+
uuid: uuid,
|
58
|
+
}
|
59
|
+
end
|
60
|
+
# We don't need to validate the facets here as we create the necessary fields.
|
61
|
+
# rubocop:disable Rails/SkipsModelValidations
|
62
|
+
InsightsFacet.upsert_all(facets, unique_by: :host_id) unless facets.empty?
|
63
|
+
# rubocop:enable Rails/SkipsModelValidations
|
64
|
+
end
|
65
|
+
puts 'Missing Insights facets created'
|
49
66
|
end
|
50
|
-
puts "Check the Uploading tab for report uploading status." if Setting[:subscription_connection_enabled]
|
51
67
|
end
|
52
68
|
end
|
53
69
|
desc 'Upload generated inventory report to Red Hat cloud'
|
@@ -55,7 +71,8 @@ namespace :rh_cloud_inventory do
|
|
55
71
|
base_folder = ENV['target'] || ForemanInventoryUpload.generated_reports_folder
|
56
72
|
organization_id = ENV['organization_id']
|
57
73
|
report_file = ForemanInventoryUpload.facts_archive_name(organization_id)
|
58
|
-
|
74
|
+
disconnected = ForemanRhCloud.with_iop_smart_proxy?
|
75
|
+
ForemanTasks.sync_task(ForemanInventoryUpload::Async::QueueForUploadJob, base_folder, report_file, organization_id, disconnected)
|
59
76
|
puts "Uploaded #{report_file}"
|
60
77
|
end
|
61
78
|
end
|