Class: Katello::HostCollection
Defined Under Namespace
Classes: Jail
Class Method Summary
collapse
Instance Method Summary
collapse
#creatable?, #deletable?, #editable?, #readable?
Methods inherited from Model
#destroy!
Class Method Details
.humanize_class_name(_name = nil) ⇒ Object
114
115
116
|
# File 'app/models/katello/host_collection.rb', line 114
def self.humanize_class_name(_name = nil)
_("Host Collections")
end
|
.lists_by_updates_needed(organizations) ⇒ Object
Retrieve the list of accessible host collections in the organization specified, returning them in the following arrays:
critical: those collections that have 1 or more security errata that need to be applied
warning: those collections that have 1 or more non-security errata that need to be applied
ok: those collections that are completely up to date
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
# File 'app/models/katello/host_collection.rb', line 85
def self.lists_by_updates_needed(organizations)
host_collections_hash = {}
host_collections = HostCollection.where(:organization_id => organizations).readable
host_collections.each do |host_collection|
host_collection_state = :ok
unless host_collection.hosts.empty?
host_collection_state = host_collection.security_updates? ? :critical : :warning
end
host_collections_hash[host_collection_state] ||= []
host_collections_hash[host_collection_state] << host_collection
end
return host_collections_hash[:critical].to_a, host_collections_hash[:warning].to_a, host_collections_hash[:ok].to_a
end
|
Instance Method Details
#bugzilla_updates?(installable_only: false) ⇒ Boolean
106
107
108
|
# File 'app/models/katello/host_collection.rb', line 106
def bugzilla_updates?(installable_only: false)
errata(Erratum::BUGZILLA, installable_only: installable_only).any?
end
|
#cache_key ⇒ Object
70
71
72
|
# File 'app/models/katello/host_collection.rb', line 70
def cache_key
"#{self.class.name}/#{self.id}"
end
|
#consumer_ids ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
|
# File 'app/models/katello/host_collection.rb', line 49
def consumer_ids
consumer_ids = []
self.hosts.each do |host|
if host.content_facet
consumer_ids.push(host.content_facet.uuid)
end
end
consumer_ids
end
|
#enhancement_updates?(installable_only: false) ⇒ Boolean
110
111
112
|
# File 'app/models/katello/host_collection.rb', line 110
def enhancement_updates?(installable_only: false)
errata(Erratum::ENHANCEMENT, installable_only: installable_only).any?
end
|
#errata(type = nil, installable_only: false) ⇒ Object
61
62
63
64
65
66
67
68
|
# File 'app/models/katello/host_collection.rb', line 61
def errata(type = nil, installable_only: false)
query = if installable_only
Katello::Erratum.installable_for_hosts(self.hosts)
else
Katello::Erratum.applicable_to_hosts(self.hosts)
end
type ? query.of_type(type) : query
end
|
#max_hosts_check ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'app/models/katello/host_collection.rb', line 31
def max_hosts_check
host_count = hosts.size
if !unlimited_hosts && (host_count > 0 && (host_count.to_i > max_hosts.to_i)) && max_hosts_changed?
errors.add :max_host, N_("may not be less than the number of hosts associated with the host collection.")
end
end
|
#max_hosts_not_exceeded ⇒ Object
40
41
42
43
44
45
|
# File 'app/models/katello/host_collection.rb', line 40
def max_hosts_not_exceeded
if !unlimited_hosts && (hosts.size.to_i > max_hosts.to_i)
errors.add :base, N_("You cannot have more than #{max_hosts} host(s) associated with host collection #{name}." %
{:max_hosts => max_hosts, :name => name})
end
end
|
#security_updates?(installable_only: false) ⇒ Boolean
102
103
104
|
# File 'app/models/katello/host_collection.rb', line 102
def security_updates?(installable_only: false)
errata(Erratum::SECURITY, installable_only: installable_only).any?
end
|
#total_hosts(cached: false) ⇒ Object
74
75
76
77
78
|
# File 'app/models/katello/host_collection.rb', line 74
def total_hosts(cached: false)
Rails.cache.fetch("#{cache_key}/total_hosts", expires_in: 1.minute, force: !cached) do
hosts.count
end
end
|