Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions definitions/reports/alternate_content_sources.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
module Checks
module Report
class AlternateContentSources < ForemanMaintain::Report
metadata do
description 'Facts about ACSs'
confine do
feature(:katello)
end
end

def run
data_field('custom_alternate_content_sources_count') { custom_alternate_content_sources }
data_field('simplified_alternate_content_sources_count') do
simplified_alternate_content_sources
end
data_field('rhui_alternate_content_sources_count') { rhui_alternate_content_sources }
data_field('yum_alternate_content_sources_count') { yum_alternate_content_sources }
data_field('file_alternate_content_sources_count') { file_alternate_content_sources }
end

def custom_alternate_content_sources
sql_count(
"katello_alternate_content_sources WHERE alternate_content_source_type = 'custom'"
)
end

def simplified_alternate_content_sources
sql_count(
"katello_alternate_content_sources WHERE alternate_content_source_type = 'simplified'"
)
end

def rhui_alternate_content_sources
sql_count("katello_alternate_content_sources WHERE alternate_content_source_type = 'rhui'")
end

def yum_alternate_content_sources
sql_count("katello_alternate_content_sources WHERE content_type = 'yum'")
end

def file_alternate_content_sources
sql_count("katello_alternate_content_sources WHERE content_type = 'file'")
end
end
end
end
54 changes: 54 additions & 0 deletions definitions/reports/content.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
module Checks
module Report
class Content < ForemanMaintain::Report
metadata do
description 'Facts about Katello content'
confine do
feature(:katello)
end
end

def run
data_field('custom_library_yum_repositories_count') { custom_library_yum_repositories }
data_field('redhat_library_yum_repositories_count') { redhat_library_yum_repositories }
data_field('library_debian_repositories_count') { library_repositories('deb') }
data_field('library_container_repositories_count') { library_repositories('docker') }
data_field('library_file_repositories_count') { library_repositories('file') }
data_field('library_python_repositories_count') { library_repositories('python') }
data_field('library_ansible_collection_repositories_count') do
library_repositories('ansible_collection')
end
data_field('library_ostree_repositories_count') { library_repositories('ostree') }
end

def custom_library_yum_repositories
query_snippet =
<<-SQL
"katello_root_repositories"
WHERE "katello_root_repositories"."id" NOT IN
(SELECT "katello_root_repositories"."id" FROM "katello_root_repositories" INNER JOIN "katello_products"
ON "katello_products"."id" = "katello_root_repositories"."product_id" INNER JOIN "katello_providers"
ON "katello_providers"."id" = "katello_products"."provider_id" WHERE "katello_providers"."provider_type" = 'Red Hat')
AND "katello_root_repositories"."content_type" = 'yum'
SQL
sql_count(query_snippet)
end

def redhat_library_yum_repositories
query_snippet =
<<-SQL
"katello_root_repositories"
INNER JOIN "katello_products" ON "katello_products"."id" = "katello_root_repositories"."product_id"
INNER JOIN "katello_providers" ON "katello_providers"."id" = "katello_products"."provider_id"
WHERE "katello_providers"."provider_type" = 'Red Hat'
AND "katello_root_repositories"."content_type" = 'yum'
SQL
sql_count(query_snippet)
end

def library_repositories(content_type)
sql_count("katello_root_repositories WHERE content_type = '#{content_type}'")
end
end
end
end
Loading