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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 219f74e70847fcdcf6247367ca4aac22ae1dc8559ab093cb270162e95f822649
4
- data.tar.gz: '09c1da91fec5a53ae8ac155d18c65344108e22e1e3ab20e5fd02466efc966ba5'
3
+ metadata.gz: 85837a58f5c5a76038117ea20c6a10873e8c87add4841c8fb08d29e69564b7f8
4
+ data.tar.gz: 652f7cac5cc2a3b861d82092257f0f683563aca3301f0c8a547ffc1cdfce89d6
5
5
  SHA512:
6
- metadata.gz: b83ea5584d689c0fcbcb14db5684237c0f0eee6d56f7ab2de7e0c6cb6c7e6aa39ceb95a00c55aa63b2bec99e1fe3a9b25b65ce215f7a72c70d8ecbd2f457fbfa
7
- data.tar.gz: 8851522e1609dcbe51f1b5c7eb9661d2026b17a18d728e31c960aa2d594d3aa001ab7134e834fa7193759f6d593e8d128144ee5f9d17f90547528c194b38911d
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)
@@ -15,8 +15,7 @@ module ForemanInventoryUpload
15
15
  end
16
16
 
17
17
  def command
18
- prefix = Rails.env.production? ? 'foreman-' : ''
19
- "#{prefix}rake foreman_inventory_upload:report:generate"
18
+ 'rake foreman_inventory_upload:report:generate'
20
19
  end
21
20
 
22
21
  def env
@@ -31,7 +31,7 @@ module ForemanInventoryUpload
31
31
  :installed_packages,
32
32
  :content_facet,
33
33
  :host_statuses,
34
- subscription_facet: [:pools, :installed_products]
34
+ subscription_facet: [:pools, :installed_products, :hypervisor_host]
35
35
  )
36
36
  .merge(fact_values)
37
37
  end
@@ -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', :last) do
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
 
@@ -1,3 +1,3 @@
1
1
  module ForemanInventoryUpload
2
- VERSION = '1.0.0.beta6'.freeze
2
+ VERSION = '1.0.0.beta7'.freeze
3
3
  end
@@ -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.beta6
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-09-15 00:00:00.000000000 Z
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