11.8. 创建报告模板以监控权利
您可以使用报告模板返回具有特定订阅的主机列表,并显示这些主机的内核数。有关编写模板的更多信息,请参阅 附录 A, 模板编写参考。
流程
- 在 Satellite Web UI 中,进入到 Monitor > Reports > Report Templates。
- 点 Create Template。
可选:在 Editor 字段中,使用
<%# >
标签添加注释,其中的信息可能有助于以后参考。例如:<%# name: Entitlements snippet: false model: ReportTemplate require: - plugin: katello version: 3.14.0 -%>
使用
load_hosts ()
宏添加一行,并使用以下方法之一和变量填充宏:<%- load_hosts(includes: [:lifecycle_environment, :operatingsystem, :architecture, :content_view, :organization, :reported_data, :subscription_facet, :pools => [:subscription]]).each_record do |host| -%>
要查看您可以使用的变量列表,请点 Help 选项卡,并在 Safe 模式方法和变量 表中找到 Host::Managed 行。
添加一个带有
each
方法的host.pools
变量的一行,例如:<%- host.pools.each do |pool| -%>
使用
report_row ()
方法添加一行,以创建报告并添加您要作为报告的一部分的目标变量:<%- report_row( 'Name': host.name, 'Organization': host.organization, 'Lifecycle Environment': host.lifecycle_environment, 'Content View': host.content_view, 'Host Collections': host.host_collections, '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(host), 'Subscription Name': sub_name(pool), 'Subscription Type': pool.type, 'Subscription Quantity': pool.quantity, '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) ) -%>
在模板中添加结束语句:
<%- end -%> <%- end -%>
要生成报告,您必须添加 <%
= report_render -%>
宏:<%= report_render -%>
- 点 Submit 以保存模板。