forked from Katello/katello
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkatello-check
executable file
·105 lines (91 loc) · 4.57 KB
/
katello-check
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/ruby
# vim: ft=ruby:ts=2:sw=2:et
# TODO: refactor out globals
# rubocop:disable GlobalVars
puts '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$7......~$$$$:......:$$$$:......$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$. .=$$$7: .:$$$$, $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$. .=$$$7: .:$$$$, $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$. ........................$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$. .....................$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$+. . . . . ..=$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$I . .... . .. .. . ..7$$$$$$$$$$$$$$$$$$$$$$$+....$$$$'
puts '$$$$$$$$$$$$$$$$$. ..$$$$$$$$$$$$$$$$$$$$$$$7$, .$$$$'
puts '$$$$$$$$$$$$$$$$$7, .7$$$$$$$$$$$$$$?~.=I$$$$$$$=,=7$$$$'
puts '$$$$$$$$$$$$$$$$$$$.. .?$$$$$$$$$$$$?..I$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$$$7 . ..$$$$$$$$$$..=$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$$$. .$$$$$$$7..~$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$$$. .$$$$$$:..$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$$~. .....$$$..........~$$$7..+$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$$ . .$$$. ..$$$...$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$$. . . .$$$. ..I7 ,$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$7 . ..$$$. . .. . ..7:..,$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$. .... .$$$+..=$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$. .I$$$$I..+$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$: .:$$$$$$7..7$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$. . $$$$$$$$7..$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$I. ?$$$$$$$$$$,,$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$7,. .$$$$$$$$$$$7,:$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$.. ..7$$$$$$$$$$$$$~,$$$$$$$$$$$$$$$'
puts '$$7$$$$$$$$$$$ .,$$$$$$$$$$$$$$$,I$$$$$$$$$$$$$'
puts '$$$$7$$$$$$$$: . .. . . .$$$$$$$$$$$$$$$$$:$$$$$$$$$$$$'
puts '$$$$$$7:$$$$$. ...,+7$$$$$$$$$$$$I,..$$$$$$$$$$$$$$$$$$$7$$$$$$$$$$'
puts '$$$$$$$$$77$?~::::+I$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts '$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$'
puts ' Katello integrity checker'
puts ' (takes a while to finish)'
Dir.chdir "/usr/share/katello"
ENV["RAILS_ENV"] = 'production'
require "/usr/share/katello/config/boot"
require "/usr/share/katello/config/application"
Rails.application.require_environment!
# TYPE => DESCRIPTION (HOW TO FIX IT)
ERROR_TYPES = {}
ERROR_TYPES[:ERRREPOKAPU] = <<EOS
Repository was found in Katello, but not in Pulp. To fix this you need to add
the repository to Pulp using pulp-admin cli tool.
EOS
ERROR_TYPES[:ERRREPOPUKA] = <<EOS
Repository was found in Pulp, but not in Katello.
EOS
ERROR_TYPES[:TEMPLATE] = <<EOS
Use this as a template for your description. Please keep paragraph width max. 79
characters. Inform user how to fix error.
EOS
# rubocop:disable AvoidGlobalVars
$errors = {}
def err(type, msg)
$stderr.puts "#{type.to_s}: #{msg}"
$errors[type] += 1 rescue $errors[type] = 1
end
# use admin user to get oauth header
User.current = User.find(1)
# <CHECKS>
if defined? Resources::Pulp::Repository
# Pulp version 1.x checks
puts "Checking repos from Katello against Pulp..."
Repository.all.each do |repo|
if Resources::Pulp::Repository.find(repo.pulp_id).nil?
err :ERRREPOKAPU, "repo #{repo.id} (#{repo.pulp_id}) not found in Pulp"
end
end
puts "Checking repos from Pulp against Katello..."
Resources::Pulp::Repository.all.each do |repo_json|
id = repo_json["id"]
if Repository.where(:pulp_id => id).count != 1
err :ERRREPOPUKA, "repo '#{id}' not found in Katello"
end
end
else
# Pulp version 2.x checks
# TODO
end
# </CHECKS>
# print final result
puts "\nErrors found: #{$errors.values.sum}"
$errors.each_pair do |type, count|
puts "#{type.to_s} (#{count}):\n#{ERROR_TYPES[type]}"
end
# EOF