foreman_inventory_upload 1.0.0.beta6 → 1.0.0.beta7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/foreman_inventory_upload.rb +2 -1
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +1 -2
- data/lib/foreman_inventory_upload/generators/queries.rb +1 -1
- data/lib/foreman_inventory_upload/generators/slice.rb +15 -1
- data/lib/foreman_inventory_upload/version.rb +1 -1
- data/test/unit/slice_generator_test.rb +52 -0
- metadata +2 -3
- data/app/assets/stylesheets/foreman_inventory_upload/foreman_inventory_upload.scss +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85837a58f5c5a76038117ea20c6a10873e8c87add4841c8fb08d29e69564b7f8
|
4
|
+
data.tar.gz: 652f7cac5cc2a3b861d82092257f0f683563aca3301f0c8a547ffc1cdfce89d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 751a08aec0fafcc07496027d72dd087756f366acd6da686ea67833a3b2502fbffbd677734a122addd77b1213b35c61eee35736026617c43ae0ae866f2abd6632
|
7
|
+
data.tar.gz: bb8ba3a8aaad6e5ef7994aff64d42b3848d0855187b6bd1c91205c010b2c7aaeb89236678f69bd81d4f179bcd9e2a5faab8c4842410f6908d15c167bc45ecb07
|
@@ -38,7 +38,8 @@ module ForemanInventoryUpload
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def self.upload_url
|
41
|
-
'https://ci.cloud.paas.psi.redhat.com/api/ingress/v1/upload'
|
41
|
+
# for testing set ENV to 'https://ci.cloud.paas.psi.redhat.com/api/ingress/v1/upload'
|
42
|
+
@upload_url ||= ENV['SATELLITE_INVENTORY_UPLOAD_URL'] || 'https://cloud.redhat.com/api/ingress/v1/upload'
|
42
43
|
end
|
43
44
|
|
44
45
|
def self.ensure_folder(folder)
|
@@ -49,9 +49,23 @@ module ForemanInventoryUpload
|
|
49
49
|
@stream.stringify_value(nic.mac) if nic.mac
|
50
50
|
end.compact.join(', '))
|
51
51
|
end
|
52
|
-
@stream.object_field('system_profile'
|
52
|
+
@stream.object_field('system_profile') do
|
53
53
|
report_system_profile(host)
|
54
54
|
end
|
55
|
+
@stream.array_field('facts', :last) do
|
56
|
+
@stream.object do
|
57
|
+
@stream.simple_field('namespace', 'satellite')
|
58
|
+
@stream.object_field('facts', :last) do
|
59
|
+
@stream.simple_field('virtual_host_name', host.subscription_facet.hypervisor_host&.name)
|
60
|
+
@stream.simple_field('virtual_host_uuid', host.subscription_facet.hypervisor_host&.subscription_facet&.uuid)
|
61
|
+
if defined?(ForemanThemeSatellite)
|
62
|
+
@stream.simple_field('satellite_version', ForemanThemeSatellite::SATELLITE_VERSION)
|
63
|
+
end
|
64
|
+
@stream.simple_field('satellite_instance_id', Foreman.respond_to?(:instance_id) ? Foreman.instance_id : nil)
|
65
|
+
@stream.simple_field('organization_id', host.organization_id, :last)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
55
69
|
end
|
56
70
|
end
|
57
71
|
|
@@ -57,4 +57,56 @@ class ReportGeneratorTest < ActiveSupport::TestCase
|
|
57
57
|
assert_equal @host.fqdn, actual_host['fqdn']
|
58
58
|
assert_equal '1234', actual_host['account']
|
59
59
|
end
|
60
|
+
|
61
|
+
test 'generates a report with satellite facts' do
|
62
|
+
Foreman.expects(:instance_id).returns('satellite-id')
|
63
|
+
batch = Host.where(id: @host.id).in_batches.first
|
64
|
+
generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice-123')
|
65
|
+
|
66
|
+
json_str = generator.render
|
67
|
+
actual = JSON.parse(json_str.join("\n"))
|
68
|
+
|
69
|
+
facts = actual['hosts'].first['facts'].first
|
70
|
+
assert_equal 'satellite', facts['namespace']
|
71
|
+
satellite_facts = facts['facts']
|
72
|
+
assert_equal 'satellite-id', satellite_facts['satellite_instance_id']
|
73
|
+
assert_equal @host.organization_id, satellite_facts['organization_id']
|
74
|
+
|
75
|
+
version = satellite_facts['satellite_version']
|
76
|
+
if defined?(ForemanThemeSatellite)
|
77
|
+
assert_equal ForemanThemeSatellite::SATELLITE_VERSION, version
|
78
|
+
else
|
79
|
+
assert_nil version
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
test 'generates a report for a host with hypervisor' do
|
84
|
+
hypervisor_host = FactoryBot.create(
|
85
|
+
:host,
|
86
|
+
:with_subscription,
|
87
|
+
:with_content,
|
88
|
+
content_view: @host.content_view,
|
89
|
+
lifecycle_environment: @host.lifecycle_environment,
|
90
|
+
organization: @host.organization
|
91
|
+
)
|
92
|
+
|
93
|
+
@host.subscription_facet.hypervisor_host = hypervisor_host
|
94
|
+
@host.save!
|
95
|
+
|
96
|
+
batch = Host.where(id: @host.id).in_batches.first
|
97
|
+
generator = ForemanInventoryUpload::Generators::Slice.new(batch, [], 'slice_123')
|
98
|
+
|
99
|
+
json_str = generator.render
|
100
|
+
actual = JSON.parse(json_str.join("\n"))
|
101
|
+
|
102
|
+
assert_equal 'slice_123', actual['report_slice_id']
|
103
|
+
assert_not_nil(actual_host = actual['hosts'].first)
|
104
|
+
assert_equal @host.name, actual_host['display_name']
|
105
|
+
assert_equal @host.fqdn, actual_host['fqdn']
|
106
|
+
assert_not_nil(host_facts = actual_host['facts']&.first)
|
107
|
+
assert_equal 'satellite', host_facts['namespace']
|
108
|
+
assert_not_nil(fact_values = host_facts['facts'])
|
109
|
+
assert_equal hypervisor_host.name, fact_values['virtual_host_name']
|
110
|
+
assert_equal hypervisor_host.subscription_facet.uuid, fact_values['virtual_host_uuid']
|
111
|
+
end
|
60
112
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: foreman_inventory_upload
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.beta7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inventory upload team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: katello
|
@@ -104,7 +104,6 @@ files:
|
|
104
104
|
- LICENSE
|
105
105
|
- README.md
|
106
106
|
- Rakefile
|
107
|
-
- app/assets/stylesheets/foreman_inventory_upload/foreman_inventory_upload.scss
|
108
107
|
- app/controllers/foreman_inventory_upload/react_controller.rb
|
109
108
|
- app/controllers/foreman_inventory_upload/reports_controller.rb
|
110
109
|
- app/controllers/foreman_inventory_upload/statuses_controller.rb
|
File without changes
|