Module: Katello::HostsAndHostgroupsHelper
Instance Method Summary
collapse
#errata_counts, #host_checkin_time, #host_registered_time, #host_status_icon, #hosts_change_content_source
#host_hostgroup_kickstart_repository_id, #kickstart_repository_id, #kickstart_repository_options, #os_updated_kickstart_options, #use_install_media
#blank_or_inherit_cve, #blank_or_inherit_with_id, #build_cve_option_tags, #build_cve_options_for_orgs, #content_options, #content_source_options, #content_view_environment_options, #content_views_for_host, #fetch_cves_for_org, #filter_cves_by_content_source, #lifecycle_environment_options, #view_to_options
Instance Method Details
#accessible_content_proxies(obj) ⇒ Object
100
101
102
103
104
105
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 100
def accessible_content_proxies(obj)
list = accessible_resource_records(:smart_proxy).with_content.order(:name).to_a
current = obj.content_source
list |= [current] if current.present?
list
end
|
#accessible_lifecycle_environments(org, host_or_hostgroup) ⇒ Object
89
90
91
92
93
94
95
96
97
98
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 89
def accessible_lifecycle_environments(org, host_or_hostgroup)
selected = if host_or_hostgroup.is_a?(::Host::Managed)
host_or_hostgroup.try(:single_lifecycle_environment)
else
host_or_hostgroup.lifecycle_environment
end
envs = org.kt_environments.readable.order(:name)
envs |= [selected] if selected.present? && org == selected.organization
envs
end
|
#content_source_inherited?(host) ⇒ Boolean
19
20
21
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 19
def content_source_inherited?(host)
!using_hostgroups_page? && host&.content_source.blank? && host&.hostgroup&.content_source.present? && cv_lce_disabled?
end
|
#content_view_inherited?(host) ⇒ Boolean
27
28
29
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 27
def content_view_inherited?(host)
!using_hostgroups_page? && host&.content_views&.empty? && host&.hostgroup&.content_view.present? && cv_lce_disabled?
end
|
#cv_lce_disabled? ⇒ Boolean
15
16
17
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 15
def cv_lce_disabled?
edit_action? && !using_discovered_hosts_page?
end
|
#edit_action? ⇒ Boolean
11
12
13
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 11
def edit_action?
params[:action] == 'edit'
end
|
#fetch_content_source(host_or_hostgroup, options = {}) ⇒ Object
79
80
81
82
83
84
85
86
87
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 79
def fetch_content_source(host_or_hostgroup, options = {})
return host_or_hostgroup.content_source if host_or_hostgroup.content_source_id&.present? && host_or_hostgroup.persisted?
if host_or_hostgroup.is_a?(::Hostgroup) && host_or_hostgroup.content_facet.present?
return host_or_hostgroup.content_facet.content_source
end
selected_host_group = options.fetch(:selected_host_group, nil)
return selected_host_group.content_source if selected_host_group.present?
end
|
#fetch_content_view(host_or_hostgroup, options = {}) ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 62
def fetch_content_view(host_or_hostgroup, options = {})
return host_or_hostgroup.single_content_view if host_or_hostgroup.try(:single_content_view)
return host_or_hostgroup.content_view if host_or_hostgroup.try(:content_view)
if host_or_hostgroup.is_a?(::Hostgroup) && host_or_hostgroup.content_facet.present?
return host_or_hostgroup.content_facet.content_view
end
selected_host_group = options.fetch(:selected_host_group, nil)
return selected_host_group.content_view if selected_host_group.present?
end
|
#fetch_content_view_environment(hostgroup, options = {}) ⇒ Object
73
74
75
76
77
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 73
def fetch_content_view_environment(hostgroup, options = {})
return hostgroup.content_facet.content_view_environment if hostgroup.content_facet.present?
selected_host_group = options.fetch(:selected_host_group, nil)
return selected_host_group.content_facet.content_view_environment if selected_host_group&.content_facet.present?
end
|
#fetch_inherited_param(id, entity, parent_value) ⇒ Object
118
119
120
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 118
def fetch_inherited_param(id, entity, parent_value)
id.blank? ? parent_value : entity.find(id)
end
|
#fetch_lifecycle_environment(host_or_hostgroup, options = {}) ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 51
def fetch_lifecycle_environment(host_or_hostgroup, options = {})
return host_or_hostgroup.single_lifecycle_environment if host_or_hostgroup.try(:single_lifecycle_environment)
return host_or_hostgroup.lifecycle_environment if host_or_hostgroup.try(:lifecycle_environment)
if host_or_hostgroup.is_a?(::Hostgroup) && host_or_hostgroup.content_facet.present?
return host_or_hostgroup.content_facet.lifecycle_environment
end
selected_host_group = options.fetch(:selected_host_group, nil)
return selected_host_group.lifecycle_environment if selected_host_group.present?
end
|
#kickstart_repo_inheritable?(host) ⇒ Boolean
31
32
33
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 31
def kickstart_repo_inheritable?(host)
host&.kickstart_repository_id.blank?
end
|
#kt_ak_label ⇒ Object
7
8
9
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 7
def kt_ak_label
"kt_activation_keys"
end
|
#lifecycle_environment_inherited?(host) ⇒ Boolean
23
24
25
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 23
def lifecycle_environment_inherited?(host)
!using_hostgroups_page? && host&.lifecycle_environments&.empty? && host&.hostgroup&.lifecycle_environment.present? && cv_lce_disabled?
end
|
#organizations(host) ⇒ Object
43
44
45
46
47
48
49
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 43
def organizations(host)
if host.is_a?(::Hostgroup)
host.organizations
else
host.organization ? [host.organization] : []
end
end
|
#relevant_organizations(host) ⇒ Object
107
108
109
110
111
112
113
114
115
116
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 107
def relevant_organizations(host)
host_orgs = organizations(host)
if Organization.current
[Organization.current]
elsif host_orgs.present?
host_orgs
else
Organization.my_organizations
end
end
|
#using_discovered_hosts_page? ⇒ Boolean
35
36
37
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 35
def using_discovered_hosts_page?
controller.controller_name == "discovered_hosts"
end
|
#using_hostgroups_page? ⇒ Boolean
39
40
41
|
# File 'app/helpers/katello/hosts_and_hostgroups_helper.rb', line 39
def using_hostgroups_page?
controller.controller_name == "hostgroups"
end
|