foreman_maintain 0.6.0 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/README.md +4 -0
- data/definitions/checks/check_hotfix_installed.rb +2 -1
- data/definitions/checks/disk/performance.rb +24 -9
- data/definitions/checks/foreman/check_corrupted_roles.rb +14 -2
- data/definitions/checks/foreman/validate_external_db_version.rb +28 -0
- data/definitions/checks/original_assets.rb +1 -0
- data/definitions/checks/pulpcore/db_up.rb +29 -0
- data/definitions/checks/repositories/check_non_rh_repository.rb +23 -0
- data/definitions/checks/repositories/check_upstream_repository.rb +2 -1
- data/definitions/checks/repositories/validate.rb +2 -1
- data/definitions/features/apache.rb +19 -0
- data/definitions/features/dynflow_sidekiq.rb +1 -1
- data/definitions/features/foreman_database.rb +5 -3
- data/definitions/features/foreman_server.rb +9 -3
- data/definitions/features/foreman_tasks.rb +7 -2
- data/definitions/features/installer.rb +9 -2
- data/definitions/features/instance.rb +5 -2
- data/definitions/features/katello.rb +7 -0
- data/definitions/features/{pulp3.rb → pulpcore.rb} +9 -3
- data/definitions/features/pulpcore_database.rb +39 -0
- data/definitions/features/puppet_server.rb +6 -2
- data/definitions/features/service.rb +10 -3
- data/definitions/features/tar.rb +5 -0
- data/definitions/procedures/backup/config_files.rb +3 -0
- data/definitions/procedures/backup/metadata.rb +2 -0
- data/definitions/procedures/backup/offline/pulpcore_db.rb +57 -0
- data/definitions/procedures/backup/online/pulpcore_db.rb +20 -0
- data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +1 -0
- data/definitions/procedures/backup/snapshot/mount_pulpcore_db.rb +48 -0
- data/definitions/procedures/content/prepare.rb +2 -2
- data/definitions/procedures/content/switchover.rb +22 -0
- data/definitions/procedures/hammer_setup.rb +1 -1
- data/definitions/procedures/installer/run.rb +3 -1
- data/definitions/procedures/installer/upgrade.rb +6 -1
- data/definitions/procedures/packages/installer_confirmation.rb +1 -1
- data/definitions/procedures/packages/update.rb +1 -1
- data/definitions/procedures/packages/update_all_confirmation.rb +24 -0
- data/definitions/procedures/pulpcore/migrate.rb +25 -0
- data/definitions/procedures/restore/configs.rb +6 -0
- data/definitions/procedures/restore/drop_databases.rb +11 -1
- data/definitions/procedures/restore/extract_files.rb +1 -0
- data/definitions/procedures/restore/pulpcore_dump.rb +30 -0
- data/definitions/procedures/restore/regenerate_queues.rb +69 -0
- data/definitions/procedures/service/stop.rb +1 -1
- data/definitions/scenarios/backup.rb +21 -4
- data/definitions/scenarios/content.rb +27 -0
- data/definitions/scenarios/packages.rb +38 -14
- data/definitions/scenarios/restore.rb +10 -2
- data/definitions/scenarios/upgrade_to_capsule_6_7.rb +88 -0
- data/definitions/scenarios/upgrade_to_capsule_6_7_z.rb +88 -0
- data/definitions/scenarios/upgrade_to_capsule_6_8.rb +88 -0
- data/definitions/scenarios/upgrade_to_capsule_6_8_z.rb +88 -0
- data/definitions/scenarios/upgrade_to_satellite_6_2.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_2_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_3.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_3_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_4.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_4_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_5.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_5_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_6.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_6_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_7.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_7_z.rb +13 -5
- data/definitions/scenarios/upgrade_to_satellite_6_8.rb +88 -0
- data/definitions/scenarios/upgrade_to_satellite_6_8_z.rb +88 -0
- data/extras/foreman_protector/foreman-protector.py +1 -1
- data/lib/foreman_maintain.rb +31 -0
- data/lib/foreman_maintain/cli.rb +2 -0
- data/lib/foreman_maintain/cli/content_command.rb +17 -0
- data/lib/foreman_maintain/cli/packages_command.rb +1 -1
- data/lib/foreman_maintain/cli/upgrade_command.rb +10 -0
- data/lib/foreman_maintain/concerns/base_database.rb +16 -1
- data/lib/foreman_maintain/concerns/downstream.rb +14 -10
- data/lib/foreman_maintain/feature.rb +4 -0
- data/lib/foreman_maintain/package_manager/dnf.rb +11 -5
- data/lib/foreman_maintain/package_manager/yum.rb +15 -5
- data/lib/foreman_maintain/reporter/cli_reporter.rb +6 -6
- data/lib/foreman_maintain/upgrade_runner.rb +20 -26
- data/lib/foreman_maintain/utils/backup.rb +62 -62
- data/lib/foreman_maintain/utils/disk/io_device.rb +1 -1
- data/lib/foreman_maintain/utils/facter.rb +1 -1
- data/lib/foreman_maintain/utils/service/abstract.rb +6 -0
- data/lib/foreman_maintain/version.rb +1 -1
- metadata +184 -165
- data/definitions/checks/check_epel_repository.rb +0 -21
@@ -0,0 +1,17 @@
|
|
1
|
+
module ForemanMaintain
|
2
|
+
module Cli
|
3
|
+
class ContentCommand < Base
|
4
|
+
subcommand 'prepare', 'Prepare content for Pulp 3' do
|
5
|
+
def execute
|
6
|
+
run_scenarios_and_exit(Scenarios::Content::Prepare.new)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
subcommand 'switchover', 'Switch support for certain content from Pulp 2 to Pulp 3' do
|
11
|
+
def execute
|
12
|
+
run_scenarios_and_exit(Scenarios::Content::Switchover.new)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -38,7 +38,7 @@ module ForemanMaintain
|
|
38
38
|
|
39
39
|
subcommand 'update', 'Update packages in an unlocked session' do
|
40
40
|
interactive_option
|
41
|
-
parameter 'PACKAGES ...', 'packages to update', :attribute_name => :packages
|
41
|
+
parameter '[PACKAGES ...]', 'packages to update', :attribute_name => :packages
|
42
42
|
|
43
43
|
def execute
|
44
44
|
run_scenarios_and_exit(
|
@@ -6,6 +6,11 @@ module ForemanMaintain
|
|
6
6
|
:required => false
|
7
7
|
end
|
8
8
|
|
9
|
+
def self.disable_self_upgrade_option
|
10
|
+
option '--disable-self-upgrade', :flag, 'Disable automatic self upgrade',
|
11
|
+
:default => false
|
12
|
+
end
|
13
|
+
|
9
14
|
def current_target_version
|
10
15
|
current_target_version = ForemanMaintain::UpgradeRunner.current_target_version
|
11
16
|
if current_target_version && target_version && target_version != current_target_version
|
@@ -56,8 +61,10 @@ module ForemanMaintain
|
|
56
61
|
subcommand 'check', 'Run pre-upgrade checks before upgrading to specified version' do
|
57
62
|
target_version_option
|
58
63
|
interactive_option
|
64
|
+
disable_self_upgrade_option
|
59
65
|
|
60
66
|
def execute
|
67
|
+
ForemanMaintain.perform_self_upgrade unless disable_self_upgrade?
|
61
68
|
upgrade_runner.run_phase(:pre_upgrade_checks)
|
62
69
|
exit upgrade_runner.exit_code
|
63
70
|
end
|
@@ -66,6 +73,8 @@ module ForemanMaintain
|
|
66
73
|
subcommand 'run', 'Run full upgrade to a specified version' do
|
67
74
|
target_version_option
|
68
75
|
interactive_option
|
76
|
+
disable_self_upgrade_option
|
77
|
+
|
69
78
|
option '--phase', 'phase', 'run only a specific phase', :required => false do |phase|
|
70
79
|
unless UpgradeRunner::PHASES.include?(phase.to_sym)
|
71
80
|
raise Error::UsageError, "Unknown phase #{phase}"
|
@@ -74,6 +83,7 @@ module ForemanMaintain
|
|
74
83
|
end
|
75
84
|
|
76
85
|
def execute
|
86
|
+
ForemanMaintain.perform_self_upgrade unless disable_self_upgrade?
|
77
87
|
if phase
|
78
88
|
upgrade_runner.run_phase(phase.to_sym)
|
79
89
|
else
|
@@ -2,7 +2,11 @@ module ForemanMaintain
|
|
2
2
|
module Concerns
|
3
3
|
module BaseDatabase
|
4
4
|
def data_dir
|
5
|
-
'
|
5
|
+
if check_min_version('foreman', '2.0')
|
6
|
+
'/var/opt/rh/rh-postgresql12/lib/pgsql/data/'
|
7
|
+
else
|
8
|
+
'/var/lib/pgsql/data/'
|
9
|
+
end
|
6
10
|
end
|
7
11
|
|
8
12
|
def configuration
|
@@ -146,6 +150,17 @@ module ForemanMaintain
|
|
146
150
|
end
|
147
151
|
end
|
148
152
|
|
153
|
+
def db_version(config = configuration)
|
154
|
+
if ping(config)
|
155
|
+
# Note - t removes headers, -A removes alignment whitespace
|
156
|
+
server_version_cmd = psql_command(config) + ' -c "SHOW server_version" -t -A'
|
157
|
+
version_string = execute!(server_version_cmd, :hidden_patterns => [config['password']])
|
158
|
+
version(version_string)
|
159
|
+
else
|
160
|
+
raise_service_error
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
149
164
|
private
|
150
165
|
|
151
166
|
def base_command(config, command = 'psql')
|
@@ -87,8 +87,7 @@ module ForemanMaintain
|
|
87
87
|
else
|
88
88
|
"rhel-#{rh_version_major}-server-#{package_name}-#{full_version}-rpms"
|
89
89
|
end
|
90
|
-
|
91
|
-
if current_minor_version == '6.3' && server_version.to_s != '6.4' && (
|
90
|
+
if current_minor_version == '6.3' && full_version.to_s != '6.4' && (
|
92
91
|
feature(:puppet_server) && feature(:puppet_server).puppet_version.major == 4)
|
93
92
|
# TODO: confirm repo for capsule. It might be same repo
|
94
93
|
repos << "rhel-#{rh_version_major}-server-satellite-tools-6.3-puppet4-rpms"
|
@@ -98,16 +97,21 @@ module ForemanMaintain
|
|
98
97
|
end
|
99
98
|
|
100
99
|
def common_repos(rh_version_major, full_version)
|
101
|
-
|
102
|
-
|
100
|
+
repos_arrary = common_repos_array(rh_version_major, full_version)
|
101
|
+
return repos_arrary.first(1) if feature(:capsule)
|
103
102
|
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
103
|
+
repos_arrary
|
104
|
+
end
|
105
|
+
|
106
|
+
def common_repos_array(rh_version_major, full_version)
|
107
|
+
["rhel-#{rh_version_major}-server-satellite-maintenance-6#{use_beta}-rpms",
|
108
|
+
"rhel-#{rh_version_major}-server-satellite-tools-#{full_version}#{use_beta}-rpms"]
|
109
|
+
end
|
110
|
+
|
111
|
+
def use_beta
|
112
|
+
return '-beta' if ENV['FOREMAN_MAINTAIN_USE_BETA'] == '1'
|
109
113
|
|
110
|
-
|
114
|
+
nil
|
111
115
|
end
|
112
116
|
|
113
117
|
def main_rh_repos(rh_version_major)
|
@@ -1,17 +1,23 @@
|
|
1
1
|
module ForemanMaintain::PackageManager
|
2
2
|
class Dnf < Yum
|
3
|
-
def clean_cache
|
4
|
-
dnf_action('clean', 'all')
|
3
|
+
def clean_cache(assumeyes: false)
|
4
|
+
dnf_action('clean', 'all', :assumeyes => assumeyes)
|
5
5
|
super
|
6
6
|
end
|
7
7
|
|
8
8
|
private
|
9
9
|
|
10
|
-
def dnf_action(action, packages, assumeyes: false)
|
10
|
+
def dnf_action(action, packages, with_status: false, assumeyes: false)
|
11
11
|
yum_options = []
|
12
12
|
yum_options << '-y' if assumeyes
|
13
|
-
|
14
|
-
|
13
|
+
if with_status
|
14
|
+
sys.execute_with_status("dnf #{yum_options.join(' ')} #{action} #{packages.join(' ')}",
|
15
|
+
:interactive => !assumeyes)
|
16
|
+
else
|
17
|
+
sys.execute!("dnf #{yum_options.join(' ')} #{action} #{packages.join(' ')}",
|
18
|
+
:interactive => !assumeyes)
|
19
|
+
|
20
|
+
end
|
15
21
|
end
|
16
22
|
end
|
17
23
|
end
|
@@ -57,8 +57,13 @@ module ForemanMaintain::PackageManager
|
|
57
57
|
yum_action('update', packages, :assumeyes => assumeyes)
|
58
58
|
end
|
59
59
|
|
60
|
-
def clean_cache
|
61
|
-
yum_action('clean', 'all')
|
60
|
+
def clean_cache(assumeyes: false)
|
61
|
+
yum_action('clean', 'all', :assumeyes => assumeyes)
|
62
|
+
end
|
63
|
+
|
64
|
+
def update_available?(package)
|
65
|
+
cmd_output = yum_action('check-update -q', package, :with_status => true, :assumeyes => false)
|
66
|
+
cmd_output[0] == 100
|
62
67
|
end
|
63
68
|
|
64
69
|
def files_not_owned_by_package(directory)
|
@@ -96,14 +101,19 @@ module ForemanMaintain::PackageManager
|
|
96
101
|
File.open(protector_config_file, 'w') { |file| file.puts config }
|
97
102
|
end
|
98
103
|
|
99
|
-
def yum_action(action, packages, assumeyes: false)
|
104
|
+
def yum_action(action, packages, with_status: false, assumeyes: false)
|
100
105
|
yum_options = []
|
101
106
|
packages = [packages].flatten(1)
|
102
107
|
yum_options << '-y' if assumeyes
|
103
108
|
yum_options_s = yum_options.empty? ? '' : ' ' + yum_options.join(' ')
|
104
109
|
packages_s = packages.empty? ? '' : ' ' + packages.join(' ')
|
105
|
-
|
106
|
-
|
110
|
+
if with_status
|
111
|
+
sys.execute_with_status("yum#{yum_options_s} #{action}#{packages_s}",
|
112
|
+
:interactive => !assumeyes)
|
113
|
+
else
|
114
|
+
sys.execute!("yum#{yum_options_s} #{action}#{packages_s}",
|
115
|
+
:interactive => !assumeyes)
|
116
|
+
end
|
107
117
|
end
|
108
118
|
|
109
119
|
def install_extras(src, dest, override: false)
|
@@ -16,7 +16,6 @@ module ForemanMaintain
|
|
16
16
|
@spinner_chars = %w[| / - \\]
|
17
17
|
@current_line = ''
|
18
18
|
@puts_needed = false
|
19
|
-
start_spinner
|
20
19
|
end
|
21
20
|
|
22
21
|
def update(line)
|
@@ -42,8 +41,6 @@ module ForemanMaintain
|
|
42
41
|
end
|
43
42
|
end
|
44
43
|
|
45
|
-
private
|
46
|
-
|
47
44
|
def start_spinner
|
48
45
|
@thread = Thread.new do
|
49
46
|
loop do
|
@@ -53,6 +50,8 @@ module ForemanMaintain
|
|
53
50
|
end
|
54
51
|
end
|
55
52
|
|
53
|
+
private
|
54
|
+
|
56
55
|
def spin
|
57
56
|
@mutex.synchronize do
|
58
57
|
return unless @active
|
@@ -80,6 +79,7 @@ module ForemanMaintain
|
|
80
79
|
@line_char = '-'
|
81
80
|
@cell_char = '|'
|
82
81
|
@spinner = Spinner.new(self)
|
82
|
+
@spinner.start_spinner if @stdout.tty?
|
83
83
|
@last_line = ''
|
84
84
|
end
|
85
85
|
|
@@ -184,9 +184,9 @@ module ForemanMaintain
|
|
184
184
|
ask_to_select('Select step to continue', steps, &:runtime_message)
|
185
185
|
end
|
186
186
|
|
187
|
-
def ask_decision(message, options = 'y(yes), n(no), q(quit)')
|
188
|
-
if assumeyes?
|
189
|
-
print("#{message} (assuming yes)")
|
187
|
+
def ask_decision(message, options = 'y(yes), n(no), q(quit)', ignore_assumeyes: false)
|
188
|
+
if !ignore_assumeyes && assumeyes?
|
189
|
+
print("#{message} (assuming yes)\n")
|
190
190
|
return :yes
|
191
191
|
end
|
192
192
|
until_valid_decision do
|
@@ -15,29 +15,8 @@ module ForemanMaintain
|
|
15
15
|
def available_targets
|
16
16
|
# when some upgrade is in progress, we don't allow upgrade to different version
|
17
17
|
return [current_target_version] if current_target_version
|
18
|
-
versions_to_tags.inject([]) do |available_targets, (version, tag)|
|
19
|
-
if !find_scenarios(:tags => [tag]).empty?
|
20
|
-
available_targets << version
|
21
|
-
else
|
22
|
-
available_targets
|
23
|
-
end
|
24
|
-
end.sort
|
25
|
-
end
|
26
|
-
|
27
|
-
def versions_to_tags
|
28
|
-
@versions_to_tags ||= {}
|
29
|
-
end
|
30
|
-
|
31
|
-
# registers target version to specific tag
|
32
|
-
def register_version(version, tag)
|
33
|
-
if versions_to_tags.key?(version) && versions_to_tags[version] != tag
|
34
|
-
raise "Version #{version} already registered to tag #{versions_to_tags[version]}"
|
35
|
-
end
|
36
|
-
@versions_to_tags[version] = tag
|
37
|
-
end
|
38
18
|
|
39
|
-
|
40
|
-
versions_to_tags.clear
|
19
|
+
find_scenarios(:tags => :upgrade_scenario).map(&:target_version).uniq.sort
|
41
20
|
end
|
42
21
|
|
43
22
|
def current_target_version
|
@@ -57,25 +36,35 @@ module ForemanMaintain
|
|
57
36
|
|
58
37
|
def initialize(version, reporter, options = {})
|
59
38
|
super(reporter, [], options)
|
60
|
-
@tag = self.class.versions_to_tags[version]
|
61
|
-
raise "Unknown version #{version}" unless tag
|
62
39
|
@version = version
|
40
|
+
scenarios_present = find_scenarios(:tags => :upgrade_scenario).any?(&matching_version_test)
|
41
|
+
raise "Unknown version #{version}" unless scenarios_present
|
42
|
+
|
63
43
|
@scenario_cache = {}
|
64
44
|
self.phase = :pre_upgrade_checks
|
65
45
|
end
|
66
46
|
|
67
47
|
def scenario(phase)
|
68
48
|
return @scenario_cache[phase] if @scenario_cache.key?(phase)
|
69
|
-
|
70
|
-
|
49
|
+
|
50
|
+
condition = { :tags => [:upgrade_scenario, phase] }
|
51
|
+
matching_scenarios = find_scenarios(condition).select(&matching_version_test)
|
71
52
|
raise "Too many scenarios match #{condition.inspect}" if matching_scenarios.size > 1
|
53
|
+
|
72
54
|
@scenario_cache[phase] = matching_scenarios.first
|
73
55
|
end
|
74
56
|
|
57
|
+
def matching_version_test
|
58
|
+
proc do |scenario|
|
59
|
+
scenario.respond_to?(:target_version) && scenario.target_version == @version
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
75
63
|
def run
|
76
64
|
self.class.current_target_version = @version
|
77
65
|
PHASES.each do |phase|
|
78
66
|
return run_rollback if quit?
|
67
|
+
|
79
68
|
if skip?(phase)
|
80
69
|
skip_phase(phase)
|
81
70
|
else
|
@@ -127,6 +116,7 @@ module ForemanMaintain
|
|
127
116
|
# deserializes the state of the run from the storage
|
128
117
|
def load
|
129
118
|
return unless storage[:serialized]
|
119
|
+
|
130
120
|
load_from_hash(storage[:serialized])
|
131
121
|
end
|
132
122
|
|
@@ -134,6 +124,7 @@ module ForemanMaintain
|
|
134
124
|
with_non_empty_scenario(phase) do |scenario|
|
135
125
|
confirm_scenario(scenario)
|
136
126
|
return if quit?
|
127
|
+
|
137
128
|
self.phase = phase
|
138
129
|
run_scenario(scenario)
|
139
130
|
# if we started from the :pre_upgrade_checks, ensure to ask before
|
@@ -158,6 +149,7 @@ module ForemanMaintain
|
|
158
149
|
# rubocop:disable Metrics/MethodLength
|
159
150
|
def rollback_pre_migrations
|
160
151
|
raise "Unexpected phase #{phase}, expecting pre_migrations" unless phase == :pre_migrations
|
152
|
+
|
161
153
|
rollback_needed = scenario(:pre_migrations).steps.any? { |s| s.executed? && s.success? }
|
162
154
|
if rollback_needed
|
163
155
|
@quit = false
|
@@ -198,6 +190,7 @@ module ForemanMaintain
|
|
198
190
|
unless @scenario_cache.empty?
|
199
191
|
raise "Some scenarios are already initialized: #{@scenario_cache.keys}"
|
200
192
|
end
|
193
|
+
|
201
194
|
self.phase = hash[:phase]
|
202
195
|
hash[:scenarios].each do |key, scenario_hash|
|
203
196
|
@scenario_cache[key] = Scenario.new_from_hash(scenario_hash)
|
@@ -229,6 +222,7 @@ module ForemanMaintain
|
|
229
222
|
|
230
223
|
def phase=(phase)
|
231
224
|
raise "Unknown phase #{phase}" unless PHASES.include?(phase)
|
225
|
+
|
232
226
|
@phase = phase
|
233
227
|
end
|
234
228
|
end
|
@@ -16,6 +16,9 @@ module ForemanMaintain
|
|
16
16
|
@backup_dir = backup_dir
|
17
17
|
@standard_files = ['config_files.tar.gz']
|
18
18
|
@katello_online_files = ['mongo_dump', 'candlepin.dump', 'foreman.dump']
|
19
|
+
if feature(:pulpcore)
|
20
|
+
@katello_online_files << 'pulpcore.dump'
|
21
|
+
end
|
19
22
|
@katello_offline_files = ['mongo_data.tar.gz', 'pgsql_data.tar.gz']
|
20
23
|
@foreman_online_files = ['foreman.dump']
|
21
24
|
@foreman_offline_files = ['pgsql_data.tar.gz']
|
@@ -35,6 +38,10 @@ module ForemanMaintain
|
|
35
38
|
:pg_globals => map_file(@backup_dir, 'pg_globals.dump'),
|
36
39
|
:metadata => map_file(@backup_dir, 'metadata.yml')
|
37
40
|
}
|
41
|
+
if feature(:pulpcore)
|
42
|
+
@file_map[:pulpcore_dump] = map_file(@backup_dir, 'pulpcore.dump')
|
43
|
+
end
|
44
|
+
@file_map
|
38
45
|
end
|
39
46
|
|
40
47
|
def map_file(backup_dir, filename)
|
@@ -77,92 +84,80 @@ module ForemanMaintain
|
|
77
84
|
foreman_standard_backup? || foreman_online_backup? || foreman_logical_backup?
|
78
85
|
end
|
79
86
|
|
87
|
+
def check_file_existence(existence_map)
|
88
|
+
unless feature(:pulpcore)
|
89
|
+
existence_map[:present].delete(:pulpcore_dump)
|
90
|
+
existence_map[:absent].delete(:pulpcore_dump)
|
91
|
+
end
|
92
|
+
|
93
|
+
existence_map[:present].each do |file|
|
94
|
+
unless file_map[file][:present]
|
95
|
+
return false
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
existence_map[:absent].each do |file|
|
100
|
+
if file_map[file][:present]
|
101
|
+
return false
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
true
|
106
|
+
end
|
107
|
+
|
108
|
+
# TODO: Need to check for pulpcore feature?
|
80
109
|
def katello_standard_backup?
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
file_map[:candlepin_dump][:present] ||
|
85
|
-
file_map[:foreman_dump][:present] ||
|
86
|
-
file_map[:mongo_dump][:present]
|
87
|
-
)
|
110
|
+
check_file_existence(:present => [:mongo_data, :pgsql_data],
|
111
|
+
:absent => [:candlepin_dump, :foreman_dump,
|
112
|
+
:pulpcore_dump, :mongo_dump])
|
88
113
|
end
|
89
114
|
|
90
115
|
def katello_online_backup?
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
!(
|
95
|
-
file_map[:mongo_data][:present] ||
|
96
|
-
file_map[:pgsql_data][:present]
|
97
|
-
)
|
116
|
+
check_file_existence(:present => [:candlepin_dump, :foreman_dump,
|
117
|
+
:pulpcore_dump, :mongo_dump],
|
118
|
+
:absent => [:mongo_data, :pgsql_data])
|
98
119
|
end
|
99
120
|
|
100
121
|
def katello_logical_backup?
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
file_map[:candlepin_dump][:present] &&
|
105
|
-
file_map[:foreman_dump][:present]
|
122
|
+
check_file_existence(:present => [:mongo_dump, :mongo_data, :pgsql_data,
|
123
|
+
:candlepin_dump, :pulpcore_dump, :foreman_dump],
|
124
|
+
:absent => [])
|
106
125
|
end
|
107
126
|
|
108
127
|
def fpc_standard_backup?
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
file_map[:candlepin_dump][:present] ||
|
113
|
-
file_map[:foreman_dump][:present] ||
|
114
|
-
file_map[:mongo_dump][:present]
|
115
|
-
)
|
128
|
+
check_file_existence(:present => [:mongo_data],
|
129
|
+
:absent => [:pgsql_data, :candlepin_dump,
|
130
|
+
:foreman_dump, :mongo_dump, :pulpcore_dump])
|
116
131
|
end
|
117
132
|
|
118
133
|
def fpc_online_backup?
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
file_map[:candlepin_dump][:present] ||
|
124
|
-
file_map[:foreman_dump][:present]
|
125
|
-
)
|
134
|
+
absent = [:mongo_data, :pgsql_data, :candlepin_dump, :foreman_dump]
|
135
|
+
|
136
|
+
check_file_existence(:present => [:mongo_dump], :absent => absent) ||
|
137
|
+
check_file_existence(:present => [:pulpcore_dump], :absent => absent)
|
126
138
|
end
|
127
139
|
|
128
140
|
def fpc_logical_backup?
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
file_map[:pgsql_data][:present] ||
|
133
|
-
file_map[:candlepin_dump][:present] ||
|
134
|
-
file_map[:foreman_dump][:present]
|
135
|
-
)
|
141
|
+
absent = [:pgsql_data, :candlepin_dump, :foreman_dump]
|
142
|
+
check_file_existence(:present => [:mongo_dump, :mongo_data], :absent => absent) ||
|
143
|
+
check_file_existence(:present => [:pulpcore_dump], :absent => absent)
|
136
144
|
end
|
137
145
|
|
138
146
|
def foreman_standard_backup?
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
file_map[:foreman_dump][:present] ||
|
143
|
-
file_map[:mongo_data][:present] ||
|
144
|
-
file_map[:mongo_dump][:present]
|
145
|
-
)
|
147
|
+
check_file_existence(:present => [:pgsql_data],
|
148
|
+
:absent => [:candlepin_dump, :foreman_dump, :pulpcore_dump,
|
149
|
+
:mongo_data, :mongo_dump])
|
146
150
|
end
|
147
151
|
|
148
152
|
def foreman_online_backup?
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
file_map[:pgsql_data][:present] ||
|
153
|
-
file_map[:mongo_data][:present] ||
|
154
|
-
file_map[:mongo_dump][:present]
|
155
|
-
)
|
153
|
+
check_file_existence(:present => [:foreman_dump],
|
154
|
+
:absent => [:candlepin_dump, :pgsql_data,
|
155
|
+
:mongo_data, :mongo_dump])
|
156
156
|
end
|
157
157
|
|
158
158
|
def foreman_logical_backup?
|
159
|
-
|
160
|
-
|
161
|
-
!(
|
162
|
-
file_map[:candlepin_dump][:present] ||
|
163
|
-
file_map[:mongo_data][:present] ||
|
164
|
-
file_map[:mongo_dump][:present]
|
165
|
-
)
|
159
|
+
check_file_existence(:present => [:pgsql_data, :foreman_dump],
|
160
|
+
:absent => [:candlepin_dump, :mongo_data, :mongo_dump])
|
166
161
|
end
|
167
162
|
|
168
163
|
def validate_hostname?
|
@@ -202,12 +197,17 @@ module ForemanMaintain
|
|
202
197
|
|
203
198
|
def sql_dump_files_exist?
|
204
199
|
file_map[:foreman_dump][:present] ||
|
205
|
-
file_map[:candlepin_dump][:present]
|
200
|
+
file_map[:candlepin_dump][:present] ||
|
201
|
+
(feature(:pulpcore) && file_map[:pulpcore_dump][:present])
|
206
202
|
end
|
207
203
|
|
208
204
|
def incremental?
|
209
205
|
!!metadata.fetch('incremental', false)
|
210
206
|
end
|
207
|
+
|
208
|
+
def online_backup?
|
209
|
+
!!metadata.fetch('online', false)
|
210
|
+
end
|
211
211
|
end
|
212
212
|
end
|
213
213
|
end
|