foreman_inventory_upload 1.0.0.beta7 → 1.0.0
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/controllers/foreman_inventory_upload/accounts_controller.rb +39 -0
- data/app/controllers/foreman_inventory_upload/reports_controller.rb +3 -4
- data/app/controllers/foreman_inventory_upload/uploads_controller.rb +3 -3
- data/app/views/scripts/uploader.sh.erb +21 -9
- data/config/routes.rb +5 -5
- data/lib/foreman_inventory_upload.rb +14 -10
- data/lib/foreman_inventory_upload/async/generate_all_reports_job.rb +4 -7
- data/lib/foreman_inventory_upload/async/generate_report_job.rb +13 -9
- data/lib/foreman_inventory_upload/async/queue_for_upload_job.rb +7 -7
- data/lib/foreman_inventory_upload/async/upload_report_job.rb +22 -17
- data/lib/foreman_inventory_upload/generators/archived_report.rb +2 -2
- data/lib/foreman_inventory_upload/generators/queries.rb +18 -9
- data/lib/foreman_inventory_upload/generators/slice.rb +16 -9
- data/lib/foreman_inventory_upload/version.rb +1 -1
- data/lib/tasks/generator.rake +19 -5
- data/test/controllers/{statuses_controller_test.rb → accounts_controller_test.rb} +6 -7
- data/test/controllers/reports_controller_test.rb +3 -3
- data/test/controllers/uploads_controller_test.rb +3 -3
- data/test/unit/archived_report_generator_test.rb +3 -3
- data/test/unit/slice_generator_test.rb +22 -0
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.fixtures.js +5 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountList.js +11 -9
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListActions.js +3 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListReducer.js +7 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/AccountListSelectors.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.fixtures.js +1 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/ListItem.js +9 -7
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItem/__tests__/__snapshots__/ListItem.test.js.snap +6 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.fixtures.js +2 -1
- data/webpack/ForemanInventoryUpload/Components/AccountList/Components/ListItemStatus/ListItemStatus.js +5 -5
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListReducer.test.js +2 -2
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/AccountListSelectors.test.js +4 -4
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountList.test.js.snap +15 -12
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListReducer.test.js.snap +13 -10
- data/webpack/ForemanInventoryUpload/Components/AccountList/__tests__/__snapshots__/AccountListSelectors.test.js.snap +9 -3
- data/webpack/ForemanInventoryUpload/Components/AccountList/index.js +3 -6
- data/webpack/ForemanInventoryUpload/Components/Dashboard/Dashboard.js +5 -5
- data/webpack/ForemanInventoryUpload/Components/Dashboard/index.js +1 -4
- data/webpack/ForemanInventoryUpload/Components/NavContainer/__tests__/__snapshots__/NavContainer.test.js.snap +4 -4
- data/webpack/ForemanInventoryUpload/Components/StatusChart/StatusChart.js +4 -1
- metadata +7 -7
- data/app/controllers/foreman_inventory_upload/statuses_controller.rb +0 -41
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b18615a8878127f74e382f34b99c409d2a3cea180d40aaf4600660bf3e32875
|
4
|
+
data.tar.gz: fdabaddefa7099573546fe4f80a5ac3e406d2f52b1816efb7e433a958b73fe14
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1552fbef1b4ffadb0271a804d54b8782ebe9b39c0557686398e28fb72a159cddee7eea26e4ca65b86224a2fa596fa56b7e1d7237b03b9ef4eebf0f776cd32520
|
7
|
+
data.tar.gz: e6ddf50d580f4be2ef5575eed02cf5f448e273239f33449c80f79fb68fefb124ba3c92ec45e58ed6fcb4f2fedb6cc5a6c6a45577e8b00247ca4bbeab810e30c9
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module ForemanInventoryUpload
|
2
|
+
class AccountsController < ::ApplicationController
|
3
|
+
# override default "welcome screen behavior, since we don't have a model"
|
4
|
+
def welcome
|
5
|
+
true
|
6
|
+
end
|
7
|
+
|
8
|
+
def index
|
9
|
+
labels = Organization.all.pluck(:id, :name)
|
10
|
+
|
11
|
+
accounts = Hash[
|
12
|
+
labels.map do |id, label|
|
13
|
+
generate_report_status = status_for(id, ForemanInventoryUpload::Async::GenerateReportJob)
|
14
|
+
upload_report_status = status_for(id, ForemanInventoryUpload::Async::UploadReportJob)
|
15
|
+
|
16
|
+
[
|
17
|
+
id,
|
18
|
+
{
|
19
|
+
generate_report_status: generate_report_status,
|
20
|
+
upload_report_status: upload_report_status,
|
21
|
+
label: label,
|
22
|
+
},
|
23
|
+
]
|
24
|
+
end
|
25
|
+
]
|
26
|
+
|
27
|
+
render json: {
|
28
|
+
accounts: accounts,
|
29
|
+
}, status: :ok
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def status_for(label, job_class)
|
35
|
+
label = job_class.output_label(label)
|
36
|
+
ForemanInventoryUpload::Async::ProgressOutput.get(label)&.status
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module ForemanInventoryUpload
|
4
4
|
class ReportsController < ::ApplicationController
|
5
5
|
def last
|
6
|
-
label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(params[:
|
6
|
+
label = ForemanInventoryUpload::Async::GenerateReportJob.output_label(params[:organization_id])
|
7
7
|
output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
|
8
8
|
task_label = ForemanInventoryUpload::Async::GenerateAllReportsJob.singleton_job_name
|
9
9
|
scheduled = ForemanTasks::Task.where(
|
@@ -18,10 +18,9 @@ module ForemanInventoryUpload
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def generate
|
21
|
-
|
21
|
+
organization_id = params[:organization_id]
|
22
22
|
|
23
|
-
|
24
|
-
ForemanInventoryUpload::Async::GenerateReportJob.perform_later(generated_file_name, portal_user)
|
23
|
+
ForemanInventoryUpload::Async::GenerateReportJob.perform_later(ForemanInventoryUpload.generated_reports_folder, organization_id)
|
25
24
|
|
26
25
|
render json: {
|
27
26
|
action_status: 'success',
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module ForemanInventoryUpload
|
2
2
|
class UploadsController < ::ApplicationController
|
3
3
|
def last
|
4
|
-
label = ForemanInventoryUpload::Async::UploadReportJob.output_label(params[:
|
4
|
+
label = ForemanInventoryUpload::Async::UploadReportJob.output_label(params[:organization_id])
|
5
5
|
output = ForemanInventoryUpload::Async::ProgressOutput.get(label)&.full_output
|
6
6
|
|
7
7
|
render json: {
|
@@ -10,8 +10,8 @@ module ForemanInventoryUpload
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def download_file
|
13
|
-
filename =
|
14
|
-
path = Rails.root.join(ForemanInventoryUpload.uploads_folder
|
13
|
+
filename = ForemanInventoryUpload.facts_archive_name(params[:organization_id])
|
14
|
+
path = Rails.root.join(ForemanInventoryUpload.uploads_folder, filename)
|
15
15
|
unless File.exist? path
|
16
16
|
return throw_flash_error(
|
17
17
|
"Path doesn't exist: #{path}"
|
@@ -3,26 +3,38 @@
|
|
3
3
|
DEST=<%= @upload_url %>
|
4
4
|
RH_USERNAME=<%= @rh_username %>
|
5
5
|
|
6
|
-
if [ -z "$
|
6
|
+
if [ -z "$FILES" ]
|
7
7
|
then
|
8
|
-
|
8
|
+
FILES=./*.tar.gz
|
9
9
|
fi
|
10
10
|
|
11
|
-
if [ -
|
11
|
+
if [ -n "$CER_PATH" ]
|
12
12
|
then
|
13
|
-
|
14
|
-
|
13
|
+
AUTH_KEY="--cert"
|
14
|
+
AUTH_VAL="$CER_PATH"
|
15
|
+
else
|
16
|
+
if [ -z "$RH_USERNAME" ]
|
17
|
+
then
|
18
|
+
IFS= read -rp "Enter username: " RH_USERNAME
|
19
|
+
fi
|
15
20
|
|
16
|
-
if [ -z "$
|
17
|
-
then
|
18
|
-
|
21
|
+
if [ -z "$RH_PASSWORD" ]
|
22
|
+
then
|
23
|
+
IFS= read -rsp "Enter password: " RH_PASSWORD
|
24
|
+
fi
|
25
|
+
|
26
|
+
AUTH_KEY="-u"
|
27
|
+
AUTH_VAL="\"$RH_USERNAME\":\"$RH_PASSWORD\""
|
19
28
|
fi
|
20
29
|
|
30
|
+
# /tmp/a b/x.pem
|
31
|
+
# curl --cert /tmp/a\ b/x.pem
|
32
|
+
|
21
33
|
mkdir -p done
|
22
34
|
|
23
35
|
for f in $FILES
|
24
36
|
do
|
25
|
-
curl -k -vvv -# --fail -F "file=@$f;type=application/vnd.redhat.qpc.tar+tgz" $DEST
|
37
|
+
curl -k -vvv -# --fail -F "file=@$f;type=application/vnd.redhat.qpc.tar+tgz" $DEST "$AUTH_KEY" "$AUTH_VAL"
|
26
38
|
if [ $? -eq 0 ]; then
|
27
39
|
mv $f done/
|
28
40
|
echo "Done: $f"
|
data/config/routes.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
namespace :foreman_inventory_upload do
|
3
3
|
get 'index', to: 'react#index'
|
4
|
-
get ':
|
5
|
-
post ':
|
6
|
-
get ':
|
7
|
-
get ':
|
8
|
-
get '
|
4
|
+
get ':organization_id/reports/last', to: 'reports#last', constraints: { organization_id: %r{[^\/]+} }
|
5
|
+
post ':organization_id/reports', to: 'reports#generate', constraints: { organization_id: %r{[^\/]+} }
|
6
|
+
get ':organization_id/uploads/last', to: 'uploads#last', constraints: { organization_id: %r{[^\/]+} }
|
7
|
+
get ':organization_id/uploads/file', to: 'uploads#download_file', constraints: { organization_id: %r{[^\/]+} }
|
8
|
+
get 'accounts', to: 'accounts#index'
|
9
9
|
end
|
10
10
|
end
|
@@ -11,16 +11,20 @@ module ForemanInventoryUpload
|
|
11
11
|
)
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.uploads_folder
|
15
|
-
@
|
16
|
-
|
17
|
-
|
14
|
+
def self.uploads_folder
|
15
|
+
@uploads_folder ||= ensure_folder(
|
16
|
+
File.join(
|
17
|
+
ForemanInventoryUpload.base_folder,
|
18
|
+
'uploads/'
|
19
|
+
)
|
20
|
+
)
|
21
|
+
end
|
18
22
|
|
19
|
-
|
23
|
+
def self.generated_reports_folder
|
24
|
+
@generated_reports_folder ||= ensure_folder(
|
20
25
|
File.join(
|
21
26
|
ForemanInventoryUpload.base_folder,
|
22
|
-
'
|
23
|
-
"#{group}/"
|
27
|
+
'generated_reports/'
|
24
28
|
)
|
25
29
|
)
|
26
30
|
end
|
@@ -33,12 +37,12 @@ module ForemanInventoryUpload
|
|
33
37
|
'uploader.sh'
|
34
38
|
end
|
35
39
|
|
36
|
-
def self.facts_archive_name
|
37
|
-
|
40
|
+
def self.facts_archive_name(organization)
|
41
|
+
"report_for_#{organization}.tar.gz"
|
38
42
|
end
|
39
43
|
|
40
44
|
def self.upload_url
|
41
|
-
# for testing set ENV to 'https://ci.cloud.
|
45
|
+
# for testing set ENV to 'https://ci.cloud.redhat.com/api/ingress/v1/upload'
|
42
46
|
@upload_url ||= ENV['SATELLITE_INVENTORY_UPLOAD_URL'] || 'https://cloud.redhat.com/api/ingress/v1/upload'
|
43
47
|
end
|
44
48
|
|
@@ -2,13 +2,10 @@ module ForemanInventoryUpload
|
|
2
2
|
module Async
|
3
3
|
class GenerateAllReportsJob < ::ApplicationJob
|
4
4
|
def perform
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
portal_users.map do |portal_user|
|
10
|
-
generated_file_name = File.join(ForemanInventoryUpload.base_folder, "#{portal_user}.tar.gz")
|
11
|
-
GenerateReportJob.perform_later(generated_file_name, portal_user)
|
5
|
+
organizations = Organization.unscoped.all
|
6
|
+
|
7
|
+
organizations.map do |organization|
|
8
|
+
GenerateReportJob.perform_later(ForemanInventoryUpload.generated_reports_folder, organization.id)
|
12
9
|
end
|
13
10
|
ensure
|
14
11
|
self.class.set(:wait => 24.hours).perform_later
|
@@ -1,17 +1,21 @@
|
|
1
1
|
module ForemanInventoryUpload
|
2
2
|
module Async
|
3
3
|
class GenerateReportJob < ShellProcess
|
4
|
-
def self.output_label(
|
5
|
-
"report_for_#{
|
4
|
+
def self.output_label(label)
|
5
|
+
"report_for_#{label}"
|
6
6
|
end
|
7
7
|
|
8
|
-
def perform(
|
9
|
-
@
|
10
|
-
@
|
8
|
+
def perform(base_folder, organization)
|
9
|
+
@base_folder = base_folder
|
10
|
+
@organization = organization
|
11
11
|
|
12
|
-
super(GenerateReportJob.output_label(
|
12
|
+
super(GenerateReportJob.output_label(organization))
|
13
13
|
|
14
|
-
QueueForUploadJob.perform_later(
|
14
|
+
QueueForUploadJob.perform_later(
|
15
|
+
base_folder,
|
16
|
+
ForemanInventoryUpload.facts_archive_name(organization),
|
17
|
+
organization
|
18
|
+
)
|
15
19
|
end
|
16
20
|
|
17
21
|
def command
|
@@ -20,8 +24,8 @@ module ForemanInventoryUpload
|
|
20
24
|
|
21
25
|
def env
|
22
26
|
super.merge(
|
23
|
-
'target' => @
|
24
|
-
'
|
27
|
+
'target' => @base_folder,
|
28
|
+
'organization_id' => @organization
|
25
29
|
)
|
26
30
|
end
|
27
31
|
end
|
@@ -1,21 +1,22 @@
|
|
1
1
|
module ForemanInventoryUpload
|
2
2
|
module Async
|
3
3
|
class QueueForUploadJob < ::ApplicationJob
|
4
|
-
def perform(report_file,
|
5
|
-
@
|
4
|
+
def perform(base_folder, report_file, organization_id)
|
5
|
+
@base_folder = base_folder
|
6
|
+
@report_file = report_file
|
6
7
|
logger.debug('Ensuring objects')
|
7
8
|
ensure_ouput_folder
|
8
9
|
ensure_output_script
|
9
10
|
logger.debug("Copying #{report_file} to #{uploads_folder}")
|
10
|
-
enqueued_file_name = File.join(uploads_folder,
|
11
|
-
FileUtils.mv(report_file, enqueued_file_name)
|
11
|
+
enqueued_file_name = File.join(uploads_folder, report_file)
|
12
|
+
FileUtils.mv(File.join(base_folder, report_file), enqueued_file_name)
|
12
13
|
logger.debug("Done copying #{report_file} to #{enqueued_file_name}")
|
13
14
|
|
14
|
-
UploadReportJob.perform_later(enqueued_file_name,
|
15
|
+
UploadReportJob.perform_later(enqueued_file_name, organization_id)
|
15
16
|
end
|
16
17
|
|
17
18
|
def uploads_folder
|
18
|
-
@uploads_folder ||= ForemanInventoryUpload.uploads_folder
|
19
|
+
@uploads_folder ||= ForemanInventoryUpload.uploads_folder
|
19
20
|
end
|
20
21
|
|
21
22
|
def script_file
|
@@ -36,7 +37,6 @@ module ForemanInventoryUpload
|
|
36
37
|
source: template_src,
|
37
38
|
variables: {
|
38
39
|
upload_url: ForemanInventoryUpload.upload_url,
|
39
|
-
rh_username: @portal_user,
|
40
40
|
}
|
41
41
|
)
|
42
42
|
script_source = Foreman::Renderer.render(template_src, scope)
|
@@ -1,15 +1,23 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
|
1
3
|
module ForemanInventoryUpload
|
2
4
|
module Async
|
3
5
|
class UploadReportJob < ShellProcess
|
4
|
-
def self.output_label(
|
5
|
-
"upload_for_#{
|
6
|
+
def self.output_label(label)
|
7
|
+
"upload_for_#{label}"
|
6
8
|
end
|
7
9
|
|
8
|
-
def perform(filename,
|
9
|
-
@portal_user = portal_user
|
10
|
+
def perform(filename, organization_id)
|
10
11
|
@filename = filename
|
12
|
+
@organization = Organization.find(organization_id)
|
11
13
|
|
12
|
-
|
14
|
+
Tempfile.create([@organization.name, '.pem']) do |cer_file|
|
15
|
+
cer_file.write(rh_credentials[:cert])
|
16
|
+
cer_file.write(rh_credentials[:key])
|
17
|
+
cer_file.flush
|
18
|
+
@cer_path = cer_file.path
|
19
|
+
super(UploadReportJob.output_label(organization_id))
|
20
|
+
end
|
13
21
|
end
|
14
22
|
|
15
23
|
def command
|
@@ -18,22 +26,19 @@ module ForemanInventoryUpload
|
|
18
26
|
|
19
27
|
def env
|
20
28
|
super.merge(
|
21
|
-
'
|
22
|
-
'
|
23
|
-
'FILES' => @filename
|
29
|
+
'FILES' => @filename,
|
30
|
+
'CER_PATH' => @cer_path
|
24
31
|
)
|
25
32
|
end
|
26
33
|
|
27
34
|
def rh_credentials
|
28
|
-
@rh_credentials ||=
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
def rh_password
|
36
|
-
rh_credentials.portal_password
|
35
|
+
@rh_credentials ||= begin
|
36
|
+
candlepin_id_certificate = @organization.owner_details['upstreamConsumer']['idCert']
|
37
|
+
{
|
38
|
+
cert: candlepin_id_certificate['cert'],
|
39
|
+
key: candlepin_id_certificate['key'],
|
40
|
+
}
|
41
|
+
end
|
37
42
|
end
|
38
43
|
end
|
39
44
|
end
|
@@ -6,10 +6,10 @@ module ForemanInventoryUpload
|
|
6
6
|
@logger = logger
|
7
7
|
end
|
8
8
|
|
9
|
-
def render(
|
9
|
+
def render(organization:)
|
10
10
|
Dir.mktmpdir do |tmpdir|
|
11
11
|
@logger.info "Started generating hosts report in #{tmpdir}"
|
12
|
-
host_batches = ForemanInventoryUpload::Generators::Queries.
|
12
|
+
host_batches = ForemanInventoryUpload::Generators::Queries.for_org(organization)
|
13
13
|
File.open(File.join(tmpdir, 'metadata.json'), 'w') do |metadata_out|
|
14
14
|
metadata_generator = ForemanInventoryUpload::Generators::Metadata.new(metadata_out)
|
15
15
|
metadata_generator.render do |inner_generator|
|
@@ -17,6 +17,7 @@ module ForemanInventoryUpload
|
|
17
17
|
'distribution::name',
|
18
18
|
'uname::release',
|
19
19
|
'lscpu::flags',
|
20
|
+
'distribution::version',
|
20
21
|
]).pluck(:name, :id)
|
21
22
|
]
|
22
23
|
end
|
@@ -37,15 +38,23 @@ module ForemanInventoryUpload
|
|
37
38
|
end
|
38
39
|
|
39
40
|
def self.for_report(portal_user)
|
40
|
-
org_ids =
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
41
|
+
org_ids = organizations_for_user(portal_user).pluck(:id)
|
42
|
+
for_slice(Host.unscoped.where(organization_id: org_ids)).in_batches(of: 1_000)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.for_org(organization_id)
|
46
|
+
for_slice(Host.unscoped.where(organization_id: organization_id)).in_batches(of: 1_000)
|
47
|
+
end
|
48
|
+
|
49
|
+
def self.organizations_for_user(portal_user)
|
50
|
+
Organization
|
51
|
+
.joins(:telemetry_configuration)
|
52
|
+
.where(
|
53
|
+
redhat_access_telemetry_configurations: {
|
54
|
+
portal_user: portal_user,
|
55
|
+
enable_telemetry: true,
|
56
|
+
}
|
57
|
+
)
|
49
58
|
end
|
50
59
|
end
|
51
60
|
end
|
@@ -23,14 +23,14 @@ module ForemanInventoryUpload
|
|
23
23
|
first = true
|
24
24
|
hosts_batch.each do |host|
|
25
25
|
@stream.comma unless first
|
26
|
-
first = false
|
27
|
-
report_host(host)
|
26
|
+
first = false if report_host(host)
|
28
27
|
end
|
29
28
|
end
|
30
29
|
end
|
31
30
|
end
|
32
31
|
|
33
32
|
def report_host(host)
|
33
|
+
return nil unless host&.subscription_facet&.pools&.first
|
34
34
|
@stream.object do
|
35
35
|
@stream.simple_field('display_name', host.name)
|
36
36
|
@stream.simple_field('fqdn', host.fqdn)
|
@@ -56,13 +56,7 @@ module ForemanInventoryUpload
|
|
56
56
|
@stream.object do
|
57
57
|
@stream.simple_field('namespace', 'satellite')
|
58
58
|
@stream.object_field('facts', :last) do
|
59
|
-
|
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)
|
59
|
+
report_satellite_facts(host)
|
66
60
|
end
|
67
61
|
end
|
68
62
|
end
|
@@ -120,6 +114,19 @@ module ForemanInventoryUpload
|
|
120
114
|
end
|
121
115
|
end
|
122
116
|
|
117
|
+
def report_satellite_facts(host)
|
118
|
+
@stream.simple_field('virtual_host_name', host.subscription_facet.hypervisor_host&.name)
|
119
|
+
@stream.simple_field('virtual_host_uuid', host.subscription_facet.hypervisor_host&.subscription_facet&.uuid)
|
120
|
+
if defined?(ForemanThemeSatellite)
|
121
|
+
@stream.simple_field('satellite_version', ForemanThemeSatellite::SATELLITE_VERSION)
|
122
|
+
end
|
123
|
+
@stream.simple_field('system_purpose_usage', host.subscription_facet.purpose_usage)
|
124
|
+
@stream.simple_field('system_purpose_role', host.subscription_facet.purpose_role)
|
125
|
+
@stream.simple_field('distribution_version', fact_value(host, 'distribution::version'))
|
126
|
+
@stream.simple_field('satellite_instance_id', Foreman.respond_to?(:instance_id) ? Foreman.instance_id : nil)
|
127
|
+
@stream.simple_field('organization_id', host.organization_id, :last)
|
128
|
+
end
|
129
|
+
|
123
130
|
def fact_value(host, fact_name)
|
124
131
|
value_record = host.fact_values.find do |fact_value|
|
125
132
|
fact_value.fact_name_id == ForemanInventoryUpload::Generators::Queries.fact_names[fact_name]
|