foreman_rh_cloud 1.0.16 → 1.0.17

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eeffb0a27f7ac98d94317024ffa19cf9ec9776870e46f635f2a2f4610b7d3bb3
4
- data.tar.gz: 96d8c4cefe7e5a6c7eb44154beafa7e5e50977e67be4cb74a9f7c88b386ad0e6
3
+ metadata.gz: 0724cdfa4e0563ba9b2cbab222198ab8dd921527f8c31d1136795a158b659038
4
+ data.tar.gz: 7bc88ae8db51b586e7e4d6d8e05baf16dc782f86626e059aecacece43adbd4d8
5
5
  SHA512:
6
- metadata.gz: 00176ebf23c4b18f981fd41622edbc49679a8a12ff77dc1dd9feba5fc4076a22eee994fce99bb9bf4caf7062dc8307adf9a7659e0aefbbfc95b7c24e2ad7d50c
7
- data.tar.gz: d2bb193f176793554b5d0cd3f81703ea2b2042ede7868a6a2a49d4d807e0f2c582a2ea4b82010877bcbee7f83cb5ea2d1659555f23990e858020c0e69057c228
6
+ metadata.gz: 0e7e3dd16635ecbac89f7ad2cb2f62a59c29b71108e323dee2c050a9aedf62b7c1a304a977fe589322ae18044f5f2ffdbb1e22eb07ad9ee3e9e67045fa3d4614
7
+ data.tar.gz: 46f916e376facb3b487eb125e65916efca85b51c40c7ff4f090758e677ac37638cf81f07dec0e3279a61c67455d4c966948a6343eb4a26ed20ef3e76e0a3fafa
@@ -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]].compact,
109
- 'ipv6_addresses': [nic.ip6].compact,
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,
@@ -1,3 +1,3 @@
1
1
  module ForemanRhCloud
2
- VERSION = '1.0.16'.freeze
2
+ VERSION = '1.0.17'.freeze
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "foreman_rh_cloud",
3
- "version": "1.0.14",
3
+ "version": "1.0.17",
4
4
  "description": "Inventory Upload =============",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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
- refute actual_nic.key?('name')
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
@@ -141,7 +145,9 @@ class SliceGeneratorTest < ActiveSupport::TestCase
141
145
  assert_not_nil actual_host['mac_addresses'].find { |mac| mac == expected_mac }
142
146
  assert_not_nil(actual_system_profile = actual_host['system_profile'])
143
147
  assert_not_nil(actual_network_interfaces = actual_system_profile['network_interfaces'])
144
- assert_not_nil(actual_nic = actual_network_interfaces.find { |nic_node| nic_node['ipv4_addresses'].first == nic.ip })
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' })
145
151
  assert_equal nic.ip, actual_nic['ipv4_addresses'].first
146
152
  assert_equal nic.ip6, actual_nic['ipv6_addresses'].first
147
153
  assert_equal 1500, actual_nic['mtu']
@@ -152,6 +158,26 @@ class SliceGeneratorTest < ActiveSupport::TestCase
152
158
  assert_equal 1, generator.hosts_count
153
159
  end
154
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
+
155
181
  test 'generates obfuscated ip_address fields without inisghts-client' do
156
182
  FactoryBot.create(:setting, :name => 'obfuscate_inventory_ips', :value => true)
157
183
 
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.16
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: 2021-02-09 00:00:00.000000000 Z
11
+ date: 2021-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: katello