foreman_rh_cloud 12.0.0 → 12.1.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/controllers/concerns/inventory_upload/report_actions.rb +1 -1
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -0
- data/app/controllers/foreman_inventory_upload/uploads_settings_controller.rb +2 -0
- data/app/services/foreman_rh_cloud/cloud_request.rb +4 -0
- data/app/services/foreman_rh_cloud/cloud_request_forwarder.rb +17 -1
- data/app/services/foreman_rh_cloud/rules_ingester.rb +12 -1
- data/config/routes.rb +4 -0
- data/lib/foreman_inventory_upload/generators/queries.rb +2 -0
- data/lib/foreman_inventory_upload/generators/slice.rb +83 -42
- data/lib/foreman_inventory_upload.rb +5 -0
- data/lib/foreman_rh_cloud/engine.rb +15 -3
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/foreman_rh_cloud.rb +2 -0
- data/package.json +1 -1
- data/test/unit/slice_generator_test.rb +212 -4
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +5 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/__snapshots__/Dashboard.test.js.snap +2 -1
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/AdvancedSettingsConstants.js +27 -8
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/AdvancedSetting/index.js +11 -3
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettings.js +71 -10
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/InventorySettingsSelectors.js +13 -1
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/MinimalInventoryDropdown.js +107 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.fixtures.js +9 -2
- data/webpack/ForemanInventoryUpload/Components/NavContainer/NavContainer.js +8 -0
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/NavContainer.test.js +53 -9
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +72 -58
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/PageDescription.test.js +61 -6
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/ToolbarButtons.js +18 -6
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/ToolbarButtons.test.js +54 -6
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.fixtures.js +2 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/ReportGenerate.js +8 -0
- data/webpack/ForemanInventoryUpload/Components/ReportGenerate/__tests__/__snapshots__/ReportGenerate.test.js.snap +4 -2
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/ReportUpload.js +1 -8
- data/webpack/ForemanInventoryUpload/Components/ReportUpload/__tests__/__snapshots__/ReportUpload.test.js.snap +4 -2
- data/webpack/ForemanInventoryUpload/Components/TabHeader/TabHeader.js +47 -28
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/TabHeader.test.js +46 -8
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +2 -7
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +1 -6
- data/webpack/common/Switcher/SwitcherPF4.js +11 -1
- metadata +4 -11
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/InventorySettings.test.js +0 -13
- data/webpack/ForemanInventoryUpload/Components/InventorySettings/__tests__/__snapshots__/InventorySettings.test.js.snap +0 -31
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +0 -89
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/__tests__/__snapshots__/PageDescription.test.js.snap +0 -62
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/ToolbarButtons/__tests__/__snapshots__/ToolbarButtons.test.js.snap +0 -10
- data/webpack/ForemanInventoryUpload/Components/TabHeader/__tests__/__snapshots__/TabHeader.test.js.snap +0 -43
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +0 -72
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc6fa218e9a87166dd1b6ea44dc00f52dc4a0ee28edaa6363bfd74fd0e93c17c
|
4
|
+
data.tar.gz: 80d9b1dcfa4a2e1589d2273b895360d237e84101d0e2a216a18ffc0d9259e14d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e76e623f5509cd2bedab0fcd8abf926d7380eee120d1c73fc7f3be32ec9fe97cfc3948f56e93436ac21431ec8a5f85b4f8f349d1fe5df05bcad9d4e043eb332
|
7
|
+
data.tar.gz: d6f0d6140787ba18bc69bcf4de2161795a4404530fd24bd4502c352d1e87e1d13bd447049b220901edc48f0fbb9fde78ce73b737dea5435fc841d70f6c1a38bf
|
@@ -16,7 +16,7 @@ module InventoryUpload
|
|
16
16
|
|
17
17
|
def report_file(organization_id)
|
18
18
|
filename = ForemanInventoryUpload.facts_archive_name(organization_id)
|
19
|
-
files =
|
19
|
+
files = ForemanInventoryUpload.report_file_paths(organization_id)
|
20
20
|
|
21
21
|
raise ReportMissingError.new(filename: filename) if files.empty?
|
22
22
|
|
@@ -8,12 +8,14 @@ module ForemanInventoryUpload
|
|
8
8
|
labels.map do |id, label|
|
9
9
|
generate_report_status = status_for(id, ForemanInventoryUpload::Async::GenerateReportJob)
|
10
10
|
upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportJob)
|
11
|
+
report_file_paths = ForemanInventoryUpload.report_file_paths(id)
|
11
12
|
|
12
13
|
[
|
13
14
|
label,
|
14
15
|
{
|
15
16
|
generate_report_status: generate_report_status,
|
16
17
|
upload_report_status: upload_report_status,
|
18
|
+
report_file_paths: report_file_paths,
|
17
19
|
id: id,
|
18
20
|
},
|
19
21
|
]
|
@@ -2,7 +2,9 @@ module ForemanInventoryUpload
|
|
2
2
|
class UploadsSettingsController < ::ApplicationController
|
3
3
|
def index
|
4
4
|
render json: {
|
5
|
+
insightsMinimalDataCollection: Setting[:insights_minimal_data_collection],
|
5
6
|
autoUploadEnabled: Setting[:allow_auto_inventory_upload],
|
7
|
+
subscriptionConnectionEnabled: Setting[:subscription_connection_enabled],
|
6
8
|
hostObfuscationEnabled: Setting[:obfuscate_inventory_hostnames],
|
7
9
|
ipsObfuscationEnabled: Setting[:obfuscate_inventory_ips],
|
8
10
|
excludePackagesEnabled: Setting[:exclude_installed_packages],
|
@@ -8,6 +8,10 @@ module ForemanRhCloud
|
|
8
8
|
proxy: ForemanRhCloud.transformed_http_proxy_string,
|
9
9
|
}.deep_merge(params)
|
10
10
|
|
11
|
+
if ForemanRhCloud.with_local_advisor_engine?
|
12
|
+
final_params[:ssl_ca_file] ||= ForemanRhCloud.ca_cert
|
13
|
+
end
|
14
|
+
|
11
15
|
response = RestClient::Request.execute(final_params)
|
12
16
|
|
13
17
|
logger.debug("Response headers for request url #{final_params[:url]} are: #{response.headers}")
|
@@ -34,7 +34,13 @@ module ForemanRhCloud
|
|
34
34
|
),
|
35
35
|
}
|
36
36
|
requested_url = original_request.original_fullpath.end_with?('/') ? original_request.path + '/' : original_request.path
|
37
|
-
|
37
|
+
params = path_params(requested_url, certs)
|
38
|
+
|
39
|
+
if ForemanRhCloud.with_local_advisor_engine?
|
40
|
+
params[:ssl_ca_file] = ForemanRhCloud.ca_cert
|
41
|
+
end
|
42
|
+
|
43
|
+
base_params.merge(params)
|
38
44
|
end
|
39
45
|
|
40
46
|
def prepare_forward_payload(original_request, controller_name)
|
@@ -63,6 +69,12 @@ module ForemanRhCloud
|
|
63
69
|
|
64
70
|
def path_params(request_path, certs)
|
65
71
|
case request_path
|
72
|
+
when lightspeed?
|
73
|
+
{
|
74
|
+
url: ForemanRhCloud.cert_base_url + request_path,
|
75
|
+
ssl_client_cert: OpenSSL::X509::Certificate.new(certs[:cert]),
|
76
|
+
ssl_client_key: OpenSSL::PKey.read(certs[:key]),
|
77
|
+
}
|
66
78
|
when platform_request?
|
67
79
|
{
|
68
80
|
url: ForemanRhCloud.cert_base_url + request_path.sub('/redhat_access/r/insights/platform', '/api'),
|
@@ -95,6 +107,10 @@ module ForemanRhCloud
|
|
95
107
|
headers
|
96
108
|
end
|
97
109
|
|
110
|
+
def lightspeed?
|
111
|
+
->(request_path) { request_path.include? '/lightspeed' }
|
112
|
+
end
|
113
|
+
|
98
114
|
def platform_request?
|
99
115
|
->(request_path) { request_path.include? '/platform' }
|
100
116
|
end
|
@@ -13,7 +13,18 @@ module ForemanRhCloud
|
|
13
13
|
|
14
14
|
def fetch_rules_data
|
15
15
|
advisor_url = "#{ForemanRhCloud.on_premise_url}/r/insights/v1/static/release/content.json"
|
16
|
-
|
16
|
+
uri = URI.parse(advisor_url)
|
17
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
18
|
+
http.use_ssl = true
|
19
|
+
|
20
|
+
# Set CA certificate
|
21
|
+
http.ca_file = ForemanRhCloud.ca_cert
|
22
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
23
|
+
|
24
|
+
request = Net::HTTP::Get.new(uri.request_uri)
|
25
|
+
|
26
|
+
response = http.request(request)
|
27
|
+
JSON.parse(response.body, symbolize_names: true)
|
17
28
|
end
|
18
29
|
|
19
30
|
def fetch_rules_and_resolutions
|
data/config/routes.rb
CHANGED
@@ -49,6 +49,10 @@ Rails.application.routes.draw do
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
52
|
+
scope :module => :'insights_cloud/api' do
|
53
|
+
match '/api/lightspeed/*path', to: 'machine_telemetries#forward_request', via: :all
|
54
|
+
end
|
55
|
+
|
52
56
|
# API routes
|
53
57
|
|
54
58
|
namespace :api, :defaults => { :format => 'json' } do
|
@@ -50,56 +50,97 @@ module ForemanInventoryUpload
|
|
50
50
|
@stream.simple_field('success', ActiveModel::Type::Boolean.new.cast(fact_value(host, 'conversions::success')), :last)
|
51
51
|
end
|
52
52
|
|
53
|
+
def insights_minimal_data_collection(host)
|
54
|
+
@stream.simple_field('account', account_id(host.organization).to_s)
|
55
|
+
@stream.simple_field('subscription_manager_id', uuid_value!(host.subscription_facet&.uuid))
|
56
|
+
@stream.simple_field('insights_id', uuid_value(fact_value(host, 'insights_id')))
|
57
|
+
@stream.simple_field('bios_uuid', bios_uuid(host))
|
58
|
+
@stream.simple_field('bios_vendor', fact_value(host, 'dmi::bios::vendor'))
|
59
|
+
@stream.simple_field('bios_version', fact_value(host, 'dmi::bios::version'))
|
60
|
+
@stream.simple_field('arch', host.architecture&.name)
|
61
|
+
@stream.simple_field(
|
62
|
+
'infrastructure_type',
|
63
|
+
ActiveModel::Type::Boolean.new.cast(fact_value(host, 'virt::is_guest')) ? 'virtual' : 'physical'
|
64
|
+
)
|
65
|
+
@stream.object_field('system_profile') do
|
66
|
+
unless (installed_products = host.subscription_facet&.installed_products).empty?
|
67
|
+
@stream.array_field('installed_products') do
|
68
|
+
@stream.raw(installed_products.map do |product|
|
69
|
+
{
|
70
|
+
'name': product.name,
|
71
|
+
'id': product.cp_product_id,
|
72
|
+
}.to_json
|
73
|
+
end.join(', '))
|
74
|
+
end
|
75
|
+
end
|
76
|
+
@stream.simple_field('cores_per_socket', fact_value(host, 'cpu::core(s)_per_socket')) { |v| v.to_i } if fact_value(host, 'cpu::core(s)_per_socket').present?
|
77
|
+
@stream.simple_field('system_memory_bytes', fact_value(host, 'memory::memtotal')) { |v| kilobytes_to_bytes(v.to_i) } if fact_value(host, 'memory::memtotal').present?
|
78
|
+
@stream.simple_field('number_of_cpus', fact_value(host, 'cpu::cpu(s)')) { |v| v.to_i } if fact_value(host, 'cpu::cpu(s)').present?
|
79
|
+
@stream.simple_field('number_of_sockets', fact_value(host, 'cpu::cpu_socket(s)'), :last) { |v| v.to_i } if fact_value(host, 'cpu::cpu_socket(s)').present?
|
80
|
+
end
|
81
|
+
if host.subscription_facet.hypervisor?
|
82
|
+
@stream.simple_field('cpu_socket(s)', fact_value(host, 'cpu::cpu_socket(s)'))
|
83
|
+
@stream.simple_field('hypervisor_type', fact_value(host, 'hypervisor::type'))
|
84
|
+
@stream.simple_field('hypervisor_version', fact_value(host, 'hypervisor::version'), :last)
|
85
|
+
else
|
86
|
+
@stream.simple_field('cpu_socket(s)', fact_value(host, 'cpu::cpu_socket(s)'), :last)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
53
90
|
def report_host(host)
|
54
91
|
host_ips_cache = host_ips(host)
|
55
92
|
@stream.object do
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
@stream.
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
93
|
+
if Setting[:insights_minimal_data_collection]
|
94
|
+
insights_minimal_data_collection(host)
|
95
|
+
else
|
96
|
+
@stream.simple_field('fqdn', fqdn(host))
|
97
|
+
@stream.simple_field('account', account_id(host.organization).to_s)
|
98
|
+
@stream.simple_field('subscription_manager_id', uuid_value!(host.subscription_facet&.uuid))
|
99
|
+
@stream.simple_field('satellite_id', uuid_value!(host.subscription_facet&.uuid))
|
100
|
+
if host.subscription_facet&.convert2rhel_through_foreman.present?
|
101
|
+
@stream.object_field('conversions') do
|
102
|
+
@stream.object_field('source_os') do
|
103
|
+
@stream.simple_field('name', fact_value(host, 'conversions::source_os::name'))
|
104
|
+
@stream.simple_field('version', fact_value(host, 'conversions::source_os::version') || 'Unknown - Fact not reported', :last)
|
105
|
+
end
|
106
|
+
@stream.object_field('target_os') do
|
107
|
+
@stream.simple_field('name', fact_value(host, 'conversions::target_os::name'))
|
108
|
+
@stream.simple_field('version', fact_value(host, 'conversions::target_os::version') || 'Unknown - Fact not reported', :last)
|
109
|
+
end
|
110
|
+
report_conversions(host)
|
69
111
|
end
|
70
|
-
report_conversions(host)
|
71
112
|
end
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
report_system_profile(host, host_ips_cache)
|
80
|
-
end
|
81
|
-
@stream.array_field('facts') do
|
82
|
-
@stream.object do
|
83
|
-
@stream.simple_field('namespace', SATELLITE_NAMESPACE)
|
84
|
-
@stream.object_field('facts', :last) do
|
85
|
-
report_satellite_facts(host)
|
86
|
-
end
|
113
|
+
@stream.simple_field('bios_uuid', bios_uuid(host))
|
114
|
+
@stream.simple_field('vm_uuid', uuid_value(fact_value(host, 'virt::uuid')))
|
115
|
+
@stream.simple_field('insights_id', uuid_value(fact_value(host, 'insights_id')))
|
116
|
+
report_ip_addresses(host, host_ips_cache)
|
117
|
+
report_mac_addresses(host)
|
118
|
+
@stream.object_field('system_profile') do
|
119
|
+
report_system_profile(host, host_ips_cache)
|
87
120
|
end
|
88
|
-
end
|
89
121
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
122
|
+
@stream.array_field('facts') do
|
123
|
+
@stream.object do
|
124
|
+
@stream.simple_field('namespace', SATELLITE_NAMESPACE)
|
125
|
+
@stream.object_field('facts', :last) do
|
126
|
+
report_satellite_facts(host)
|
127
|
+
end
|
128
|
+
end
|
96
129
|
end
|
97
130
|
|
98
|
-
tags
|
99
|
-
|
100
|
-
|
101
|
-
key, value
|
102
|
-
|
131
|
+
@stream.array_field('tags', :last) do
|
132
|
+
tags_generator = Tags.new(host)
|
133
|
+
host_params_tags = tags_generator.generate_parameters
|
134
|
+
host_params_tags.each do |key, value|
|
135
|
+
report_tag(SATELLITE_PARAMS_NAMESPACE, key, value)
|
136
|
+
end
|
137
|
+
|
138
|
+
tags = tags_generator.generate
|
139
|
+
last_index = tags.count - 1
|
140
|
+
tags.each_with_index do |pair, index|
|
141
|
+
key, value = pair
|
142
|
+
report_tag(SATELLITE_NAMESPACE, key, value, index == last_index)
|
143
|
+
end
|
103
144
|
end
|
104
145
|
end
|
105
146
|
end
|
@@ -165,7 +206,7 @@ module ForemanInventoryUpload
|
|
165
206
|
end.join(', '))
|
166
207
|
end
|
167
208
|
end
|
168
|
-
|
209
|
+
if !Setting[:insights_minimal_data_collection] && !Setting[:exclude_installed_packages]
|
169
210
|
@stream.array_field('installed_packages') do
|
170
211
|
first = true
|
171
212
|
host.installed_packages.each do |package|
|
@@ -30,6 +30,11 @@ module ForemanInventoryUpload
|
|
30
30
|
File.join(ForemanInventoryUpload.done_folder, filename)
|
31
31
|
end
|
32
32
|
|
33
|
+
def self.report_file_paths(organization_id)
|
34
|
+
filename = facts_archive_name(organization_id)
|
35
|
+
Dir[ForemanInventoryUpload.uploads_file_path(filename), ForemanInventoryUpload.done_file_path(filename)]
|
36
|
+
end
|
37
|
+
|
33
38
|
def self.generated_reports_folder
|
34
39
|
@generated_reports_folder ||= ensure_folder(
|
35
40
|
File.join(
|
@@ -44,11 +44,12 @@ module ForemanRhCloud
|
|
44
44
|
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'))
|
45
45
|
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'))
|
46
46
|
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'))
|
47
|
-
setting('obfuscate_inventory_hostnames', type: :boolean, description: N_('Obfuscate host names sent to the Red Hat cloud'), default: false, full_name: N_('Obfuscate host names'))
|
48
|
-
setting('obfuscate_inventory_ips', type: :boolean, description: N_('Obfuscate ipv4 addresses sent to the Red Hat cloud'), default: false, full_name: N_('Obfuscate host ipv4 addresses'))
|
49
|
-
setting('exclude_installed_packages', type: :boolean, description: N_('Exclude installed packages from being uploaded to the Red Hat cloud'), default: false, full_name: N_("Exclude installed
|
47
|
+
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 and host names are always obfuscated.)'), default: false, full_name: N_('Obfuscate host names'))
|
48
|
+
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 and host ipv4 addresses are always obfuscated.)'), default: false, full_name: N_('Obfuscate host ipv4 addresses.'))
|
49
|
+
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"))
|
50
50
|
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'))
|
51
51
|
setting('rhc_instance_id', type: :string, description: N_('RHC daemon id'), default: nil, full_name: N_('ID of the RHC(Yggdrasil) daemon'))
|
52
|
+
setting('insights_minimal_data_collection', type: :boolean, default: false, full_name: N_('Minimal data collection'), description: N_('Only send the minimum required data to Red Hat cloud, and obfuscate wherever possible. When this is true, hostnames and IPv4 addresses are always obfuscated and installed packages are excluded, regardless of those settings.'))
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
@@ -212,4 +213,15 @@ module ForemanRhCloud
|
|
212
213
|
def self.with_local_advisor_engine?
|
213
214
|
SETTINGS.dig(:foreman_rh_cloud, :use_local_advisor_engine) || false
|
214
215
|
end
|
216
|
+
|
217
|
+
def self.ca_cert
|
218
|
+
# The reference to candlepin ca_cert_file can be removed
|
219
|
+
# once the setting is dropped. Foreman 3.15 introduces
|
220
|
+
# a single CA file that bundles all CAs.
|
221
|
+
if ::SETTINGS.dig(:katello, :candlepin, :ca_cert_file)
|
222
|
+
::SETTINGS[:katello][:candlepin][:ca_cert_file]
|
223
|
+
else
|
224
|
+
::SETTINGS[:ssl_ca_file]
|
225
|
+
end
|
226
|
+
end
|
215
227
|
end
|
data/lib/foreman_rh_cloud.rb
CHANGED
data/package.json
CHANGED
@@ -35,6 +35,12 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
35
35
|
ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
|
36
36
|
end
|
37
37
|
|
38
|
+
def create_fact_values(host, facts)
|
39
|
+
facts.each do |fact_name, value|
|
40
|
+
FactoryBot.create(:fact_value, fact_name: fact_names[fact_name], value: value, host: host)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
38
44
|
def interesting_facts
|
39
45
|
[
|
40
46
|
'dmi::system::uuid',
|
@@ -52,6 +58,8 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
52
58
|
'distribution::version',
|
53
59
|
'distribution::id',
|
54
60
|
'virt::is_guest',
|
61
|
+
'hypervisor::type',
|
62
|
+
'hypervisor::version',
|
55
63
|
'dmi::system::manufacturer',
|
56
64
|
'dmi::system::product_name',
|
57
65
|
'dmi::chassis::asset_tag',
|
@@ -98,10 +106,210 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
98
106
|
assert_equal 'test_nic1', actual_nic['name']
|
99
107
|
end
|
100
108
|
|
109
|
+
test 'generates a report with minimal data collection' do
|
110
|
+
Setting[:insights_minimal_data_collection] = true
|
111
|
+
create_fact_values(@host,
|
112
|
+
'dmi::system::uuid' => 'D30B0B42-7824-2635-C62D-491394DE43F7',
|
113
|
+
'dmi::bios::vendor' => 'SeaBios',
|
114
|
+
'dmi::bios::version' => '10',
|
115
|
+
'cpu::cpu_socket(s)' => '2',
|
116
|
+
'cpu::cpu(s)' => '4',
|
117
|
+
'cpu::core(s)_per_socket' => '1',
|
118
|
+
'memory::memtotal' => '1024',
|
119
|
+
'insights_id' => '00000000-0073-0400-0000-000000000000')
|
120
|
+
|
121
|
+
batch = Host.where(id: @host.id).in_batches.first
|
122
|
+
generator = create_generator(batch)
|
123
|
+
|
124
|
+
json_str = generator.render
|
125
|
+
actual = JSON.parse(json_str.join("\n"))
|
126
|
+
|
127
|
+
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
128
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
129
|
+
assert_equal 1, generator.hosts_count
|
130
|
+
assert_equal '1234', actual_host['account']
|
131
|
+
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
132
|
+
assert_not_nil actual_host['subscription_manager_id']
|
133
|
+
assert_equal 'D30B0B42-7824-2635-C62D-491394DE43F7', actual_host['bios_uuid']
|
134
|
+
assert_equal '00000000-0073-0400-0000-000000000000', actual_host['insights_id']
|
135
|
+
assert_equal 4, actual_system_profile['number_of_cpus']
|
136
|
+
assert_equal 2, actual_system_profile['number_of_sockets']
|
137
|
+
assert_equal 1_048_576, actual_system_profile['system_memory_bytes']
|
138
|
+
assert_equal 1, actual_system_profile['cores_per_socket']
|
139
|
+
assert_equal 'SeaBios', actual_host['bios_vendor']
|
140
|
+
assert_equal '10', actual_host['bios_version']
|
141
|
+
assert_equal '2', actual_host['cpu_socket(s)']
|
142
|
+
# Assert exclusion of non-minimal data collection fact
|
143
|
+
assert_nil actual_host['ip_addresses']
|
144
|
+
assert_nil actual_host['mac_addresses']
|
145
|
+
assert_nil actual_host['fqdn']
|
146
|
+
end
|
147
|
+
|
148
|
+
test 'generates a report with minimal data collection for a hypervisor' do
|
149
|
+
Setting[:insights_minimal_data_collection] = true
|
150
|
+
create_fact_values(@host,
|
151
|
+
'dmi::system::uuid' => 'D30B0B42-7824-2635-C62D-491394DE43F7',
|
152
|
+
'hypervisor::type' => 'VMware',
|
153
|
+
'hypervisor::version' => '6.7',
|
154
|
+
'cpu::cpu_socket(s)' => '2',
|
155
|
+
'cpu::cpu(s)' => '4',
|
156
|
+
'cpu::core(s)_per_socket' => '1',
|
157
|
+
'memory::memtotal' => '1024')
|
158
|
+
|
159
|
+
@host.subscription_facet.hypervisor = true
|
160
|
+
@host.subscription_facet.save!
|
161
|
+
|
162
|
+
batch = Host.where(id: @host.id).in_batches.first
|
163
|
+
generator = create_generator(batch)
|
164
|
+
|
165
|
+
json_str = generator.render
|
166
|
+
actual = JSON.parse(json_str.join("\n"))
|
167
|
+
|
168
|
+
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
169
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
170
|
+
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
171
|
+
assert_equal 'D30B0B42-7824-2635-C62D-491394DE43F7', actual_host['bios_uuid']
|
172
|
+
assert_equal 'VMware', actual_host['hypervisor_type']
|
173
|
+
assert_equal '6.7', actual_host['hypervisor_version']
|
174
|
+
assert_equal '2', actual_host['cpu_socket(s)']
|
175
|
+
assert_equal 4, actual_system_profile['number_of_cpus']
|
176
|
+
assert_equal 2, actual_system_profile['number_of_sockets']
|
177
|
+
assert_equal 1_048_576, actual_system_profile['system_memory_bytes']
|
178
|
+
assert_equal 1, actual_system_profile['cores_per_socket']
|
179
|
+
assert_equal 1, generator.hosts_count
|
180
|
+
# Assert exclusion of non-minimal data collection facts
|
181
|
+
assert_nil actual_host['ip_addresses']
|
182
|
+
assert_nil actual_host['mac_addresses']
|
183
|
+
assert_nil actual_host['fqdn']
|
184
|
+
assert true, @host.subscription_facet.hypervisor?
|
185
|
+
end
|
186
|
+
|
187
|
+
test 'packages are excluded in the report with minimal data collection' do
|
188
|
+
Setting[:exclude_installed_packages] = false
|
189
|
+
Setting[:insights_minimal_data_collection] = true
|
190
|
+
|
191
|
+
installed_package = ::Katello::InstalledPackage.create(name: 'test-package', nvrea: 'test-package-1.0.x86_64', nvra: 'test-package-1.0.x86_64')
|
192
|
+
another_host = FactoryBot.create(
|
193
|
+
:host,
|
194
|
+
:with_subscription,
|
195
|
+
:with_content,
|
196
|
+
content_view: @host.content_views.first,
|
197
|
+
lifecycle_environment: @host.lifecycle_environments.first,
|
198
|
+
organization: @host.organization,
|
199
|
+
installed_packages: [installed_package]
|
200
|
+
)
|
201
|
+
create_fact_values(another_host,
|
202
|
+
'dmi::system::uuid' => 'D30B0B42-7824-2635-C62D-491394DE43F7',
|
203
|
+
'dmi::bios::vendor' => 'SeaBios',
|
204
|
+
'dmi::bios::version' => '10',
|
205
|
+
'cpu::cpu_socket(s)' => '2',
|
206
|
+
'cpu::cpu(s)' => '4',
|
207
|
+
'cpu::core(s)_per_socket' => '1',
|
208
|
+
'memory::memtotal' => '1024')
|
209
|
+
|
210
|
+
batch = Host.where(id: another_host.id).in_batches.first
|
211
|
+
generator = create_generator(batch)
|
212
|
+
|
213
|
+
json_str = generator.render
|
214
|
+
actual = JSON.parse(json_str.join("\n"))
|
215
|
+
|
216
|
+
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
217
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
218
|
+
assert_not_nil(actual_host['system_profile'])
|
219
|
+
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
220
|
+
assert_not_nil actual_host['subscription_manager_id']
|
221
|
+
assert_equal 'D30B0B42-7824-2635-C62D-491394DE43F7', actual_host['bios_uuid']
|
222
|
+
assert_equal 4, actual_system_profile['number_of_cpus']
|
223
|
+
assert_equal 2, actual_system_profile['number_of_sockets']
|
224
|
+
assert_equal 1_048_576, actual_system_profile['system_memory_bytes']
|
225
|
+
assert_equal 1, actual_system_profile['cores_per_socket']
|
226
|
+
assert_equal 'SeaBios', actual_host['bios_vendor']
|
227
|
+
assert_equal '10', actual_host['bios_version']
|
228
|
+
assert_equal '2', actual_host['cpu_socket(s)']
|
229
|
+
assert_nil actual_host['installed_packages']
|
230
|
+
end
|
231
|
+
|
232
|
+
test 'generates a report with minimal data collection with ip setting overridden' do
|
233
|
+
Setting[:insights_minimal_data_collection] = true
|
234
|
+
Setting[:obfuscate_inventory_ips] = false
|
235
|
+
create_fact_values(@host,
|
236
|
+
'dmi::system::uuid' => 'D30B0B42-7824-2635-C62D-491394DE43F7',
|
237
|
+
'dmi::bios::vendor' => 'SeaBios',
|
238
|
+
'dmi::bios::version' => '10',
|
239
|
+
'cpu::cpu_socket(s)' => '2',
|
240
|
+
'cpu::cpu(s)' => '4',
|
241
|
+
'cpu::core(s)_per_socket' => '1',
|
242
|
+
'memory::memtotal' => '1024')
|
243
|
+
|
244
|
+
batch = Host.where(id: @host.id).in_batches.first
|
245
|
+
generator = create_generator(batch)
|
246
|
+
|
247
|
+
json_str = generator.render
|
248
|
+
actual = JSON.parse(json_str.join("\n"))
|
249
|
+
|
250
|
+
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
251
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
252
|
+
assert_equal 1, generator.hosts_count
|
253
|
+
assert_not_nil(actual_host['system_profile'])
|
254
|
+
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
255
|
+
assert_not_nil actual_host['subscription_manager_id']
|
256
|
+
assert_equal 'D30B0B42-7824-2635-C62D-491394DE43F7', actual_host['bios_uuid']
|
257
|
+
assert_equal 4, actual_system_profile['number_of_cpus']
|
258
|
+
assert_equal 2, actual_system_profile['number_of_sockets']
|
259
|
+
assert_equal 1_048_576, actual_system_profile['system_memory_bytes']
|
260
|
+
assert_equal 1, actual_system_profile['cores_per_socket']
|
261
|
+
assert_equal 'SeaBios', actual_host['bios_vendor']
|
262
|
+
assert_equal '10', actual_host['bios_version']
|
263
|
+
assert_equal '2', actual_host['cpu_socket(s)']
|
264
|
+
# Assert exclusion of non-minimal data collection fact
|
265
|
+
assert_nil actual_host['ip_addresses']
|
266
|
+
assert_nil actual_host['mac_addresses']
|
267
|
+
assert_nil actual_host['fqdn']
|
268
|
+
end
|
269
|
+
|
270
|
+
test 'generates a report with minimal data collection with fqdn setting overridden' do
|
271
|
+
Setting[:insights_minimal_data_collection] = true
|
272
|
+
Setting[:obfuscate_inventory_hostnames] = false
|
273
|
+
create_fact_values(@host,
|
274
|
+
'dmi::system::uuid' => 'D30B0B42-7824-2635-C62D-491394DE43F7',
|
275
|
+
'dmi::bios::vendor' => 'SeaBios',
|
276
|
+
'dmi::bios::version' => '10',
|
277
|
+
'cpu::cpu_socket(s)' => '2',
|
278
|
+
'cpu::cpu(s)' => '4',
|
279
|
+
'cpu::core(s)_per_socket' => '1',
|
280
|
+
'memory::memtotal' => '1024')
|
281
|
+
|
282
|
+
batch = Host.where(id: @host.id).in_batches.first
|
283
|
+
generator = create_generator(batch)
|
284
|
+
|
285
|
+
json_str = generator.render
|
286
|
+
actual = JSON.parse(json_str.join("\n"))
|
287
|
+
|
288
|
+
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
289
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
290
|
+
assert_not_nil(actual_host['system_profile'])
|
291
|
+
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
292
|
+
assert_not_nil actual_host['subscription_manager_id']
|
293
|
+
assert_equal 'D30B0B42-7824-2635-C62D-491394DE43F7', actual_host['bios_uuid']
|
294
|
+
assert_equal 4, actual_system_profile['number_of_cpus']
|
295
|
+
assert_equal 2, actual_system_profile['number_of_sockets']
|
296
|
+
assert_equal 1_048_576, actual_system_profile['system_memory_bytes']
|
297
|
+
assert_equal 1, actual_system_profile['cores_per_socket']
|
298
|
+
assert_equal 'SeaBios', actual_host['bios_vendor']
|
299
|
+
assert_equal '10', actual_host['bios_version']
|
300
|
+
assert_equal '2', actual_host['cpu_socket(s)']
|
301
|
+
# Assert exclusion of non-minimal data collection fact
|
302
|
+
assert_nil actual_host['ip_addresses']
|
303
|
+
assert_nil actual_host['mac_addresses']
|
304
|
+
assert_nil actual_host['fqdn']
|
305
|
+
assert_equal 1, generator.hosts_count
|
306
|
+
end
|
307
|
+
|
101
308
|
test 'hosts report fields should be present if fact exist' do
|
102
|
-
|
103
|
-
|
104
|
-
|
309
|
+
create_fact_values(@host,
|
310
|
+
'cpu::cpu(s)' => '4',
|
311
|
+
'cpu::cpu_socket(s)' => '2',
|
312
|
+
'cpu::core(s)_per_socket' => '1')
|
105
313
|
|
106
314
|
batch = Host.where(id: @host.id).in_batches.first
|
107
315
|
generator = create_generator(batch)
|
@@ -704,7 +912,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
704
912
|
end
|
705
913
|
|
706
914
|
test 'passes valid bios_uuid field' do
|
707
|
-
|
915
|
+
create_fact_values(@host, 'dmi::system::uuid' => 'D30B0B42-7824-2635-C62D-491394DE43F7')
|
708
916
|
|
709
917
|
batch = Host.where(id: @host.id).in_batches.first
|
710
918
|
generator = create_generator(batch)
|
@@ -49,6 +49,7 @@ class Dashboard extends React.Component {
|
|
49
49
|
showFullScreen,
|
50
50
|
activeTab,
|
51
51
|
} = this.props;
|
52
|
+
const downloadButtonDisabled = () => account.report_file_paths.length === 0;
|
52
53
|
return (
|
53
54
|
<NavContainer
|
54
55
|
items={[
|
@@ -60,6 +61,8 @@ class Dashboard extends React.Component {
|
|
60
61
|
...generating,
|
61
62
|
restartProcess: this.handleRestart,
|
62
63
|
exitCode: account.generate_report_status,
|
64
|
+
downloadReports: this.handleDownload,
|
65
|
+
downloadButtonDisabled,
|
63
66
|
toggleFullScreen: this.handleToggleFullScreen,
|
64
67
|
},
|
65
68
|
onClick: () => this.handleTabChange('generating'),
|
@@ -70,7 +73,6 @@ class Dashboard extends React.Component {
|
|
70
73
|
component: ReportUpload,
|
71
74
|
props: {
|
72
75
|
...uploading,
|
73
|
-
downloadReports: this.handleDownload,
|
74
76
|
exitCode: account.upload_report_status,
|
75
77
|
toggleFullScreen: this.handleToggleFullScreen,
|
76
78
|
},
|
@@ -117,6 +119,7 @@ Dashboard.propTypes = {
|
|
117
119
|
account: PropTypes.shape({
|
118
120
|
generate_report_status: PropTypes.string,
|
119
121
|
upload_report_status: PropTypes.string,
|
122
|
+
report_file_paths: PropTypes.arrayOf(PropTypes.string),
|
120
123
|
}),
|
121
124
|
showFullScreen: PropTypes.bool,
|
122
125
|
toggleFullScreen: PropTypes.func,
|
@@ -136,6 +139,7 @@ Dashboard.defaultProps = {
|
|
136
139
|
account: {
|
137
140
|
generate_report_status: 'unknown',
|
138
141
|
upload_report_status: 'unknown',
|
142
|
+
report_file_paths: [],
|
139
143
|
},
|
140
144
|
showFullScreen: false,
|
141
145
|
toggleFullScreen: noop,
|