Class: Katello::Deb
- Includes:
- Concerns::PulpDatabaseUnit
- Defined in:
- app/models/katello/deb.rb
Constant Summary collapse
- CONTENT_TYPE =
'deb'.freeze
Class Method Summary collapse
- .applicable_to_hosts(hosts) ⇒ Object
- .content_facet_association_class ⇒ Object
-
.deb_installable_for_host(host) ⇒ Object
Return deb packages that are not installed on a host, but could be installed the word ‘installable’ has a different meaning here than elsewhere.
- .default_sort ⇒ Object
- .installable_for_hosts(hosts = nil) ⇒ Object
- .latest(_relation) ⇒ Object
- .repository_association_class ⇒ Object
- .split_nav(value) ⇒ Object
- .total_for_repositories(repos) ⇒ Object
Instance Method Summary collapse
- #hosts_applicable(org_id = nil) ⇒ Object
- #hosts_available(org_id = nil) ⇒ Object
-
#nav ⇒ Object
the format apt needs to identify the packet with version and architecture.
-
#nva ⇒ Object
the more natural format ;-).
Methods included from Concerns::PulpDatabaseUnit
#backend_data, #library_repositories, #remove_from_repository
Methods inherited from Model
Class Method Details
.applicable_to_hosts(hosts) ⇒ Object
92 93 94 95 |
# File 'app/models/katello/deb.rb', line 92 def self.applicable_to_hosts(hosts) self.joins(:content_facets). where("#{Katello::Host::ContentFacet.table_name}.host_id" => hosts).distinct end |
.content_facet_association_class ⇒ Object
26 27 28 |
# File 'app/models/katello/deb.rb', line 26 def self.content_facet_association_class ContentFacetApplicableDeb end |
.deb_installable_for_host(host) ⇒ Object
Return deb packages that are not installed on a host, but could be installed the word ‘installable’ has a different meaning here than elsewhere
99 100 101 102 |
# File 'app/models/katello/deb.rb', line 99 def self.deb_installable_for_host(host) repos = host.content_facet.bound_repositories.pluck(:id) Katello::Deb.in_repositories(repos).where.not(name: host.installed_debs.pluck(:name)).order(:name) end |
.default_sort ⇒ Object
18 19 20 |
# File 'app/models/katello/deb.rb', line 18 def self.default_sort order(:name).order(:version).order(:architecture) end |
.installable_for_hosts(hosts = nil) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'app/models/katello/deb.rb', line 76 def self.installable_for_hosts(hosts = nil) debs = Katello::Deb.joins(:repositories, "INNER JOIN #{Katello::InstalledDeb.table_name} ON #{Katello::InstalledDeb.table_name}.name = #{self.table_name}.name", "INNER JOIN #{Katello::HostInstalledDeb.table_name} ON #{Katello::HostInstalledDeb.table_name}.installed_deb_id = #{Katello::InstalledDeb.table_name}.id") .where("deb_version_cmp(#{self.table_name}.version, #{Katello::InstalledDeb.table_name}.version) > 0") unless hosts.nil? facet_repos = Katello::ContentFacetRepository.joins(:content_facet => :host).select(:repository_id) hosts = ::Host.where(id: hosts) if hosts.is_a?(Array) facet_repos = facet_repos.merge(hosts).reorder(nil) debs = debs.where("#{Katello::HostInstalledDeb.table_name}.host_id": hosts.pluck(:id)) .where("#{Katello::RepositoryDeb.table_name}.repository_id" => facet_repos) end debs.distinct end |
.latest(_relation) ⇒ Object
104 105 106 |
# File 'app/models/katello/deb.rb', line 104 def self.latest(_relation) fail 'NotImplemented' end |
.repository_association_class ⇒ Object
22 23 24 |
# File 'app/models/katello/deb.rb', line 22 def self.repository_association_class RepositoryDeb end |
.split_nav(value) ⇒ Object
55 56 57 58 59 60 |
# File 'app/models/katello/deb.rb', line 55 def self.split_nav(value) v = /^(?<name>[^:\s]+)(:(?<architecture>[^=\s]*))?(=(?<version>.*))?$/.match(value)&.named_captures if v [ v['name'], v['architecture'], v['version'] ] end end |
.total_for_repositories(repos) ⇒ Object
41 42 43 |
# File 'app/models/katello/deb.rb', line 41 def self.total_for_repositories(repos) self.in_repositories(repos).count end |
Instance Method Details
#hosts_applicable(org_id = nil) ⇒ Object
62 63 64 65 66 67 68 |
# File 'app/models/katello/deb.rb', line 62 def hosts_applicable(org_id = nil) if org_id.present? self.content_facets.joins(:host).where("#{::Host.table_name}.organization_id" => org_id) else self.content_facets.joins(:host) end end |
#hosts_available(org_id = nil) ⇒ Object
70 71 72 73 74 |
# File 'app/models/katello/deb.rb', line 70 def hosts_available(org_id = nil) self.hosts_applicable(org_id).joins("INNER JOIN #{Katello::RepositoryDeb.table_name} on \ #{Katello::RepositoryDeb.table_name}.deb_id = #{self.id}").joins(:content_facet_repositories). where("#{Katello::ContentFacetRepository.table_name}.repository_id = #{Katello::RepositoryDeb.table_name}.repository_id").uniq end |
#nav ⇒ Object
the format apt needs to identify the packet with version and architecture
46 47 48 |
# File 'app/models/katello/deb.rb', line 46 def nav "#{self.name}:#{self.architecture}=#{self.version}" end |
#nva ⇒ Object
the more natural format ;-)
51 52 53 |
# File 'app/models/katello/deb.rb', line 51 def nva "#{self.name}_#{self.version}_#{self.architecture}" end |