Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add additional fields for convert2RHEL #914

Merged
merged 1 commit into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions lib/foreman_inventory_upload/generators/queries.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,16 @@ def self.fact_names
'insights_client::hostname',
'insights_client::ips',
'insights_id',
'conversions::activity',
'conversions::packages::0::nevra',
'conversions::packages::0::signature',
'conversions::activity_started',
'conversions::activity_ended',
'conversions::success',
'conversions::source_os::name',
'conversions::source_os::version',
'conversions::target_os::name',
'conversions::target_os::version',
]).pluck(:name, :id)
]
end
Expand Down
24 changes: 23 additions & 1 deletion lib/foreman_inventory_upload/generators/slice.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,36 @@ def report_slice(hosts_batch)
end
end

def report_conversions(host)
@stream.simple_field('convert2rhel_through_foreman', host.subscription_facet&.convert2rhel_through_foreman)
@stream.simple_field('activity', fact_value(host, 'conversions::activity'))
@stream.simple_field('packages_0_nevra', fact_value(host, 'conversions::packages::0::nevra'))
@stream.simple_field('packages_0_signature', fact_value(host, 'conversions::packages::0::signature'))
@stream.simple_field('activity_started', fact_value(host, 'conversions::activity_started'))
@stream.simple_field('activity_ended', fact_value(host, 'conversions::activity_ended'))
@stream.simple_field('success', fact_value(host, 'conversions::success') || false, :last)
end

def report_host(host)
host_ips_cache = host_ips(host)
@stream.object do
@stream.simple_field('fqdn', fqdn(host))
@stream.simple_field('account', account_id(host.organization).to_s)
@stream.simple_field('subscription_manager_id', uuid_value!(host.subscription_facet&.uuid))
@stream.simple_field('satellite_id', uuid_value!(host.subscription_facet&.uuid))
@stream.simple_field('convert2rhel_through_foreman', host.subscription_facet&.convert2rhel_through_foreman)
if host.subscription_facet&.convert2rhel_through_foreman.present?
@stream.object_field('conversions') do
@stream.object_field('source_os') do
@stream.simple_field('name', fact_value(host, 'conversions::source_os::name'))
@stream.simple_field('version', fact_value(host, 'conversions::source_os::version') || 'Unknown - Fact not reported', :last)
end
@stream.object_field('target_os') do
@stream.simple_field('name', fact_value(host, 'conversions::target_os::name'))
@stream.simple_field('version', fact_value(host, 'conversions::target_os::version') || 'Unknown - Fact not reported', :last)
end
report_conversions(host)
end
end
@stream.simple_field('bios_uuid', bios_uuid(host))
@stream.simple_field('vm_uuid', uuid_value(fact_value(host, 'virt::uuid')))
@stream.simple_field('insights_id', uuid_value(fact_value(host, 'insights_id')))
Expand Down