foreman_rh_cloud 2.0.18.1 → 3.0.14
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/README.md +0 -13
- data/app/controllers/foreman_inventory_upload/accounts_controller.rb +2 -2
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +8 -1
- data/app/helpers/foreman_inventory_upload_host_helper.rb +1 -8
- data/app/models/setting/rh_cloud.rb +5 -5
- data/lib/foreman_inventory_upload.rb +2 -3
- data/lib/foreman_inventory_upload/generators/archived_report.rb +1 -1
- data/lib/foreman_inventory_upload/generators/json_stream.rb +1 -1
- data/lib/foreman_inventory_upload/generators/slice.rb +3 -3
- data/lib/foreman_rh_cloud/engine.rb +4 -2
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/lib/tasks/rh_cloud_inventory.rake +0 -23
- data/package.json +1 -1
- data/test/controllers/accounts_controller_test.rb +1 -1
- data/test/unit/slice_generator_test.rb +4 -30
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +3 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +7 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListHelper.js +6 -6
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +1 -10
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +7 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +8 -11
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListHelper.test.js +3 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +6 -6
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListActions.test.js.snap +3 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +3 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +6 -6
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/AutoUploadSwitcher.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AutoUploadSwitcher/__tests__/__snapshots__/AutoUploadSwitcher.test.js.snap +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/DashboardActions.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/Dashboard/__tests__/DashboardActions.test.js +4 -4
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/InventoryAutoUpload.js +92 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/InventoryAutoUpload.test.js +17 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/__tests__/__snapshots__/InventoryAutoUpload.test.js.snap +106 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/AdvancedSettings.js +60 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/components/AdvancedSettings/index.js +28 -0
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/InventoryAutoUpload/index.js +22 -0
- data/webpack/ForemanRhCloudFills.js +23 -0
- data/webpack/ForemanRhCloudPages.js +6 -1
- data/webpack/ForemanRhCloudReducers.js +10 -1
- data/webpack/InsightsHostDetailsTab/InsightsTab.js +5 -7
- data/webpack/InsightsHostDetailsTab/__tests__/InsightsTab.fixtures.js +12 -14
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabActions.test.js.snap +10 -12
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabReducer.test.js.snap +10 -12
- data/webpack/InsightsHostDetailsTab/__tests__/__snapshots__/InsightsTabSelectors.test.js.snap +10 -12
- data/webpack/__mocks__/foremanReact/common/MountingService.js +1 -0
- data/webpack/common/Switcher/index.js +79 -0
- data/webpack/global_index.js +5 -0
- data/webpack/index.js +4 -14
- metadata +25 -21
- data/config/Gemfile.lock.gh_test +0 -817
- data/config/database.yml.example +0 -17
- data/config/package-lock.json.gh_test +0 -36317
- data/db/migrate/20210307000001_add_unique_to_insights_facet.foreman_rh_cloud.rb +0 -11
- data/webpack/ForemanInventoryUpload/SubscriptionsPageExtension/SubscriptionsPageExtensionActions.js +0 -34
- data/webpack/subscriptions_extension_index.js +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1b0882515e038d95959e1926b002f3caebb0b38ed0bd05951208d33cea7748ae
|
|
4
|
+
data.tar.gz: 29d8594297d6c4ed6936d568c7c7a8547186ab7390d03b81448cc5c563f5031d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 71d58183a48ca30f148138bb036ba0cd7bea80dd1ce087b13605e884b763035b674207f91c359f193d658211f2e742f54b2f7e4fadac3f7bc723eb10dbd85f6e
|
|
7
|
+
data.tar.gz: ef3740403be8ab6cc6bb2848666833b424b41cabbc7fac78b06af573db3e59cfed40b01dad2deb88d3bfcba6b8ef86a5c7fe16f8dc48d6b68e821d8f5f2c3ddf
|
data/README.md
CHANGED
|
@@ -19,23 +19,10 @@ In UI: Configure -> Inventory Upload -> Restart
|
|
|
19
19
|
|
|
20
20
|
From command-line:
|
|
21
21
|
|
|
22
|
-
# generate and upload report for all organizations
|
|
23
|
-
/usr/sbin/foreman-rake rh_cloud_inventory:report:generate_upload
|
|
24
|
-
|
|
25
|
-
# generate and upload report for specific organization
|
|
26
|
-
export organization_id=1
|
|
27
|
-
/usr/sbin/foreman-rake rh_cloud_inventory:report:generate_upload
|
|
28
|
-
|
|
29
|
-
# generate report for specific organization (don't upload)
|
|
30
22
|
export organization_id=1
|
|
31
23
|
export target=/var/lib/foreman/red_hat_inventory/generated_reports/
|
|
32
24
|
/usr/sbin/foreman-rake rh_cloud_inventory:report:generate
|
|
33
25
|
|
|
34
|
-
# upload previously generated report (needs to be named 'report_for_#{organization_id}.tar.gz')
|
|
35
|
-
export organization_id=1
|
|
36
|
-
export target=/var/lib/foreman/red_hat_inventory/generated_reports/
|
|
37
|
-
/usr/sbin/foreman-rake rh_cloud_inventory:report:upload
|
|
38
|
-
|
|
39
26
|
#### Fetch hosts remediation data
|
|
40
27
|
|
|
41
28
|
In UI: Configure -> Insights -> Sync now
|
|
@@ -10,11 +10,11 @@ module ForemanInventoryUpload
|
|
|
10
10
|
upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportJob)
|
|
11
11
|
|
|
12
12
|
[
|
|
13
|
-
|
|
13
|
+
id,
|
|
14
14
|
{
|
|
15
15
|
generate_report_status: generate_report_status,
|
|
16
16
|
upload_report_status: upload_report_status,
|
|
17
|
-
|
|
17
|
+
label: label,
|
|
18
18
|
},
|
|
19
19
|
]
|
|
20
20
|
end
|
|
@@ -14,7 +14,14 @@ module ForemanInventoryUpload
|
|
|
14
14
|
files = Dir["{#{ForemanInventoryUpload.uploads_file_path(filename)},#{ForemanInventoryUpload.done_file_path(filename)}}"]
|
|
15
15
|
|
|
16
16
|
return send_file files.first, disposition: 'attachment', filename: filename unless files.empty?
|
|
17
|
-
|
|
17
|
+
throw_flash_error "File doesn't exist"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def throw_flash_error(message)
|
|
21
|
+
process_error(
|
|
22
|
+
:redirect => foreman_inventory_upload_index_path,
|
|
23
|
+
:error_msg => message
|
|
24
|
+
)
|
|
18
25
|
end
|
|
19
26
|
|
|
20
27
|
def auto_upload
|
|
@@ -6,14 +6,7 @@ module ForemanInventoryUploadHostHelper
|
|
|
6
6
|
def hits_counts_cell(host)
|
|
7
7
|
host_hits = hits_counts[host.id]
|
|
8
8
|
tag.td class: ['hidden-xs', 'ellipsis', 'text-center'] do
|
|
9
|
-
if host_hits
|
|
10
|
-
link_to(
|
|
11
|
-
host_hits,
|
|
12
|
-
InsightsCloud::WebUi.system_url(InsightsCloud::WebUi::ADVISOR, host.insights.uuid),
|
|
13
|
-
:rel => 'external noopener noreferrer',
|
|
14
|
-
:target => '_blank'
|
|
15
|
-
)
|
|
16
|
-
end
|
|
9
|
+
link_to(host_hits, "#{host_path(host)}#insights") if host_hits
|
|
17
10
|
end
|
|
18
11
|
end
|
|
19
12
|
end
|
|
@@ -3,12 +3,12 @@ class Setting::RhCloud < Setting
|
|
|
3
3
|
return unless ActiveRecord::Base.connection.table_exists?('settings')
|
|
4
4
|
return unless super
|
|
5
5
|
[
|
|
6
|
-
set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), false
|
|
7
|
-
set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false
|
|
8
|
-
set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false
|
|
9
|
-
set('obfuscate_inventory_ips', N_('Obfuscate ip addresses sent to Red Hat cloud'), false
|
|
6
|
+
set('allow_auto_inventory_upload', N_('Allow automatic upload of the host inventory to the Red Hat cloud'), false),
|
|
7
|
+
set('allow_auto_insights_sync', N_('Allow recommendations synchronization from Red Hat cloud'), false),
|
|
8
|
+
set('obfuscate_inventory_hostnames', N_('Obfuscate host names sent to Red Hat cloud'), false),
|
|
9
|
+
set('obfuscate_inventory_ips', N_('Obfuscate ip addresses sent to Red Hat cloud'), false),
|
|
10
10
|
set('rh_cloud_token', N_('Authentication token to Red Hat cloud services. Used to authenticate requests to cloud APIs'), 'DEFAULT', N_('Red Hat Cloud token'), nil, encrypted: true),
|
|
11
|
-
set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false
|
|
11
|
+
set('exclude_installed_packages', N_('Exclude installed packages from Red Hat cloud inventory report'), false),
|
|
12
12
|
]
|
|
13
13
|
end
|
|
14
14
|
|
|
@@ -48,7 +48,7 @@ module ForemanInventoryUpload
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def self.facts_archive_name(organization)
|
|
51
|
-
"report_for_#{organization}.tar.
|
|
51
|
+
"report_for_#{organization}.tar.gz"
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def self.upload_url
|
|
@@ -62,7 +62,6 @@ module ForemanInventoryUpload
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
def self.inventory_export_url
|
|
65
|
-
|
|
66
|
-
ForemanRhCloud.base_url + "/api/inventory/v1/hosts?tags=#{tags}"
|
|
65
|
+
ForemanRhCloud.base_url + '/api/inventory/v1/hosts'
|
|
67
66
|
end
|
|
68
67
|
end
|
|
@@ -28,7 +28,7 @@ module ForemanInventoryUpload
|
|
|
28
28
|
|
|
29
29
|
@logger.info 'Archiving generated report'
|
|
30
30
|
# success = system('tar', '-zcvf', @target, '-C', tmpdir, '.')
|
|
31
|
-
Open3.popen2e('tar', '-
|
|
31
|
+
Open3.popen2e('tar', '-zcvf', @target, '-C', tmpdir, '.') do |_in, out, wait_thr|
|
|
32
32
|
@logger.info("tar: #{out.read}")
|
|
33
33
|
|
|
34
34
|
if wait_thr.value.success?
|
|
@@ -103,10 +103,10 @@ module ForemanInventoryUpload
|
|
|
103
103
|
@stream.simple_field('cores_per_socket', fact_value(host, 'cpu::core(s)_per_socket')) { |v| v.to_i }
|
|
104
104
|
@stream.simple_field('system_memory_bytes', fact_value(host, 'memory::memtotal')) { |v| kilobytes_to_bytes(v.to_i) }
|
|
105
105
|
@stream.array_field('network_interfaces') do
|
|
106
|
-
@stream.raw(host.interfaces.
|
|
106
|
+
@stream.raw(host.interfaces.map do |nic|
|
|
107
107
|
{
|
|
108
|
-
'ipv4_addresses': [host_ips_cache[nic.ip]].
|
|
109
|
-
'ipv6_addresses': [nic.ip6].
|
|
108
|
+
'ipv4_addresses': [host_ips_cache[nic.ip]].compact,
|
|
109
|
+
'ipv6_addresses': [nic.ip6].compact,
|
|
110
110
|
'mtu': nic.try(:mtu) && nic.mtu.to_i,
|
|
111
111
|
'mac_address': nic.mac,
|
|
112
112
|
'name': nic.identifier,
|
|
@@ -27,7 +27,7 @@ module ForemanRhCloud
|
|
|
27
27
|
|
|
28
28
|
initializer 'foreman_rh_cloud.register_plugin', :before => :finisher_hook do |_app|
|
|
29
29
|
Foreman::Plugin.register :foreman_rh_cloud do
|
|
30
|
-
requires_foreman '
|
|
30
|
+
requires_foreman '>= 2.3'
|
|
31
31
|
|
|
32
32
|
# Add permissions
|
|
33
33
|
security_block :foreman_rh_cloud do
|
|
@@ -64,7 +64,7 @@ module ForemanRhCloud
|
|
|
64
64
|
end
|
|
65
65
|
end
|
|
66
66
|
|
|
67
|
-
register_global_js_file '
|
|
67
|
+
register_global_js_file 'global'
|
|
68
68
|
|
|
69
69
|
register_custom_status(InventorySync::InventoryStatus)
|
|
70
70
|
|
|
@@ -72,6 +72,7 @@ module ForemanRhCloud
|
|
|
72
72
|
context.add_pagelet :main_tabs,
|
|
73
73
|
partial: 'hosts/insights_tab',
|
|
74
74
|
name: _('Insights'),
|
|
75
|
+
id: 'insights',
|
|
75
76
|
onlyif: proc { |host| host.insights }
|
|
76
77
|
end
|
|
77
78
|
end
|
|
@@ -79,6 +80,7 @@ module ForemanRhCloud
|
|
|
79
80
|
::Katello::UINotifications::Subscriptions::ManifestImportSuccess.include ForemanInventoryUpload::Notifications::ManifestImportSuccessNotificationOverride if defined?(Katello)
|
|
80
81
|
|
|
81
82
|
::Host::Managed.include RhCloudHost
|
|
83
|
+
::Host::Base.include RhCloudHost
|
|
82
84
|
end
|
|
83
85
|
|
|
84
86
|
initializer "foreman_rh_cloud.set_dynflow.config.on_init", :before => :finisher_hook do |_app|
|
|
@@ -2,21 +2,6 @@ require 'tempfile'
|
|
|
2
2
|
|
|
3
3
|
namespace :rh_cloud_inventory do
|
|
4
4
|
namespace :report do
|
|
5
|
-
desc 'Generate inventory report and send it to Red Hat cloud'
|
|
6
|
-
task generate_upload: [:environment, 'dynflow:client'] do
|
|
7
|
-
unless ENV['organization_id'].nil?
|
|
8
|
-
organizations = [ Organization.where(:id => ENV['organization_id']).first ]
|
|
9
|
-
else
|
|
10
|
-
organizations = Organization.unscoped.all
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
User.as_anonymous_admin do
|
|
14
|
-
organizations.each do |organization|
|
|
15
|
-
ForemanInventoryUpload::Async::GenerateReportJob.perform_now(ForemanInventoryUpload.generated_reports_folder, organization.id)
|
|
16
|
-
puts "Generated and uploaded inventory report for organization '#{organization.name}'"
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|
|
20
5
|
desc 'Generate inventory report to be sent to Red Hat cloud'
|
|
21
6
|
task generate: :environment do
|
|
22
7
|
portal_user = ENV['portal_user']
|
|
@@ -42,14 +27,6 @@ namespace :rh_cloud_inventory do
|
|
|
42
27
|
end
|
|
43
28
|
end
|
|
44
29
|
end
|
|
45
|
-
desc 'Upload generated inventory report to Red Hat cloud'
|
|
46
|
-
task upload: [:environment, 'dynflow:client'] do
|
|
47
|
-
base_folder = ENV['target'] || ForemanInventoryUpload.generated_reports_folder
|
|
48
|
-
organization_id = ENV['organization_id']
|
|
49
|
-
report_file = ForemanInventoryUpload.facts_archive_name(organization_id)
|
|
50
|
-
ForemanInventoryUpload::Async::QueueForUploadJob.perform_now(base_folder, report_file, organization_id)
|
|
51
|
-
puts "Uploaded #{report_file}"
|
|
52
|
-
end
|
|
53
30
|
end
|
|
54
31
|
|
|
55
32
|
desc "Synchronize Insights hosts hits"
|
data/package.json
CHANGED
|
@@ -21,7 +21,7 @@ class AccountsControllerTest < ActionController::TestCase
|
|
|
21
21
|
|
|
22
22
|
assert_response :success
|
|
23
23
|
actual = JSON.parse(response.body)
|
|
24
|
-
actual_account_statuses = actual['accounts'][test_org.
|
|
24
|
+
actual_account_statuses = actual['accounts'][test_org.id.to_s]
|
|
25
25
|
assert_equal 'generate_status_test', actual_account_statuses['generate_report_status']
|
|
26
26
|
assert_equal 'upload_status_test', actual_account_statuses['upload_report_status']
|
|
27
27
|
|
|
@@ -18,8 +18,6 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
18
18
|
)
|
|
19
19
|
|
|
20
20
|
@host.organization.pools << FactoryBot.create(:katello_pool, account_number: '1234', cp_id: 1)
|
|
21
|
-
@host.interfaces.first.identifier = 'test_nic1'
|
|
22
|
-
@host.save!
|
|
23
21
|
|
|
24
22
|
ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
|
|
25
23
|
end
|
|
@@ -83,7 +81,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
83
81
|
assert_not_nil(actual_nic = actual_network_interfaces.first)
|
|
84
82
|
refute actual_nic.key?('mtu')
|
|
85
83
|
refute actual_nic.key?('mac_address')
|
|
86
|
-
|
|
84
|
+
refute actual_nic.key?('name')
|
|
87
85
|
end
|
|
88
86
|
|
|
89
87
|
test 'hosts report fields should be present if fact exist' do
|
|
@@ -125,10 +123,8 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
125
123
|
end
|
|
126
124
|
|
|
127
125
|
test 'generates nic fields' do
|
|
128
|
-
empty_nic = FactoryBot.build(:nic_managed, ip6: '', identifier: 'empty_nic')
|
|
129
|
-
@host.interfaces << empty_nic
|
|
130
126
|
ip6 = Array.new(4) { '%x' % rand(16**4) }.join(':') + '::' + '5'
|
|
131
|
-
nic = FactoryBot.build(:nic_managed, ip6: ip6
|
|
127
|
+
nic = FactoryBot.build(:nic_managed, ip6: ip6)
|
|
132
128
|
nic.attrs['mtu'] = '1500'
|
|
133
129
|
@host.interfaces << nic
|
|
134
130
|
batch = Host.where(id: @host.id).in_batches.first
|
|
@@ -143,9 +139,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
143
139
|
assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
|
|
144
140
|
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
|
145
141
|
assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
|
|
146
|
-
assert_not_nil(
|
|
147
|
-
assert actual_empty_nic['ipv6_addresses'].empty?
|
|
148
|
-
assert_not_nil(actual_nic = actual_network_interfaces.find { |actual_nic| actual_nic['name'] == 'good_nic' })
|
|
142
|
+
assert_not_nil(actual_nic = actual_network_interfaces.first)
|
|
149
143
|
assert_equal nic.ip, actual_nic['ipv4_addresses'].first
|
|
150
144
|
assert_equal nic.ip6, actual_nic['ipv6_addresses'].first
|
|
151
145
|
assert_equal 1500, actual_nic['mtu']
|
|
@@ -156,26 +150,6 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
156
150
|
assert_equal 1, generator.hosts_count
|
|
157
151
|
end
|
|
158
152
|
|
|
159
|
-
test 'skips nameless nics' do
|
|
160
|
-
ip6 = Array.new(4) { '%x' % rand(16**4) }.join(':') + '::' + '5'
|
|
161
|
-
nic = FactoryBot.build(:nic_managed, ip6: ip6, identifier: '')
|
|
162
|
-
nic.attrs['mtu'] = '1500'
|
|
163
|
-
@host.interfaces << nic
|
|
164
|
-
batch = Host.where(id: @host.id).in_batches.first
|
|
165
|
-
generator = create_generator(batch)
|
|
166
|
-
|
|
167
|
-
json_str = generator.render
|
|
168
|
-
actual = JSON.parse(json_str.join("\n"))
|
|
169
|
-
|
|
170
|
-
assert_equal 'slice_123', actual['report_slice_id']
|
|
171
|
-
assert_not_nil(actual_host = actual['hosts'].first)
|
|
172
|
-
assert_equal @host.interfaces.where.not(ip: nil).first.ip, actual_host['ip_addresses'].first
|
|
173
|
-
assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
|
|
174
|
-
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
|
175
|
-
assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
|
|
176
|
-
assert_nil actual_network_interfaces.find { |actual_nic| actual_nic['name'].empty? }
|
|
177
|
-
end
|
|
178
|
-
|
|
179
153
|
test 'generates obfuscated ip_address fields without inisghts-client' do
|
|
180
154
|
FactoryBot.create(:setting, :name => 'obfuscate_inventory_ips', :value => true)
|
|
181
155
|
|
|
@@ -287,7 +261,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
|
287
261
|
end
|
|
288
262
|
|
|
289
263
|
test 'generates a report with satellite facts' do
|
|
290
|
-
hostgroup = FactoryBot.create(:hostgroup
|
|
264
|
+
hostgroup = FactoryBot.create(:hostgroup)
|
|
291
265
|
@host.hostgroup = hostgroup
|
|
292
266
|
@host.save!
|
|
293
267
|
|
|
@@ -2,17 +2,17 @@ import { noop } from 'patternfly-react';
|
|
|
2
2
|
|
|
3
3
|
export const accounts = {
|
|
4
4
|
Account1: {
|
|
5
|
-
|
|
5
|
+
label: 'test_org1',
|
|
6
6
|
upload_report_status: 'running',
|
|
7
7
|
generate_report_status: 'running',
|
|
8
8
|
},
|
|
9
9
|
Account2: {
|
|
10
|
-
|
|
10
|
+
label: 'test_org2',
|
|
11
11
|
upload_report_status: 'unknown',
|
|
12
12
|
generate_report_status: 'failure',
|
|
13
13
|
},
|
|
14
14
|
Account3: {
|
|
15
|
-
|
|
15
|
+
label: 'test_org3',
|
|
16
16
|
upload_report_status: 'success',
|
|
17
17
|
generate_report_status: 'running',
|
|
18
18
|
},
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import React, { Component } from 'react';
|
|
2
2
|
import { ListView, noop } from 'patternfly-react';
|
|
3
|
-
import { isEmpty } from 'lodash';
|
|
4
3
|
import PropTypes from 'prop-types';
|
|
5
4
|
import ListItem from './Components/ListItem';
|
|
6
5
|
import EmptyState from './Components/EmptyState';
|
|
@@ -24,23 +23,24 @@ class AccountList extends Component {
|
|
|
24
23
|
|
|
25
24
|
render() {
|
|
26
25
|
const { accounts, error, filterTerm } = this.props;
|
|
27
|
-
const
|
|
26
|
+
const accountIds = Object.keys(accounts);
|
|
27
|
+
const filteredAccountIds = filterAccounts(accounts, accountIds, filterTerm);
|
|
28
28
|
|
|
29
29
|
if (error) {
|
|
30
30
|
return <ErrorState error={error} />;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
if (
|
|
33
|
+
if (accountIds.length === 0) {
|
|
34
34
|
return <EmptyState />;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
if (
|
|
37
|
+
if (filteredAccountIds.length === 0) {
|
|
38
38
|
return <EmptyResults />;
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
const items =
|
|
42
|
-
const account = accounts[
|
|
43
|
-
return <ListItem key={index}
|
|
41
|
+
const items = filteredAccountIds.map((accountID, index) => {
|
|
42
|
+
const account = accounts[accountID];
|
|
43
|
+
return <ListItem key={index} accountID={accountID} account={account} />;
|
|
44
44
|
});
|
|
45
45
|
return <ListView className="account_list">{items}</ListView>;
|
|
46
46
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const filterAccounts = (accounts, accountIds, filterTerm) => {
|
|
2
|
+
if (!filterTerm || !accountIds.length) {
|
|
3
|
+
return accountIds;
|
|
4
|
+
}
|
|
5
5
|
|
|
6
6
|
const filterTermLowerCased = filterTerm.toLowerCase();
|
|
7
|
-
return
|
|
8
|
-
|
|
7
|
+
return accountIds.filter(id =>
|
|
8
|
+
accounts[id].label.toLowerCase().includes(filterTermLowerCased)
|
|
9
9
|
);
|
|
10
10
|
};
|
|
@@ -4,26 +4,26 @@ import PropTypes from 'prop-types';
|
|
|
4
4
|
import ListItemStatus from '../ListItemStatus';
|
|
5
5
|
import Dashboard from '../../../Dashboard';
|
|
6
6
|
|
|
7
|
-
const ListItem = ({
|
|
7
|
+
const ListItem = ({ accountID, account }) => (
|
|
8
8
|
<ListView.Item
|
|
9
9
|
leftContent={<ListView.Icon name="user" />}
|
|
10
|
-
heading={label}
|
|
10
|
+
heading={account.label}
|
|
11
11
|
additionalInfo={[
|
|
12
|
-
<ListItemStatus key={`${
|
|
12
|
+
<ListItemStatus key={`${accountID}_status`} account={account} />,
|
|
13
13
|
]}
|
|
14
14
|
stacked
|
|
15
15
|
hideCloseIcon
|
|
16
16
|
>
|
|
17
|
-
<Dashboard accountID={
|
|
17
|
+
<Dashboard accountID={accountID} account={account} />
|
|
18
18
|
</ListView.Item>
|
|
19
19
|
);
|
|
20
20
|
|
|
21
21
|
ListItem.propTypes = {
|
|
22
|
-
|
|
22
|
+
accountID: PropTypes.string.isRequired,
|
|
23
23
|
account: PropTypes.shape({
|
|
24
24
|
generate_report_status: PropTypes.string,
|
|
25
25
|
upload_report_status: PropTypes.string,
|
|
26
|
-
|
|
26
|
+
label: PropTypes.string,
|
|
27
27
|
}),
|
|
28
28
|
};
|
|
29
29
|
|
|
@@ -31,7 +31,7 @@ ListItem.defaultProps = {
|
|
|
31
31
|
account: {
|
|
32
32
|
generate_report_status: 'unknown',
|
|
33
33
|
upload_report_status: 'unknown',
|
|
34
|
-
|
|
34
|
+
label: 'default_org_name',
|
|
35
35
|
},
|
|
36
36
|
};
|
|
37
37
|
|