Skip to content

Commit

Permalink
Fixes #36826 - Add Host - Installed Products report
Browse files Browse the repository at this point in the history
* Add system purpose role and usage to subscriptions entitlement report
  • Loading branch information
ianballou committed Oct 18, 2023
1 parent 2ae0516 commit 8f35c6f
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 31 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<%#
name: Host - Installed Products
snippet: false
model: ReportTemplate
template_inputs:
- name: Hosts filter
required: false
input_type: user
description: Limit the report only on hosts found by this search query. Keep empty
to report on all available hosts.
advanced: false
value_type: search
resource_type: Host
require:
- plugin: katello
version: 4.11.0
-%>
<%- report_headers 'Host Name', 'Organization', 'Lifecycle Environment', 'Content View', 'Host Collections', 'Virtual', 'Guest of Host', 'OS', 'Arch', 'Sockets', 'RAM (MB)', 'Cores', 'SLA', 'Role', 'Usage', 'Release Version', 'Products', 'Last Checkin' -%>
<%- load_hosts(search: input('Hosts filter'), includes: [:operatingsystem, :architecture, :content_view_environments, :organization, :reported_data, :subscription_facet]).each_record do |host| -%>
<%- report_row(
'Host Name': host.name,
'Organization': host.organization,
'Lifecycle Environment': host.single_lifecycle_environment,
'Content View': host.single_content_view,
'Host Collections': host_collections_names(host),
'Virtual': host.virtual,
'Guest of Host': host.hypervisor_host,
'OS': host.operatingsystem,
'Arch': host.architecture,
'Sockets': host.sockets,
'RAM (MB)': host.ram,
'Cores': host.cores,
'SLA': host_sla(host),
'Role': host.purpose_role,
'Usage': host.purpose_usage,
'Release Version': host.release_version,
'Products': host_products_names_and_ids(host),
'Last Checkin': last_checkin(host).to_s,
) -%>
<%- end -%>
<%= report_render -%>
Original file line number Diff line number Diff line change
Expand Up @@ -12,45 +12,50 @@ template_inputs:
options: "no limit\r\n7\r\n30\r\n60\r\n90\r\n120\r\n180"
require:
- plugin: katello
version: 4.8.0
version: 4.11.0
-%>
<%- days_from_now = input('Days from Now') -%>
<%- days_from_now = "" if days_from_now == 'no limit' -%>
<%- should_filter = days_from_now.present? -%>
<%- report_headers 'Host Name', 'Organization', 'Lifecycle Environment', 'Content View', 'Host Collections', 'Virtual', 'Guest of Host', 'OS', 'Arch', 'Sockets', 'RAM', 'Cores', 'SLA', 'Products', 'Last Checkin', 'Subscription Name', 'Subscription Type', 'Subscription Total Quantity', 'Subscription Total Consumed', 'Subscriptions Consumed by Host', 'Subscription SKU', 'Subscription Contract', 'Subscription Account', 'Subscription Start', 'Subscription End', 'Subscription Guest', 'Days Remaining' -%>
<%- report_headers 'Host Name', 'Organization', 'Lifecycle Environment', 'Content View', 'Host Collections', 'Virtual', 'Guest of Host', 'OS', 'Arch', 'Sockets', 'RAM (MB)', 'Cores', 'SLA', 'Role', 'Usage', 'Release Version', 'Products', 'Last Checkin', 'Subscription Name', 'Subscription Type', 'Subscription Total Quantity', 'Subscription Total Consumed', 'Subscriptions Consumed by Host', 'Subscription SKU', 'Subscription Contract', 'Subscription Account', 'Subscription Start', 'Subscription End', 'Subscription Guest', 'Days Remaining' -%>
<%- load_hosts(includes: [:operatingsystem, :architecture, :content_view_environments, :organization, :reported_data, :subscription_facet, :pools => [:subscription]], -%>
<%- search: should_filter && "pools_expiring_in_days = #{days_from_now}" -%>
<%- ).each_record do |host| -%>
<%- host.pools.expiring_in_days(days_from_now).sort_by { |p| p.end_date }.each do |pool| -%>
<%- report_row(
'Host Name': host.name,
'Organization': host.organization,
'Lifecycle Environment': host.single_lifecycle_environment.name,
'Content View': host.single_content_view.name,
'Host Collections': host_collections_names(host),
'Virtual': host.virtual,
'Guest of Host': host.hypervisor_host,
'OS': host.operatingsystem,
'Arch': host.architecture,
'Sockets': host.sockets,
'RAM': host.ram,
'Cores': host.cores,
'SLA': host_sla(host),
'Products': host_products_names(host),
'Last Checkin': last_checkin(host).to_s,
'Subscription Name': sub_name(pool),
'Subscription Type': pool.type,
'Subscription Total Quantity': pool.quantity,
'Subscription Total Consumed': pool.consumed,
'Subscriptions Consumed by Host': host.filtered_entitlement_quantity_consumed(pool),
'Subscription SKU': sub_sku(pool),
'Subscription Contract': pool.contract_number,
'Subscription Account': pool.account_number,
'Subscription Start': pool.start_date,
'Subscription End': pool.end_date,
'Subscription Guest': registered_through(host),
'Days Remaining': pool.days_until_expiration
) -%>
<%- unless host.organization.simple_content_access? -%>
<%- report_row(
'Host Name': host.name,
'Organization': host.organization,
'Lifecycle Environment': host.single_lifecycle_environment.name,
'Content View': host.single_content_view.name,
'Host Collections': host_collections_names(host),
'Virtual': host.virtual,
'Guest of Host': host.hypervisor_host,
'OS': host.operatingsystem,
'Arch': host.architecture,
'Sockets': host.sockets,
'RAM (MB)': host.ram,
'Cores': host.cores,
'SLA': host_sla(host),
'Role': host.purpose_role,
'Usage': host.purpose_usage,
'Release Version': host.release_version,
'Products': host_products_names(host),
'Last Checkin': last_checkin(host).to_s,
'Subscription Name': sub_name(pool),
'Subscription Type': pool.type,
'Subscription Total Quantity': pool.quantity,
'Subscription Total Consumed': pool.consumed,
'Subscriptions Consumed by Host': host.filtered_entitlement_quantity_consumed(pool),
'Subscription SKU': sub_sku(pool),
'Subscription Contract': pool.contract_number,
'Subscription Account': pool.account_number,
'Subscription Start': pool.start_date,
'Subscription End': pool.end_date,
'Subscription Guest': registered_through(host),
'Days Remaining': pool.days_until_expiration
) -%>
<%- end -%>
<%- end -%>
<%- end -%>
<%= report_render -%>
10 changes: 10 additions & 0 deletions db/migrate/20231016000000_introduce_host_products_report.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class IntroduceHostProductsReport < ActiveRecord::Migration[6.1]
def up
token = SecureRandom.base64(5)
ReportTemplate.unscoped.find_by(name: "Host - Installed Products")&.update_columns(:name => "Host - Installed Products #{token}")
end

def down
ReportTemplate.unscoped.find_by(name: "Host - Installed Products")&.delete
end
end

0 comments on commit 8f35c6f

Please sign in to comment.