foreman_rh_cloud 1.0.13 → 1.0.17
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/models/setting/rh_cloud.rb +5 -5
- data/config/Gemfile.lock.gh_test +757 -0
- data/config/database.yml.example +17 -0
- data/config/package-lock.json.gh_test +30855 -0
- data/lib/foreman_inventory_upload.rb +1 -1
- data/lib/foreman_inventory_upload/generators/archived_report.rb +1 -1
- data/lib/foreman_inventory_upload/generators/slice.rb +4 -4
- data/lib/foreman_rh_cloud/engine.rb +0 -1
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/package.json +1 -1
- data/test/unit/slice_generator_test.rb +64 -1
- data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js +2 -2
- data/webpack/InsightsCloudSync/InsightsCloudSync.js +1 -1
- data/webpack/InsightsCloudSync/__snapshots__/InsightsCloudSync.test.js.snap +1 -1
- data/webpack/InsightsHostDetailsTab/InsightsTab.scss +1 -1
- metadata +17 -14
@@ -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', '-Jcvf', @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,11 +103,11 @@ 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.map do |nic|
|
106
|
+
@stream.raw(host.interfaces.reject { |nic| nic.identifier.empty? }.map do |nic|
|
107
107
|
{
|
108
|
-
'ipv4_addresses': [host_ips_cache[nic.ip]].
|
109
|
-
'ipv6_addresses': [nic.ip6].
|
110
|
-
'mtu': nic.try(:mtu),
|
108
|
+
'ipv4_addresses': [host_ips_cache[nic.ip]].reject(&:empty?),
|
109
|
+
'ipv6_addresses': [nic.ip6].reject(&:empty?),
|
110
|
+
'mtu': nic.try(:mtu) && nic.mtu.to_i,
|
111
111
|
'mac_address': nic.mac,
|
112
112
|
'name': nic.identifier,
|
113
113
|
}.compact.to_json
|
@@ -79,7 +79,6 @@ module ForemanRhCloud
|
|
79
79
|
::Katello::UINotifications::Subscriptions::ManifestImportSuccess.include ForemanInventoryUpload::Notifications::ManifestImportSuccessNotificationOverride if defined?(Katello)
|
80
80
|
|
81
81
|
::Host::Managed.include RhCloudHost
|
82
|
-
::Host::Base.include RhCloudHost
|
83
82
|
end
|
84
83
|
|
85
84
|
initializer "foreman_rh_cloud.set_dynflow.config.on_init", :before => :finisher_hook do |_app|
|
data/package.json
CHANGED
@@ -18,6 +18,8 @@ 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!
|
21
23
|
|
22
24
|
ForemanInventoryUpload::Generators::Queries.instance_variable_set(:@fact_names, nil)
|
23
25
|
end
|
@@ -77,6 +79,11 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
77
79
|
assert_nil actual_system_profile['cores_per_socket']
|
78
80
|
assert_nil actual_system_profile['system_memory_bytes']
|
79
81
|
assert_nil actual_system_profile['os_release']
|
82
|
+
assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
|
83
|
+
assert_not_nil(actual_nic = actual_network_interfaces.first)
|
84
|
+
refute actual_nic.key?('mtu')
|
85
|
+
refute actual_nic.key?('mac_address')
|
86
|
+
assert_equal 'test_nic1', actual_nic['name']
|
80
87
|
end
|
81
88
|
|
82
89
|
test 'hosts report fields should be present if fact exist' do
|
@@ -99,7 +106,9 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
99
106
|
end
|
100
107
|
|
101
108
|
test 'generates ip_address and mac_address fields' do
|
102
|
-
|
109
|
+
nic = FactoryBot.build(:nic_managed)
|
110
|
+
nic.attrs['mtu'] = '1500'
|
111
|
+
@host.interfaces << nic
|
103
112
|
batch = Host.where(id: @host.id).in_batches.first
|
104
113
|
generator = create_generator(batch)
|
105
114
|
|
@@ -115,6 +124,60 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
115
124
|
assert_equal 1, generator.hosts_count
|
116
125
|
end
|
117
126
|
|
127
|
+
test 'generates nic fields' do
|
128
|
+
empty_nic = FactoryBot.build(:nic_managed, ip6: '', identifier: 'empty_nic')
|
129
|
+
@host.interfaces << empty_nic
|
130
|
+
ip6 = Array.new(4) { '%x' % rand(16**4) }.join(':') + '::' + '5'
|
131
|
+
nic = FactoryBot.build(:nic_managed, ip6: ip6, identifier: 'good_nic')
|
132
|
+
nic.attrs['mtu'] = '1500'
|
133
|
+
@host.interfaces << nic
|
134
|
+
batch = Host.where(id: @host.id).in_batches.first
|
135
|
+
generator = create_generator(batch)
|
136
|
+
|
137
|
+
json_str = generator.render
|
138
|
+
actual = JSON.parse(json_str.join("\n"))
|
139
|
+
|
140
|
+
assert_equal 'slice_123', actual['report_slice_id']
|
141
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
142
|
+
expected_ip = @host.interfaces.where.not(ip: nil).first.ip
|
143
|
+
assert_not_nil actual_host['ip_addresses'].find { |addr| addr == expected_ip }
|
144
|
+
expected_mac = @host.interfaces.where.not(mac: nil).first.mac
|
145
|
+
assert_not_nil actual_host['mac_addresses'].find { |mac| mac == expected_mac }
|
146
|
+
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
147
|
+
assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
|
148
|
+
assert_not_nil(actual_empty_nic = actual_network_interfaces.find { |actual_nic| actual_nic['name'] == 'empty_nic' })
|
149
|
+
assert actual_empty_nic['ipv6_addresses'].empty?
|
150
|
+
assert_not_nil(actual_nic = actual_network_interfaces.find { |actual_nic| actual_nic['name'] == 'good_nic' })
|
151
|
+
assert_equal nic.ip, actual_nic['ipv4_addresses'].first
|
152
|
+
assert_equal nic.ip6, actual_nic['ipv6_addresses'].first
|
153
|
+
assert_equal 1500, actual_nic['mtu']
|
154
|
+
assert_equal nic.mac, actual_nic['mac_address']
|
155
|
+
assert_equal nic.identifier, actual_nic['name']
|
156
|
+
assert_equal @host.fqdn, actual_host['fqdn']
|
157
|
+
assert_equal '1234', actual_host['account']
|
158
|
+
assert_equal 1, generator.hosts_count
|
159
|
+
end
|
160
|
+
|
161
|
+
test 'skips nameless nics' do
|
162
|
+
ip6 = Array.new(4) { '%x' % rand(16**4) }.join(':') + '::' + '5'
|
163
|
+
nic = FactoryBot.build(:nic_managed, ip6: ip6, identifier: '')
|
164
|
+
nic.attrs['mtu'] = '1500'
|
165
|
+
@host.interfaces << nic
|
166
|
+
batch = Host.where(id: @host.id).in_batches.first
|
167
|
+
generator = create_generator(batch)
|
168
|
+
|
169
|
+
json_str = generator.render
|
170
|
+
actual = JSON.parse(json_str.join("\n"))
|
171
|
+
|
172
|
+
assert_equal 'slice_123', actual['report_slice_id']
|
173
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
174
|
+
assert_equal @host.interfaces.where.not(ip: nil).first.ip, actual_host['ip_addresses'].first
|
175
|
+
assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
|
176
|
+
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
177
|
+
assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
|
178
|
+
assert_nil actual_network_interfaces.find { |actual_nic| actual_nic['name'].empty? }
|
179
|
+
end
|
180
|
+
|
118
181
|
test 'generates obfuscated ip_address fields without inisghts-client' do
|
119
182
|
FactoryBot.create(:setting, :name => 'obfuscate_inventory_ips', :value => true)
|
120
183
|
|
data/webpack/ForemanInventoryUpload/Components/PageHeader/components/SyncButton/components/Modal.js
CHANGED
@@ -21,10 +21,10 @@ const SyncModal = ({ show, toggleModal }) => (
|
|
21
21
|
<Modal.Body>
|
22
22
|
<Grid>
|
23
23
|
<p>
|
24
|
-
{__(`Please go over the following steps to add a
|
24
|
+
{__(`Please go over the following steps to add a Red Hat API token:`)}
|
25
25
|
</p>
|
26
26
|
<p>
|
27
|
-
{__(`1. Obtain an
|
27
|
+
{__(`1. Obtain an Red Hat API token: `)}
|
28
28
|
<a
|
29
29
|
href="https://access.redhat.com/management/api"
|
30
30
|
target="_blank"
|
@@ -19,7 +19,7 @@ const InsightsCloudSync = ({ data: { settingsUrl }, syncInsights }) => {
|
|
19
19
|
recommendations output for hosts managed here`)}
|
20
20
|
</p>
|
21
21
|
<p>
|
22
|
-
{__(`1. Obtain an
|
22
|
+
{__(`1. Obtain an Red Hat API token: `)}
|
23
23
|
<a
|
24
24
|
href="https://access.redhat.com/management/api"
|
25
25
|
target="_blank"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_rh_cloud
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Foreman Red Hat Cloud team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|
@@ -125,6 +125,9 @@ files:
|
|
125
125
|
- app/views/foreman_rh_cloud/react/inventory_upload.html.erb
|
126
126
|
- app/views/hosts/_insights_tab.html.erb
|
127
127
|
- app/views/layouts/foreman_rh_cloud/application.html.erb
|
128
|
+
- config/Gemfile.lock.gh_test
|
129
|
+
- config/database.yml.example
|
130
|
+
- config/package-lock.json.gh_test
|
128
131
|
- config/routes.rb
|
129
132
|
- db/migrate/20191215104806_create_insights_hits.foreman_inventory_upload.rb
|
130
133
|
- db/migrate/20191216062008_create_insights_facets.foreman_inventory_upload.rb
|
@@ -547,25 +550,25 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
547
550
|
- !ruby/object:Gem::Version
|
548
551
|
version: '0'
|
549
552
|
requirements: []
|
550
|
-
rubygems_version: 3.0.
|
553
|
+
rubygems_version: 3.0.6
|
551
554
|
signing_key:
|
552
555
|
specification_version: 4
|
553
556
|
summary: Summary of ForemanRhCloud.
|
554
557
|
test_files:
|
558
|
+
- test/controllers/uploads_controller_test.rb
|
559
|
+
- test/controllers/insights_sync/settings_controller_test.rb
|
560
|
+
- test/controllers/accounts_controller_test.rb
|
561
|
+
- test/controllers/reports_controller_test.rb
|
555
562
|
- test/test_plugin_helper.rb
|
563
|
+
- test/jobs/upload_report_job_test.rb
|
564
|
+
- test/jobs/insights_full_sync_test.rb
|
565
|
+
- test/jobs/inventory_full_sync_test.rb
|
556
566
|
- test/factories/inventory_upload_factories.rb
|
557
567
|
- test/factories/insights_factories.rb
|
558
|
-
- test/controllers/reports_controller_test.rb
|
559
|
-
- test/controllers/uploads_controller_test.rb
|
560
|
-
- test/controllers/accounts_controller_test.rb
|
561
|
-
- test/controllers/insights_sync/settings_controller_test.rb
|
562
|
-
- test/unit/slice_generator_test.rb
|
563
|
-
- test/unit/metadata_generator_test.rb
|
564
|
-
- test/unit/rh_cloud_http_proxy_test.rb
|
565
568
|
- test/unit/shell_process_job_test.rb
|
569
|
+
- test/unit/metadata_generator_test.rb
|
566
570
|
- test/unit/insights_facet_test.rb
|
567
|
-
- test/unit/
|
571
|
+
- test/unit/rh_cloud_http_proxy_test.rb
|
568
572
|
- test/unit/fact_helpers_test.rb
|
569
|
-
- test/
|
570
|
-
- test/
|
571
|
-
- test/jobs/upload_report_job_test.rb
|
573
|
+
- test/unit/archived_report_generator_test.rb
|
574
|
+
- test/unit/slice_generator_test.rb
|