foreman_rh_cloud 13.2.1 → 14.0.2
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/lib/foreman_inventory_upload/generators/fact_helpers.rb +0 -8
- data/lib/foreman_inventory_upload/generators/queries.rb +1 -1
- data/lib/foreman_inventory_upload/generators/slice.rb +1 -1
- data/lib/foreman_inventory_upload.rb +23 -8
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/package.json +1 -1
- data/test/controllers/insights_cloud/api/machine_telemetries_controller_test.rb +1 -1
- data/test/jobs/inventory_full_sync_test.rb +4 -7
- data/test/jobs/inventory_hosts_sync_test.rb +5 -7
- data/test/jobs/inventory_self_host_sync_test.rb +1 -1
- data/test/unit/archived_report_generator_test.rb +1 -2
- data/test/unit/fact_helpers_test.rb +0 -16
- 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 +1 -1
- data/test/unit/slice_generator_test.rb +2 -21
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/PageDescription/PageDescription.js +3 -1
- data/webpack/ForemanInventoryUpload/ForemanInventoryHelpers.js +7 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8eb6a1e3cb928ad1aabeca2ddd577f311eb022578dd7ca781e890b28e7108736
|
|
4
|
+
data.tar.gz: 562bf4c8074e87420d54d496ab67f69301a40b01600df53c6c715010db951e7a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 64e5d4ccc30a3c6036615e2f429be90f609102e9bbd6d714f6264d22e515d32b6fb825ca9155136a53cb9545ac8d9d8a5a0e7b34cd586dd1ec5c2c18c138d98c
|
|
7
|
+
data.tar.gz: c1c2d4224a9234278354d3cc1a98b8d3d966a3088870c89a84e94fad001e6d0bc3b93f28c76edb7ef617585989b9e66e830d1b6d030464bb5e190408e18d1525
|
|
@@ -28,14 +28,6 @@ module ForemanInventoryUpload
|
|
|
28
28
|
@organization_accounts[organization.id] ||= organization.pools.where.not(account_number: nil).pluck(:account_number).first
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
def golden_ticket?(organization)
|
|
32
|
-
result = organization.try(:golden_ticket?)
|
|
33
|
-
result = organization.content_access_mode == 'org_environment' if result.nil?
|
|
34
|
-
|
|
35
|
-
@organization_golden_tickets ||= {}
|
|
36
|
-
@organization_golden_tickets[organization.id] ||= result
|
|
37
|
-
end
|
|
38
|
-
|
|
39
31
|
def cloud_provider(host)
|
|
40
32
|
bios_version = fact_value(host, 'dmi::bios::version')
|
|
41
33
|
|
|
@@ -230,7 +230,7 @@ module ForemanInventoryUpload
|
|
|
230
230
|
@stream.simple_field('system_purpose_sla', host.subscription_facet.service_level)
|
|
231
231
|
@stream.simple_field('distribution_version', fact_value(host, 'distribution::version'))
|
|
232
232
|
@stream.simple_field('satellite_instance_id', Foreman.try(:instance_id))
|
|
233
|
-
@stream.simple_field('is_simple_content_access',
|
|
233
|
+
@stream.simple_field('is_simple_content_access', true)
|
|
234
234
|
@stream.simple_field('is_hostname_obfuscated', !!obfuscate_hostname?(host))
|
|
235
235
|
@stream.simple_field('organization_id', host.organization_id, :last)
|
|
236
236
|
end
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
module ForemanInventoryUpload
|
|
2
2
|
def self.base_folder
|
|
3
3
|
# in production setup, where selinux is enabled, we only have rights to
|
|
4
|
-
# create folders under /
|
|
5
|
-
# a dev setup, where we can use
|
|
4
|
+
# create folders under /var/lib/foreman. If the folder does not exist, it's
|
|
5
|
+
# a dev setup, where we can use the parent of the current working directory
|
|
6
6
|
@base_folder ||= File.join(
|
|
7
|
-
Dir.glob('/var/lib/foreman').first || Dir.getwd,
|
|
7
|
+
Dir.glob('/var/lib/foreman').first || File.dirname(Dir.getwd),
|
|
8
8
|
'red_hat_inventory/'
|
|
9
9
|
)
|
|
10
10
|
end
|
|
@@ -30,11 +30,6 @@ 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
|
-
|
|
38
33
|
def self.generated_reports_folder
|
|
39
34
|
@generated_reports_folder ||= ensure_folder(
|
|
40
35
|
File.join(
|
|
@@ -44,6 +39,26 @@ module ForemanInventoryUpload
|
|
|
44
39
|
)
|
|
45
40
|
end
|
|
46
41
|
|
|
42
|
+
def self.generated_reports_file_path(filename)
|
|
43
|
+
File.join(ForemanInventoryUpload.generated_reports_folder, filename)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.report_file_paths(organization_id)
|
|
47
|
+
filename = facts_archive_name(organization_id)
|
|
48
|
+
# Report files start in generated
|
|
49
|
+
# They are then MOVED (not copied) to uploads, then done.
|
|
50
|
+
# When they are moved to the new folder, they overwrite any file with the same name.
|
|
51
|
+
# If it's a generate-only, it will be in generated
|
|
52
|
+
# Failed or incomplete uploads will be in uploads
|
|
53
|
+
# Completed uploads will be in done
|
|
54
|
+
# The ordering here ensures we get the correct file path every time.
|
|
55
|
+
Dir[
|
|
56
|
+
ForemanInventoryUpload.generated_reports_file_path(filename),
|
|
57
|
+
ForemanInventoryUpload.uploads_file_path(filename),
|
|
58
|
+
ForemanInventoryUpload.done_file_path(filename),
|
|
59
|
+
]
|
|
60
|
+
end
|
|
61
|
+
|
|
47
62
|
def self.outputs_folder
|
|
48
63
|
@outputs_folder ||= ensure_folder(File.join(ForemanInventoryUpload.base_folder, 'outputs/'))
|
|
49
64
|
end
|
data/package.json
CHANGED
|
@@ -192,7 +192,7 @@ module InsightsCloud::Api
|
|
|
192
192
|
organization: env.organization
|
|
193
193
|
)
|
|
194
194
|
|
|
195
|
-
@host.
|
|
195
|
+
@host.organization.pools << FactoryBot.create(:katello_pool, account_number: '5678', cp_id: 1)
|
|
196
196
|
|
|
197
197
|
uuid = @host.subscription_facet.uuid
|
|
198
198
|
|
|
@@ -27,7 +27,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
|
27
27
|
|
|
28
28
|
pool = FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
|
|
29
29
|
|
|
30
|
-
@host1.
|
|
30
|
+
@host1.organization.pools << pool
|
|
31
31
|
|
|
32
32
|
# this host would pass our plugin queries, so it could be uploaded to the cloud.
|
|
33
33
|
@host2 = FactoryBot.create(
|
|
@@ -39,7 +39,6 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
|
39
39
|
organization: env.organization
|
|
40
40
|
)
|
|
41
41
|
|
|
42
|
-
@host2.subscription_facet.pools << pool
|
|
43
42
|
@host2_inventory_id = '4536bf5c-ff03-4154-a8c9-32ff4b40e40c'
|
|
44
43
|
|
|
45
44
|
# this host would pass our plugin queries, so it could be uploaded to the cloud.
|
|
@@ -52,8 +51,6 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
|
52
51
|
organization: env.organization
|
|
53
52
|
)
|
|
54
53
|
|
|
55
|
-
@host3.subscription_facet.pools << pool
|
|
56
|
-
|
|
57
54
|
ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
|
|
58
55
|
|
|
59
56
|
inventory_json = <<-INVENTORY_JSON
|
|
@@ -88,7 +85,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
|
88
85
|
"facts": {
|
|
89
86
|
"virtual_host_name": "virt-who-nobody.home-1",
|
|
90
87
|
"satellite_instance_id": "fc4d0cb0-a0b0-421e-b096-b028319b8e47",
|
|
91
|
-
"is_simple_content_access":
|
|
88
|
+
"is_simple_content_access": true,
|
|
92
89
|
"distribution_version": "7.3",
|
|
93
90
|
"satellite_version": "6.8.4",
|
|
94
91
|
"organization_id": 1,
|
|
@@ -139,7 +136,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
|
139
136
|
"facts": {
|
|
140
137
|
"virtual_host_name": "virt-who-nobody.home-1",
|
|
141
138
|
"satellite_instance_id": "fc4d0cb0-a0b0-421e-b096-b028319b8e47",
|
|
142
|
-
"is_simple_content_access":
|
|
139
|
+
"is_simple_content_access": true,
|
|
143
140
|
"distribution_version": "8.3",
|
|
144
141
|
"satellite_version": "6.8.4",
|
|
145
142
|
"organization_id": 1,
|
|
@@ -192,7 +189,7 @@ class InventoryFullSyncTest < ActiveSupport::TestCase
|
|
|
192
189
|
"facts": {
|
|
193
190
|
"satellite_instance_id": "fb3643d8-9030-487b-b95c-684783806ffd",
|
|
194
191
|
"system_purpose_sla": "",
|
|
195
|
-
"is_simple_content_access":
|
|
192
|
+
"is_simple_content_access": true,
|
|
196
193
|
"distribution_version": "8.3",
|
|
197
194
|
"satellite_version": "6.8.1",
|
|
198
195
|
"organization_id": 1,
|
|
@@ -23,7 +23,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
23
23
|
|
|
24
24
|
pool = FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
|
|
25
25
|
|
|
26
|
-
@host1.
|
|
26
|
+
@host1.organization.pools << pool
|
|
27
27
|
|
|
28
28
|
# this host would pass our plugin queries, so it could be uploaded to the cloud.
|
|
29
29
|
@host2 = FactoryBot.create(
|
|
@@ -34,8 +34,6 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
34
34
|
lifecycle_environment: env,
|
|
35
35
|
organization: env.organization
|
|
36
36
|
)
|
|
37
|
-
|
|
38
|
-
@host2.subscription_facet.pools << pool
|
|
39
37
|
@host2_inventory_id = '4536bf5c-ff03-4154-a8c9-32ff4b40e40c'
|
|
40
38
|
|
|
41
39
|
ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
|
|
@@ -71,7 +69,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
71
69
|
"facts": {
|
|
72
70
|
"virtual_host_name": "virt-who-nobody.home-1",
|
|
73
71
|
"satellite_instance_id": "fc4d0cb0-a0b0-421e-b096-b028319b8e47",
|
|
74
|
-
"is_simple_content_access":
|
|
72
|
+
"is_simple_content_access": true,
|
|
75
73
|
"distribution_version": "7.3",
|
|
76
74
|
"satellite_version": "6.8.4",
|
|
77
75
|
"organization_id": 1,
|
|
@@ -122,7 +120,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
122
120
|
"facts": {
|
|
123
121
|
"virtual_host_name": "virt-who-nobody.home-1",
|
|
124
122
|
"satellite_instance_id": "fc4d0cb0-a0b0-421e-b096-b028319b8e47",
|
|
125
|
-
"is_simple_content_access":
|
|
123
|
+
"is_simple_content_access": true,
|
|
126
124
|
"distribution_version": "7.3",
|
|
127
125
|
"satellite_version": "6.8.4",
|
|
128
126
|
"organization_id": 1,
|
|
@@ -173,7 +171,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
173
171
|
"facts": {
|
|
174
172
|
"virtual_host_name": "virt-who-nobody.home-1",
|
|
175
173
|
"satellite_instance_id": "fc4d0cb0-a0b0-421e-b096-b028319b8e47",
|
|
176
|
-
"is_simple_content_access":
|
|
174
|
+
"is_simple_content_access": true,
|
|
177
175
|
"distribution_version": "8.3",
|
|
178
176
|
"satellite_version": "6.8.4",
|
|
179
177
|
"organization_id": 1,
|
|
@@ -226,7 +224,7 @@ class InventoryHostsSyncTest < ActiveSupport::TestCase
|
|
|
226
224
|
"facts": {
|
|
227
225
|
"satellite_instance_id": "fb3643d8-9030-487b-b95c-684783806ffd",
|
|
228
226
|
"system_purpose_sla": "",
|
|
229
|
-
"is_simple_content_access":
|
|
227
|
+
"is_simple_content_access": true,
|
|
230
228
|
"distribution_version": "8.3",
|
|
231
229
|
"satellite_version": "6.8.1",
|
|
232
230
|
"organization_id": 1,
|
|
@@ -53,7 +53,7 @@ class InventorySelfHostSyncTest < ActiveSupport::TestCase
|
|
|
53
53
|
"facts": {
|
|
54
54
|
"virtual_host_name": "virt-who-nobody.home-1",
|
|
55
55
|
"satellite_instance_id": "fc4d0cb0-a0b0-421e-b096-b028319b8e47",
|
|
56
|
-
"is_simple_content_access":
|
|
56
|
+
"is_simple_content_access": true,
|
|
57
57
|
"distribution_version": "8.3",
|
|
58
58
|
"satellite_version": "6.8.4",
|
|
59
59
|
"organization_id": 1,
|
|
@@ -18,7 +18,7 @@ class ArchivedReportGeneratorTest < ActiveSupport::TestCase
|
|
|
18
18
|
organization: env.organization
|
|
19
19
|
)
|
|
20
20
|
|
|
21
|
-
@host.
|
|
21
|
+
@host.organization.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
def interesting_facts
|
|
@@ -51,7 +51,6 @@ class ArchivedReportGeneratorTest < ActiveSupport::TestCase
|
|
|
51
51
|
test_org = FactoryBot.create(:organization)
|
|
52
52
|
|
|
53
53
|
ForemanInventoryUpload::Generators::Queries.expects(:for_org).with(test_org.id, hosts_query: '').returns(batches)
|
|
54
|
-
ForemanInventoryUpload::Generators::Slice.any_instance.stubs(:golden_ticket?).returns(false)
|
|
55
54
|
Dir.mktmpdir do |tmpdir|
|
|
56
55
|
target = File.join(tmpdir, 'test.tar.gz')
|
|
57
56
|
generator = ForemanInventoryUpload::Generators::ArchivedReport.new(target, Logger.new(STDOUT))
|
|
@@ -12,22 +12,6 @@ class FactHelpersTest < ActiveSupport::TestCase
|
|
|
12
12
|
@org = FactoryBot.create(:organization)
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
test 'golden_ticket uses golden_ticket method when defined' do
|
|
16
|
-
@org.expects(:golden_ticket?).returns(true)
|
|
17
|
-
|
|
18
|
-
actual = @instance.golden_ticket?(@org)
|
|
19
|
-
|
|
20
|
-
assert actual
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
test 'golden_ticket uses content_access_mode method when golden_ticket not defined' do
|
|
24
|
-
@org.expects(:content_access_mode).returns('org_environment')
|
|
25
|
-
|
|
26
|
-
actual = @instance.golden_ticket?(@org)
|
|
27
|
-
|
|
28
|
-
assert actual
|
|
29
|
-
end
|
|
30
|
-
|
|
31
15
|
test 'obfuscates ips with insights-client data' do
|
|
32
16
|
host = mock('host')
|
|
33
17
|
@instance.expects(:fact_value).with(host, 'insights_client::obfuscated_ipv4').returns(
|
|
@@ -19,7 +19,7 @@ class BranchInfoTest < ActiveSupport::TestCase
|
|
|
19
19
|
organization: env.organization
|
|
20
20
|
)
|
|
21
21
|
|
|
22
|
-
@host.
|
|
22
|
+
@host.organization.pools << FactoryBot.create(:katello_pool, account_number: '5678', cp_id: 1)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
test 'should generate branch info for host' do
|
|
@@ -29,7 +29,7 @@ class CloudRequestForwarderTest < ActiveSupport::TestCase
|
|
|
29
29
|
organization: env.organization
|
|
30
30
|
)
|
|
31
31
|
|
|
32
|
-
@host.
|
|
32
|
+
@host.organization.pools << FactoryBot.create(:katello_pool, account_number: '5678', cp_id: 1)
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
test 'should prepare correct cloud url' do
|
|
@@ -641,6 +641,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
641
641
|
assert_tag('1', actual_host, 'int_param', 'satellite_parameter')
|
|
642
642
|
|
|
643
643
|
assert_equal false, satellite_facts['is_hostname_obfuscated']
|
|
644
|
+
assert_equal true, satellite_facts['is_simple_content_access']
|
|
644
645
|
|
|
645
646
|
version = satellite_facts['satellite_version']
|
|
646
647
|
if defined?(ForemanThemeSatellite)
|
|
@@ -702,22 +703,6 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
702
703
|
assert_equal 'test_sla', fact_values['system_purpose_sla']
|
|
703
704
|
end
|
|
704
705
|
|
|
705
|
-
test 'generates a report for a golden ticket' do
|
|
706
|
-
batch = Host.where(id: @host.id).in_batches.first
|
|
707
|
-
generator = create_generator(batch) do |generator|
|
|
708
|
-
generator.stubs(:golden_ticket?).returns(true)
|
|
709
|
-
end
|
|
710
|
-
|
|
711
|
-
json_str = generator.render
|
|
712
|
-
actual = JSON.parse(json_str.join("\n"))
|
|
713
|
-
|
|
714
|
-
assert_equal '00000000-0000-0000-0000-000000000000', actual['report_slice_id']
|
|
715
|
-
assert_not_nil(actual_host = actual['hosts'].first)
|
|
716
|
-
assert_equal @host.fqdn, actual_host['fqdn']
|
|
717
|
-
assert_equal '1234', actual_host['account']
|
|
718
|
-
assert_equal 1, generator.hosts_count
|
|
719
|
-
end
|
|
720
|
-
|
|
721
706
|
test 'skips hosts without subscription' do
|
|
722
707
|
a_host = FactoryBot.create(
|
|
723
708
|
:host,
|
|
@@ -1131,11 +1116,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
1131
1116
|
|
|
1132
1117
|
def create_generator(batch, name = '00000000-0000-0000-0000-000000000000')
|
|
1133
1118
|
generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], name)
|
|
1134
|
-
if block_given?
|
|
1135
|
-
yield(generator)
|
|
1136
|
-
else
|
|
1137
|
-
generator.stubs(:golden_ticket?).returns(false)
|
|
1138
|
-
end
|
|
1119
|
+
yield(generator) if block_given?
|
|
1139
1120
|
generator
|
|
1140
1121
|
end
|
|
1141
1122
|
|
|
@@ -7,6 +7,8 @@ import { getDocsURL } from 'foremanReact/common/helpers';
|
|
|
7
7
|
import { FormattedMessage } from 'react-intl';
|
|
8
8
|
import { selectSubscriptionConnectionEnabled } from '../../../InventorySettings/InventorySettingsSelectors';
|
|
9
9
|
|
|
10
|
+
import { getSubscriptionServiceDocsUrl } from '../../../../ForemanInventoryHelpers';
|
|
11
|
+
|
|
10
12
|
export const PageDescription = () => {
|
|
11
13
|
const subscriptionConnectionEnabled = useSelector(
|
|
12
14
|
selectSubscriptionConnectionEnabled
|
|
@@ -80,7 +82,7 @@ export const PageDescription = () => {
|
|
|
80
82
|
{__('For more information about the Subscriptions service, see:')}
|
|
81
83
|
|
|
82
84
|
<a
|
|
83
|
-
href=
|
|
85
|
+
href={getSubscriptionServiceDocsUrl()}
|
|
84
86
|
target="_blank"
|
|
85
87
|
rel="noopener noreferrer"
|
|
86
88
|
>
|
|
@@ -11,6 +11,13 @@ export const getInventoryDocsUrl = () =>
|
|
|
11
11
|
)}`
|
|
12
12
|
);
|
|
13
13
|
|
|
14
|
+
export const getSubscriptionServiceDocsUrl = () =>
|
|
15
|
+
foremanUrl(
|
|
16
|
+
`/links/manual/?root_url=${URI.encode(
|
|
17
|
+
'https://docs.redhat.com/en/documentation/subscription_central/1-latest/html-single/getting_started_with_the_subscriptions_service/index'
|
|
18
|
+
)}`
|
|
19
|
+
);
|
|
20
|
+
|
|
14
21
|
export const getActionsHistoryUrl = () =>
|
|
15
22
|
foremanUrl(
|
|
16
23
|
'/foreman_tasks/tasks?search=label+%3D+ForemanInventoryUpload%3A%3AAsync%3A%3AHostInventoryReportJob+or+label+%3D+ForemanInventoryUpload%3A%3AAsync%3A%3AGenerateAllReportsJob&page=1'
|