foreman_rh_cloud 2.0.16 → 2.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/lib/foreman_inventory_upload/generators/slice.rb +3 -3
- data/lib/foreman_rh_cloud/version.rb +1 -1
- data/package.json +1 -1
- data/test/unit/slice_generator_test.rb +29 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b34803af6696737993eb885384efd806b443d28668c96734e175f2595ce4829
|
4
|
+
data.tar.gz: e936612e09f71e9e3b351be01862763a4fae2f7caa29f6161547456416e8675f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb8e4f801f862736c5a4a93b3fe4b259067a1f7d44d1c81b5b11432e61b6047614c7ba7ec4e9d97af352fe85ee6a972ce1c7bcc5ac97b8602526750b0ff7018b
|
7
|
+
data.tar.gz: 59c87465077fbc67aac9e71076cc7f70ede3a577aa3cb37af8e257e78ee12f9955a77f2dfdf4a11fe84c76be073c6f84503e3a2b4178dda1bbe13bad458abf1d
|
@@ -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.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].
|
108
|
+
'ipv4_addresses': [host_ips_cache[nic.ip]].reject(&:empty?),
|
109
|
+
'ipv6_addresses': [nic.ip6].reject(&:empty?),
|
110
110
|
'mtu': nic.try(:mtu) && nic.mtu.to_i,
|
111
111
|
'mac_address': nic.mac,
|
112
112
|
'name': nic.identifier,
|
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
|
@@ -81,7 +83,7 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
81
83
|
assert_not_nil(actual_nic = actual_network_interfaces.first)
|
82
84
|
refute actual_nic.key?('mtu')
|
83
85
|
refute actual_nic.key?('mac_address')
|
84
|
-
|
86
|
+
assert_equal 'test_nic1', actual_nic['name']
|
85
87
|
end
|
86
88
|
|
87
89
|
test 'hosts report fields should be present if fact exist' do
|
@@ -123,8 +125,10 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
123
125
|
end
|
124
126
|
|
125
127
|
test 'generates nic fields' do
|
128
|
+
empty_nic = FactoryBot.build(:nic_managed, ip6: '', identifier: 'empty_nic')
|
129
|
+
@host.interfaces << empty_nic
|
126
130
|
ip6 = Array.new(4) { '%x' % rand(16**4) }.join(':') + '::' + '5'
|
127
|
-
nic = FactoryBot.build(:nic_managed, ip6: ip6)
|
131
|
+
nic = FactoryBot.build(:nic_managed, ip6: ip6, identifier: 'good_nic')
|
128
132
|
nic.attrs['mtu'] = '1500'
|
129
133
|
@host.interfaces << nic
|
130
134
|
batch = Host.where(id: @host.id).in_batches.first
|
@@ -139,7 +143,9 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
139
143
|
assert_equal @host.interfaces.where.not(mac: nil).first.mac, actual_host['mac_addresses'].first
|
140
144
|
assert_not_nil(actual_system_profile = actual_host['system_profile'])
|
141
145
|
assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
|
142
|
-
assert_not_nil(
|
146
|
+
assert_not_nil(actual_empty_nic = actual_network_interfaces.find { |actual_nic| actual_nic['name'] == 'empty_nic' })
|
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' })
|
143
149
|
assert_equal nic.ip, actual_nic['ipv4_addresses'].first
|
144
150
|
assert_equal nic.ip6, actual_nic['ipv6_addresses'].first
|
145
151
|
assert_equal 1500, actual_nic['mtu']
|
@@ -150,6 +156,26 @@ class SliceGeneratorTest < ActiveSupport::TestCase
|
|
150
156
|
assert_equal 1, generator.hosts_count
|
151
157
|
end
|
152
158
|
|
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
|
+
|
153
179
|
test 'generates obfuscated ip_address fields without inisghts-client' do
|
154
180
|
FactoryBot.create(:setting, :name => 'obfuscate_inventory_ips', :value => true)
|
155
181
|
|
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: 2.0.
|
4
|
+
version: 2.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: 2021-02-
|
11
|
+
date: 2021-02-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|