3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
# File 'lib/foreman_rh_cloud/plugin.rb', line 3
def self.register
return if Foreman::Plugin.find(:foreman_rh_cloud)
Foreman::Plugin.register :foreman_rh_cloud do
requires_foreman '>= 3.17'
register_gettext
apipie_documented_controllers ["#{ForemanRhCloud::Engine.root}/app/controllers/api/v2/**/*.rb"]
settings do
category(:rh_cloud, N_('Insights')) do
setting('allow_auto_inventory_upload', type: :boolean, description: N_('Enable automatic upload of your host inventory to the Red Hat cloud. Ignored when using local Insights.'), default: true, full_name: N_('Automatic inventory upload'))
setting('allow_auto_insights_sync', type: :boolean, description: N_('Enable automatic synchronization of Insights recommendations from the Red Hat cloud. Ignored when using local Insights.'), default: true, full_name: N_('Synchronize recommendations Automatically'))
setting('allow_auto_insights_mismatch_delete', type: :boolean, description: N_('Enable automatic deletion of mismatched host records from the Red Hat cloud. Ignored when using local Insights.'), default: false, full_name: N_('Automatic mismatch deletion'))
setting('obfuscate_inventory_hostnames', type: :boolean, description: N_('Obfuscate host names sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host names are not included in the report.) Ignored when using local Insights.'), default: false, full_name: N_('Obfuscate host names'))
setting('obfuscate_inventory_ips', type: :boolean, description: N_('Obfuscate ipv4 addresses sent to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored because host IPv4 addresses are not included in the report.) Ignored when using local Insights.'), default: false, full_name: N_('Obfuscate host ipv4 addresses.'))
setting('exclude_installed_packages', type: :boolean, description: N_('Exclude installed packages from being uploaded to the Red Hat cloud. (If insights_minimal_data_collection is set to true, this setting is ignored and installed packages are always excluded.) Ignored when using local Insights.'), default: false, full_name: N_("Exclude installed packages"))
setting('include_parameter_tags', type: :boolean, description: N_('Should import include parameter tags from Foreman? Ignored when using local Insights.'), default: false, full_name: N_('Include parameters in insights-client reports'))
setting('rhc_instance_id', type: :string, description: N_('RHC daemon id. Ignored when using local Insights.'), default: nil, full_name: N_('ID of the RHC(Yggdrasil) daemon'))
setting('insights_minimal_data_collection', type: :boolean, default: false, full_name: N_('Minimal data collection'), description: N_('Only include the minimum required data in inventory reports for uploading to Red Hat cloud. When this is true, installed packages are excluded from the report regardless of the exclude_installed_packages setting, and host names and IPv4 addresses are excluded from the report regardless of obfuscation settings. Ignored when using local Insights.'))
end
end
security_block :foreman_rh_cloud do
permission(
:generate_foreman_rh_cloud,
'foreman_inventory_upload/reports': [:generate],
'foreman_inventory_upload/tasks': [:create],
'api/v2/rh_cloud/inventory': [:get_hosts, :remove_hosts, :sync_inventory_status, :download_file, :generate_report, :enable_cloud_connector],
'foreman_inventory_upload/uploads': [:enable_cloud_connector],
'foreman_inventory_upload/uploads_settings': [:set_advanced_setting],
'foreman_inventory_upload/missing_hosts': [:remove_hosts],
'insights_cloud/settings': [:update],
'insights_cloud/tasks': [:create]
)
permission(
:view_foreman_rh_cloud,
'foreman_inventory_upload/accounts': [:index],
'foreman_inventory_upload/reports': [:last],
'foreman_inventory_upload/uploads': [:auto_upload, :show_auto_upload, :download_file, :last],
'foreman_inventory_upload/tasks': [:show],
'foreman_inventory_upload/cloud_status': [:index],
'foreman_inventory_upload/uploads_settings': [:index],
'foreman_inventory_upload/missing_hosts': [:index],
'api/v2/rh_cloud/advisor_engine_config': [:show],
'foreman_rh_cloud/foreman_rh_cloud': [:inventory_upload, :recommendations],
'react': [:index]
)
permission(
:view_insights_hits,
{
'/foreman_rh_cloud/insights_cloud': [:index],
'insights_cloud/hits': [:index, :show, :auto_complete_search, :resolutions],
'insights_cloud/settings': [:index, :show],
'insights_cloud/ui_requests': [:forward_request, :translate_insights_host],
'react': [:index],
},
:resource_type => ::InsightsHit.name
)
permission(
:dispatch_cloud_requests,
'api/v2/rh_cloud/cloud_request': [:update]
)
permission(
:control_organization_insights,
'insights_cloud/settings': [:set_org_parameter]
)
end
plugin_permissions = [:view_foreman_rh_cloud, :generate_foreman_rh_cloud, :view_insights_hits, :dispatch_cloud_requests, :control_organization_insights]
role 'ForemanRhCloud', plugin_permissions, 'Role granting permissions to view the hosts inventory,
generate a report, upload it to the cloud and download it locally'
add_permissions_to_default_roles Role::ORG_ADMIN => plugin_permissions,
Role::MANAGER => plugin_permissions,
Role::SYSTEM_ADMIN => plugin_permissions
:top_menu, :insights_menu, caption: N_('Insights'), icon: 'fa fa-cloud', after: :hosts_menu do
:top_menu,
:inventory_upload,
caption: N_('Inventory Upload'),
url: '/foreman_rh_cloud/inventory_upload',
url_hash: { controller: :react, action: :index },
parent: :insights_menu,
if: -> { !ForemanRhCloud.with_iop_smart_proxy? }
:top_menu, :insights_hits, caption: N_('Recommendations'), url: '/foreman_rh_cloud/insights_cloud', url_hash: { controller: :react, action: :index }, parent: :insights_menu
:top_menu,
:insights_vulnerability,
caption: N_('Vulnerability'),
url: '/foreman_rh_cloud/insights_vulnerability',
url_hash: { controller: :react, action: :index },
parent: :insights_menu,
if: -> { ForemanRhCloud.with_iop_smart_proxy? }
end
:admin_menu,
:inventory_upload,
caption: N_('Inventory Upload'),
url: '/foreman_rh_cloud/inventory_upload',
url_hash: { controller: :react, action: :index },
parent: :administer_menu,
before: :upgrade,
if: -> { ForemanRhCloud.with_iop_smart_proxy? }
register_facet InsightsFacet, :insights do
configure_host do
api_view :list => 'api/v2/hosts/insights/insights', :single => 'api/v2/hosts/insights/single'
set_dependent_action :destroy
end
end
register_global_js_file 'global'
register_custom_status InventorySync::InventoryStatus
register_custom_status InsightsClientReportStatus
if ForemanRhCloud.with_iop_smart_proxy?
register_ping_extension { ForemanRhCloud::Ping.ping }
register_status_extension { ForemanRhCloud::Ping.status }
end
describe_host do
overview_buttons_provider :insights_host_overview_buttons
end
extend_page 'hosts/show' do |context|
context.add_pagelet :main_tabs,
partial: 'hosts/insights_tab',
name: _('Insights'),
id: 'insights',
onlyif: proc { |host| host.insights }
end
extend_page 'hosts/_list' do |context|
context.with_profile :cloud, _('RH Cloud'), default: true do
add_pagelet :hosts_table_column_header, key: :insights_recommendations_count, label: _('Recommendations'), sortable: true, width: '12%', class: 'hidden-xs ellipsis', priority: 100,
export_data: CsvExporter::ExportDefinition.new(:insights_recommendations_count, callback: ->(host) { host&.insights_hits&.count })
add_pagelet :hosts_table_column_content, key: :insights_recommendations_count, callback: ->(host) { hits_counts_cell(host) }, class: 'hidden-xs ellipsis text-center', priority: 100
end
end
extend_template_helpers ForemanRhCloud::TemplateRendererHelper
allowed_template_helpers :remediations_playbook, :download_rh_playbook
end
end
|