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
101
102
103
|
# File 'app/models/katello/host_collection.rb', line 101
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
# File 'app/models/katello/host_collection.rb', line 72
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? ⇒ Boolean
93
94
95
|
# File 'app/models/katello/host_collection.rb', line 93
def bugzilla_updates?
errata(Erratum::BUGZILLA).any?
end
|
#consumer_ids ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
|
# File 'app/models/katello/host_collection.rb', line 46
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? ⇒ Boolean
97
98
99
|
# File 'app/models/katello/host_collection.rb', line 97
def enhancement_updates?
errata(Erratum::ENHANCEMENT).any?
end
|
#errata(type = nil) ⇒ Object
58
59
60
61
|
# File 'app/models/katello/host_collection.rb', line 58
def errata(type = nil)
query = Erratum.joins(:content_facets).where("#{Katello::Host::ContentFacet.table_name}.host_id" => self.host_ids)
type ? query.of_type(type) : query
end
|
#max_hosts_check ⇒ Object
31
32
33
34
35
|
# File 'app/models/katello/host_collection.rb', line 31
def max_hosts_check
if !unlimited_hosts && (hosts.length > 0 && (hosts.length.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
37
38
39
40
41
42
|
# File 'app/models/katello/host_collection.rb', line 37
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? ⇒ Boolean
89
90
91
|
# File 'app/models/katello/host_collection.rb', line 89
def security_updates?
errata(Erratum::SECURITY).any?
end
|
#total_hosts ⇒ Object
63
64
65
|
# File 'app/models/katello/host_collection.rb', line 63
def total_hosts
hosts.length
end
|