Skip to content

Commit

Permalink
Add additional fields for convert2RHEL
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremylenz committed Oct 30, 2024
1 parent f8f2f49 commit ffc1bfb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
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

0 comments on commit ffc1bfb

Please sign in to comment.