Skip to content

Commit 59cba93

Browse files
committed
Add report for collecting ACS facts
1 parent c9ba803 commit 59cba93

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
module Checks
2+
module Report
3+
class AlternateContentSources < ForemanMaintain::Report
4+
metadata do
5+
description 'Facts about ACSs'
6+
confine do
7+
feature(:katello)
8+
end
9+
end
10+
11+
def run
12+
data_field('custom_alternate_content_sources_count') { custom_alternate_content_sources }
13+
data_field('simplified_alternate_content_sources_count') { simplified_alternate_content_sources }
14+
data_field('rhui_alternate_content_sources_count') { rhui_alternate_content_sources }
15+
data_field('yum_alternate_content_sources_count') { yum_alternate_content_sources }
16+
data_field('file_alternate_content_sources_count') { file_alternate_content_sources }
17+
end
18+
19+
def custom_alternate_content_sources
20+
query =
21+
query(
22+
<<-SQL
23+
SELECT count(*) as custom_acs_count FROM "katello_alternate_content_sources"
24+
WHERE "katello_alternate_content_sources"."alternate_content_source_type" = 'custom'
25+
SQL
26+
)
27+
query.first['custom_acs_count'].to_i
28+
end
29+
30+
def simplified_alternate_content_sources
31+
query =
32+
query(
33+
<<-SQL
34+
SELECT count(*) as simplified_acs_count FROM "katello_alternate_content_sources"
35+
WHERE "katello_alternate_content_sources"."alternate_content_source_type" = 'simplified'
36+
SQL
37+
)
38+
query.first['simplified_acs_count'].to_i
39+
end
40+
41+
def rhui_alternate_content_sources
42+
query =
43+
query(
44+
<<-SQL
45+
SELECT count(*) as rhui_acs_count FROM "katello_alternate_content_sources"
46+
WHERE "katello_alternate_content_sources"."alternate_content_source_type" = 'rhui'
47+
SQL
48+
)
49+
query.first['rhui_acs_count'].to_i
50+
end
51+
52+
def yum_alternate_content_sources
53+
query =
54+
query(
55+
<<-SQL
56+
SELECT count(*) as yum_acs_count FROM "katello_alternate_content_sources" WHERE "katello_alternate_content_sources"."content_type" = 'yum'
57+
SQL
58+
)
59+
query.first['yum_acs_count'].to_i
60+
end
61+
62+
def file_alternate_content_sources
63+
query =
64+
query(
65+
<<-SQL
66+
SELECT count(*) as file_acs_count FROM "katello_alternate_content_sources" WHERE "katello_alternate_content_sources"."content_type" = 'file'
67+
SQL
68+
)
69+
query.first['file_acs_count'].to_i
70+
end
71+
end
72+
end
73+
end

0 commit comments

Comments
 (0)