foreman_maintain 0.5.4 → 0.6.4

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.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -0
  3. data/definitions/checks/check_hotfix_installed.rb +2 -1
  4. data/definitions/checks/disk/performance.rb +25 -10
  5. data/definitions/checks/foreman/validate_external_db_version.rb +28 -0
  6. data/definitions/checks/original_assets.rb +1 -0
  7. data/definitions/checks/pulpcore/db_up.rb +29 -0
  8. data/definitions/checks/repositories/check_non_rh_repository.rb +23 -0
  9. data/definitions/checks/repositories/check_upstream_repository.rb +2 -1
  10. data/definitions/checks/repositories/validate.rb +2 -1
  11. data/definitions/features/apache.rb +19 -0
  12. data/definitions/features/dynflow_sidekiq.rb +39 -0
  13. data/definitions/features/foreman_database.rb +5 -3
  14. data/definitions/features/foreman_proxy.rb +15 -4
  15. data/definitions/features/foreman_server.rb +9 -3
  16. data/definitions/features/foreman_tasks.rb +1 -1
  17. data/definitions/features/installer.rb +9 -2
  18. data/definitions/features/instance.rb +10 -3
  19. data/definitions/features/mongo.rb +1 -1
  20. data/definitions/features/{pulp.rb → pulp2.rb} +1 -1
  21. data/definitions/features/pulpcore.rb +28 -0
  22. data/definitions/features/pulpcore_database.rb +39 -0
  23. data/definitions/features/redis.rb +34 -0
  24. data/definitions/features/service.rb +10 -3
  25. data/definitions/features/tar.rb +18 -13
  26. data/definitions/procedures/backup/config_files.rb +43 -10
  27. data/definitions/procedures/backup/offline/pulpcore_db.rb +57 -0
  28. data/definitions/procedures/backup/online/pulpcore_db.rb +20 -0
  29. data/definitions/procedures/backup/pulp.rb +3 -3
  30. data/definitions/procedures/backup/snapshot/logical_volume_confirmation.rb +2 -1
  31. data/definitions/procedures/backup/snapshot/mount_pulp.rb +3 -3
  32. data/definitions/procedures/backup/snapshot/mount_pulpcore_db.rb +48 -0
  33. data/definitions/procedures/content/prepare.rb +12 -0
  34. data/definitions/procedures/content/switchover.rb +22 -0
  35. data/definitions/procedures/hammer_setup.rb +1 -1
  36. data/definitions/procedures/installer/run.rb +3 -1
  37. data/definitions/procedures/installer/upgrade.rb +6 -1
  38. data/definitions/procedures/packages/update.rb +1 -1
  39. data/definitions/procedures/pulp/migrate.rb +1 -1
  40. data/definitions/procedures/pulpcore/migrate.rb +25 -0
  41. data/definitions/procedures/restore/configs.rb +7 -0
  42. data/definitions/procedures/restore/drop_databases.rb +11 -1
  43. data/definitions/procedures/restore/mongo_dump.rb +2 -2
  44. data/definitions/procedures/restore/pulpcore_dump.rb +30 -0
  45. data/definitions/procedures/service/base.rb +1 -1
  46. data/definitions/procedures/service/stop.rb +1 -1
  47. data/definitions/scenarios/backup.rb +18 -3
  48. data/definitions/scenarios/content.rb +27 -0
  49. data/definitions/scenarios/packages.rb +36 -16
  50. data/definitions/scenarios/restore.rb +7 -1
  51. data/definitions/scenarios/upgrade_to_capsule_6_7.rb +88 -0
  52. data/definitions/scenarios/upgrade_to_capsule_6_7_z.rb +88 -0
  53. data/definitions/scenarios/upgrade_to_capsule_6_8.rb +88 -0
  54. data/definitions/scenarios/upgrade_to_capsule_6_8_z.rb +88 -0
  55. data/definitions/scenarios/upgrade_to_satellite_6_2.rb +13 -5
  56. data/definitions/scenarios/upgrade_to_satellite_6_2_z.rb +13 -5
  57. data/definitions/scenarios/upgrade_to_satellite_6_3.rb +13 -5
  58. data/definitions/scenarios/upgrade_to_satellite_6_3_z.rb +13 -5
  59. data/definitions/scenarios/upgrade_to_satellite_6_4.rb +13 -5
  60. data/definitions/scenarios/upgrade_to_satellite_6_4_z.rb +13 -5
  61. data/definitions/scenarios/upgrade_to_satellite_6_5.rb +13 -5
  62. data/definitions/scenarios/upgrade_to_satellite_6_5_z.rb +13 -5
  63. data/definitions/scenarios/upgrade_to_satellite_6_6.rb +13 -5
  64. data/definitions/scenarios/upgrade_to_satellite_6_6_z.rb +13 -5
  65. data/definitions/scenarios/upgrade_to_satellite_6_7.rb +13 -5
  66. data/definitions/scenarios/upgrade_to_satellite_6_7_z.rb +13 -5
  67. data/definitions/scenarios/upgrade_to_satellite_6_8.rb +88 -0
  68. data/definitions/scenarios/upgrade_to_satellite_6_8_z.rb +88 -0
  69. data/lib/foreman_maintain.rb +31 -0
  70. data/lib/foreman_maintain/cli.rb +2 -0
  71. data/lib/foreman_maintain/cli/content_command.rb +17 -0
  72. data/lib/foreman_maintain/cli/upgrade_command.rb +10 -0
  73. data/lib/foreman_maintain/concerns/base_database.rb +16 -1
  74. data/lib/foreman_maintain/concerns/downstream.rb +13 -8
  75. data/lib/foreman_maintain/concerns/system_helpers.rb +9 -7
  76. data/lib/foreman_maintain/package_manager/dnf.rb +11 -5
  77. data/lib/foreman_maintain/package_manager/yum.rb +15 -5
  78. data/lib/foreman_maintain/reporter/cli_reporter.rb +3 -3
  79. data/lib/foreman_maintain/upgrade_runner.rb +20 -26
  80. data/lib/foreman_maintain/utils/backup.rb +58 -62
  81. data/lib/foreman_maintain/utils/service/abstract.rb +8 -1
  82. data/lib/foreman_maintain/utils/service/systemd.rb +26 -2
  83. data/lib/foreman_maintain/version.rb +1 -1
  84. metadata +26 -4
  85. data/definitions/checks/check_epel_repository.rb +0 -21
@@ -0,0 +1,28 @@
1
+ require 'foreman_maintain/utils/service/systemd'
2
+
3
+ class Features::Pulpcore < ForemanMaintain::Feature
4
+ metadata do
5
+ label :pulpcore
6
+
7
+ confine do
8
+ ForemanMaintain::Utils::Service::Systemd.new('pulpcore-api', 0).exist?
9
+ end
10
+ end
11
+
12
+ def services
13
+ [
14
+ system_service('rh-redis5-redis', 5),
15
+ system_service('pulpcore-api', 10),
16
+ system_service('pulpcore-content', 10),
17
+ system_service('pulpcore-resource-manager', 10),
18
+ system_service('pulpcore-worker@*', 20, :all => true, :skip_enablement => true),
19
+ system_service('httpd', 30)
20
+ ]
21
+ end
22
+
23
+ def config_files
24
+ [
25
+ '/etc/pulp/settings.py'
26
+ ]
27
+ end
28
+ end
@@ -0,0 +1,39 @@
1
+ class Features::PulpcoreDatabase < ForemanMaintain::Feature
2
+ PULPCORE_DB_CONFIG = '/etc/pulp/settings.py'.freeze
3
+
4
+ include ForemanMaintain::Concerns::BaseDatabase
5
+
6
+ metadata do
7
+ label :pulpcore_database
8
+
9
+ confine do
10
+ file_nonzero?(PULPCORE_DB_CONFIG)
11
+ end
12
+ end
13
+
14
+ def configuration
15
+ @configuration || load_configuration
16
+ end
17
+
18
+ def services
19
+ [
20
+ system_service('postgresql', 10, :component => 'pulpcore',
21
+ :db_feature => feature(:pulpcore_database))
22
+ ]
23
+ end
24
+
25
+ private
26
+
27
+ def load_configuration
28
+ full_config = File.read(PULPCORE_DB_CONFIG).split(/[\s,'":]/).reject(&:empty?)
29
+
30
+ @configuration = {}
31
+ @configuration['adapter'] = 'postgresql'
32
+ @configuration['host'] = full_config[full_config.index('HOST') + 1]
33
+ @configuration['port'] = full_config[full_config.index('PORT') + 1]
34
+ @configuration['database'] = full_config[full_config.index('NAME') + 1]
35
+ @configuration['username'] = full_config[full_config.index('USER') + 1]
36
+ @configuration['password'] = full_config[full_config.index('PASSWORD') + 1]
37
+ @configuration
38
+ end
39
+ end
@@ -0,0 +1,34 @@
1
+ class Features::Redis < ForemanMaintain::Feature
2
+ metadata do
3
+ label :redis
4
+
5
+ confine do
6
+ # Luckily, the service name is the same as the package providing it
7
+ server? && find_package(service_name)
8
+ end
9
+ end
10
+
11
+ def services
12
+ [system_service(self.class.service_name, 10)]
13
+ end
14
+
15
+ def config_files
16
+ %w[redis redis.conf].map { |config| File.join(self.class.etc_prefix, config) }
17
+ end
18
+
19
+ class << self
20
+ SCL_NAME = 'rh-redis5'.freeze
21
+
22
+ def etc_prefix
23
+ "/etc/opt/rh/#{SCL_NAME}"
24
+ end
25
+
26
+ def scl_prefix
27
+ "#{SCL_NAME}-"
28
+ end
29
+
30
+ def service_name
31
+ "#{scl_prefix}redis"
32
+ end
33
+ end
34
+ end
@@ -27,7 +27,7 @@ class Features::Service < ForemanMaintain::Feature
27
27
  end
28
28
 
29
29
  def filtered_services(options)
30
- service_list = existing_services
30
+ service_list = include_unregistered_services(existing_services, options[:include])
31
31
  service_list = filter_services(service_list, options)
32
32
  raise 'No services found matching your parameters' unless service_list.any?
33
33
 
@@ -99,9 +99,14 @@ class Features::Service < ForemanMaintain::Feature
99
99
  %w[start stop restart status enable disable].include?(action)
100
100
  end
101
101
 
102
- def filter_services(service_list, options)
103
- service_list = include_unregistered_services(service_list, options[:include])
102
+ def extend_service_list_with_sockets(service_list, options)
103
+ return service_list unless options[:include_sockets]
104
+
105
+ socket_list = service_list.map(&:socket).compact.select(&:exist?)
106
+ service_list + socket_list
107
+ end
104
108
 
109
+ def filter_services(service_list, options)
105
110
  if options[:only] && options[:only].any?
106
111
  service_list = service_list.select do |service|
107
112
  options[:only].any? { |opt| service.matches?(opt) }
@@ -112,6 +117,8 @@ class Features::Service < ForemanMaintain::Feature
112
117
  if options[:exclude] && options[:exclude].any?
113
118
  service_list = service_list.reject { |service| options[:exclude].include?(service.name) }
114
119
  end
120
+
121
+ service_list = extend_service_list_with_sockets(service_list, options)
115
122
  service_list.sort
116
123
  end
117
124
 
@@ -20,9 +20,23 @@ class Features::Tar < ForemanMaintain::Feature
20
20
  # @option options [Boolean] :gzip filter the archive through gzip
21
21
  # @option options [Boolean] :ignore_failed_read do not fail on missing files
22
22
  # @option options [Boolean] :allow_changing_files do not fail on changing files
23
+ def run(options = {})
24
+ logger.debug("Invoking tar from #{options[:directory] || FileUtils.pwd}")
25
+ statuses = options[:allow_changing_files] ? [0, 1] : [0]
26
+ execute!(tar_command(options), :valid_exit_statuses => statuses)
27
+ end
28
+
29
+ def validate_volume_size(size)
30
+ if size.nil? || size !~ /^\d+[bBcGKkMPTw]?$/
31
+ raise ForemanMaintain::Error::Validation,
32
+ "Please specify size according to 'tar --tape-length' format."
33
+ end
34
+ true
35
+ end
36
+
23
37
  # rubocop:disable Metrics/AbcSize, Metrics/MethodLength
24
38
  # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
25
- def run(options = {})
39
+ def tar_command(options)
26
40
  volume_size = options.fetch(:volume_size, nil)
27
41
  absolute_names = options.fetch(:absolute_names, nil)
28
42
  validate_volume_size(volume_size) unless volume_size.nil?
@@ -66,29 +80,20 @@ class Features::Tar < ForemanMaintain::Feature
66
80
  tar_command << options.fetch(:files, '*')
67
81
  end
68
82
 
69
- logger.debug("Invoking tar from #{options[:directory] || FileUtils.pwd}")
70
- statuses = options[:allow_changing_files] ? [0, 1] : [0]
71
- execute!(tar_command.join(' '), :valid_exit_statuses => statuses)
83
+ tar_command.join(' ')
72
84
  end
73
85
  # rubocop:enable Metrics/AbcSize, Metrics/MethodLength
74
86
  # rubocop:enable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
75
87
 
76
- def validate_volume_size(size)
77
- if size.nil? || size !~ /^\d+[bBcGKkMPTw]?$/
78
- raise ForemanMaintain::Error::Validation,
79
- "Please specify size according to 'tar --tape-length' format."
80
- end
81
- true
82
- end
83
-
84
88
  private
85
89
 
86
90
  def default_split_tar_script
87
- utils_path = File.expand_path('../../../bin', __FILE__)
91
+ utils_path = File.expand_path('../../bin', __dir__)
88
92
  split_tar_script = File.join(utils_path, 'foreman-maintain-rotate-tar')
89
93
  unless File.executable?(split_tar_script)
90
94
  raise ForemanMaintain::Error::Fail, "Script #{split_tar_script} is not executable"
91
95
  end
96
+
92
97
  split_tar_script
93
98
  end
94
99
  end
@@ -1,5 +1,8 @@
1
1
  module Procedures::Backup
2
2
  class ConfigFiles < ForemanMaintain::Procedure
3
+ MAX_RETRIES = 3
4
+ RETRY_DELAY = 10
5
+
3
6
  metadata do
4
7
  description 'Backup config files'
5
8
  tags :backup
@@ -8,6 +11,7 @@ module Procedures::Backup
8
11
  Checks::Backup::CertsTarExist.new
9
12
  end
10
13
  end
14
+
11
15
  param :backup_dir, 'Directory where to backup to', :required => true
12
16
  param :proxy_features, 'List of proxy features to backup (default: all)',
13
17
  :array => true, :default => ['all']
@@ -17,19 +21,31 @@ module Procedures::Backup
17
21
  :flag => true, :default => false
18
22
  end
19
23
 
24
+ # rubocop:disable Metrics/MethodLength
20
25
  def run
21
- tarball = File.join(@backup_dir, 'config_files.tar.gz')
22
- increments = File.join(@backup_dir, '.config.snar')
23
- with_spinner('Collecting config files to backup') do
24
- configs, to_exclude = config_files
25
- feature(:tar).run(
26
- :command => 'create', :gzip => true, :archive => tarball,
27
- :listed_incremental => increments, :ignore_failed_read => true,
28
- :exclude => to_exclude, :allow_changing_files => @ignore_changed_files,
29
- :files => configs.join(' ')
30
- )
26
+ logger.debug("Invoking tar from #{FileUtils.pwd}")
27
+ tar_cmd = tar_command
28
+ attempt_no = 1
29
+ loop do
30
+ runner = nil
31
+ with_spinner('Collecting config files to backup') do
32
+ runner = execute_runner(tar_cmd, :valid_exit_statuses => [0, 1])
33
+ end
34
+ break if runner.exit_status == 0 || @ignore_changed_files
35
+
36
+ puts "WARNING: Attempt #{attempt_no}/#{MAX_RETRIES} to collect all config files failed!"
37
+ puts 'Some files were modified during creation of the archive.'
38
+ if attempt_no == MAX_RETRIES
39
+ raise runner.execution_error
40
+ else
41
+ attempt_no += 1
42
+ FileUtils.rm_rf(tarball_path)
43
+ puts "Waiting #{RETRY_DELAY} seconds before re-try"
44
+ sleep(RETRY_DELAY)
45
+ end
31
46
  end
32
47
  end
48
+ # rubocop:enable Metrics/MethodLength
33
49
 
34
50
  # rubocop:disable Metrics/AbcSize
35
51
  def config_files
@@ -54,5 +70,22 @@ module Procedures::Backup
54
70
  [configs, exclude_configs]
55
71
  end
56
72
  # rubocop:enable Metrics/AbcSize
73
+
74
+ private
75
+
76
+ def tar_command
77
+ increments_path = File.join(@backup_dir, '.config.snar')
78
+ configs, to_exclude = config_files
79
+
80
+ feature(:tar).tar_command(
81
+ :command => 'create', :gzip => true, :archive => tarball_path,
82
+ :listed_incremental => increments_path, :ignore_failed_read => true,
83
+ :exclude => to_exclude, :files => configs.join(' ')
84
+ )
85
+ end
86
+
87
+ def tarball_path
88
+ @tarball_path ||= File.join(@backup_dir, 'config_files.tar.gz')
89
+ end
57
90
  end
58
91
  end
@@ -0,0 +1,57 @@
1
+ module Procedures::Backup
2
+ module Offline
3
+ class PulpcoreDB < ForemanMaintain::Procedure
4
+ metadata do
5
+ description 'Backup Pulpcore DB offline'
6
+ tags :backup
7
+ label :backup_offline_pulpcore_db
8
+ for_feature :pulpcore_database
9
+ preparation_steps { Checks::Pulpcore::DBUp.new unless feature(:pulpcore_database).local? }
10
+ param :backup_dir, 'Directory where to backup to', :required => true
11
+ param :tar_volume_size, 'Size of tar volume (indicates splitting)'
12
+ param :mount_dir, 'Snapshot mount directory'
13
+ end
14
+
15
+ def run
16
+ if feature(:pulpcore_database).local?
17
+ if File.exist?(pg_backup_file)
18
+ puts 'Already done'
19
+ else
20
+ local_backup
21
+ end
22
+ else
23
+ puts "Backup of #{pg_data_dir} is not supported for remote databases." \
24
+ ' Doing postgres dump instead...'
25
+ with_spinner('Getting Pulpcore DB dump') do
26
+ feature(:pulpcore_database).dump_db(File.join(@backup_dir, 'pulpcore.dump'))
27
+ end
28
+ end
29
+ end
30
+
31
+ private
32
+
33
+ def local_backup
34
+ with_spinner("Collecting data from #{pg_data_dir}") do
35
+ feature(:pulpcore_database).backup_local(
36
+ pg_backup_file,
37
+ :listed_incremental => File.join(@backup_dir, '.postgres.snar'),
38
+ :volume_size => @tar_volume_size,
39
+ :data_dir => pg_data_dir
40
+ )
41
+ end
42
+ end
43
+
44
+ def pg_backup_file
45
+ File.join(@backup_dir, 'pgsql_data.tar')
46
+ end
47
+
48
+ def pg_data_dir
49
+ return feature(:pulpcore_database).data_dir if @mount_dir.nil?
50
+ mount_point = File.join(@mount_dir, 'pgsql')
51
+ dir = feature(:pulpcore_database).find_base_directory(mount_point)
52
+ fail!("Snapshot of Pulpcore DB was not found mounted in #{mount_point}") if dir.nil?
53
+ dir
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,20 @@
1
+ module Procedures::Backup
2
+ module Online
3
+ class PulpcoreDB < ForemanMaintain::Procedure
4
+ metadata do
5
+ description 'Backup Pulpcore database online'
6
+ tags :backup
7
+ label :backup_online_pulpcore_db
8
+ for_feature :pulpcore_database
9
+ preparation_steps { Checks::Pulpcore::DBUp.new }
10
+ param :backup_dir, 'Directory where to backup to', :required => true
11
+ end
12
+
13
+ def run
14
+ with_spinner('Getting Pulpcore DB dump') do
15
+ feature(:pulpcore_database).dump_db(File.join(@backup_dir, 'pulpcore.dump'))
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -3,7 +3,7 @@ module Procedures::Backup
3
3
  metadata do
4
4
  description 'Backup Pulp data'
5
5
  tags :backup
6
- for_feature :pulp
6
+ for_feature :pulp2
7
7
  param :backup_dir, 'Directory where to backup to', :required => true
8
8
  param :tar_volume_size, 'Size of tar volume (indicates splitting)'
9
9
  param :ensure_unchanged, 'Ensure the data did not change during backup'
@@ -39,9 +39,9 @@ module Procedures::Backup
39
39
  end
40
40
 
41
41
  def pulp_dir
42
- return feature(:pulp).data_dir if @mount_dir.nil?
42
+ return feature(:pulp2).data_dir if @mount_dir.nil?
43
43
  mount_point = File.join(@mount_dir, 'pulp')
44
- dir = feature(:pulp).find_marked_directory(mount_point)
44
+ dir = feature(:pulp2).find_marked_directory(mount_point)
45
45
  unless dir
46
46
  raise ForemanMaintain::Error::Fail,
47
47
  "Pulp base directory not found in the mount point (#{mount_point})"
@@ -12,10 +12,11 @@ module Procedures::Backup
12
12
  backup_lv = get_lv_info(@backup_dir)
13
13
 
14
14
  dbs = {}
15
- dbs[:pulp] = 'Pulp' if feature(:pulp) && !@skip_pulp
15
+ dbs[:pulp] = 'Pulp' if feature(:pulp2) && !@skip_pulp
16
16
  dbs[:mongo] = 'Mongo' if db_local?(:mongo)
17
17
  dbs[:candlepin_database] = 'Candlepin' if db_local?(:candlepin_database)
18
18
  dbs[:foreman_database] = 'Foreman' if db_local?(:foreman_database)
19
+ dbs[:pulpcore_database] = 'Pulpcore' if db_local?(:pulpcore_database)
19
20
 
20
21
  shared_lv = dbs.inject([]) do |list, (db_label, db_name)|
21
22
  db_lv = get_lv_info(feature(db_label).data_dir)
@@ -5,7 +5,7 @@ module Procedures::Backup
5
5
  metadata do
6
6
  description 'Create and mount snapshot of Pulp data'
7
7
  tags :backup
8
- for_feature :pulp
8
+ for_feature :pulp2
9
9
  MountBase.common_params(self)
10
10
  param :skip, 'Skip Pulp content during backup'
11
11
  end
@@ -13,8 +13,8 @@ module Procedures::Backup
13
13
  def run
14
14
  skip if @skip
15
15
  with_spinner('Creating snapshot of Pulp') do |spinner|
16
- feature(:pulp).with_marked_directory(feature(:pulp).data_dir) do
17
- lv_info = get_lv_info(feature(:pulp).data_dir)
16
+ feature(:pulp2).with_marked_directory(feature(:pulp2).data_dir) do
17
+ lv_info = get_lv_info(feature(:pulp2).data_dir)
18
18
  create_lv_snapshot('pulp-snap', @block_size, lv_info[0])
19
19
  spinner.update("Mounting snapshot of Pulp on #{mount_location('pulp')}")
20
20
  mount_snapshot('pulp', lv_info[1])
@@ -0,0 +1,48 @@
1
+ require 'procedures/backup/snapshot/mount_base'
2
+ module Procedures::Backup
3
+ module Snapshot
4
+ class MountPulpcoreDB < MountBase
5
+ metadata do
6
+ description 'Create and mount snapshot of Pulpcore DB'
7
+ tags :backup
8
+ label :backup_snapshot_mount_pulpcore_db
9
+ for_feature :pulpcore_database
10
+ preparation_steps { Checks::Pulpcore::DBUp.new unless feature(:pulpcore_database).local? }
11
+ MountBase.common_params(self)
12
+ param :backup_dir, 'Directory where to backup to'
13
+ end
14
+
15
+ def run
16
+ if feature(:pulpcore_database).local?
17
+ snapshot
18
+ else
19
+ dump_pulpcore
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def dump_pulpcore
26
+ puts 'LV snapshots are not supported for remote databases. Doing postgres dump instead... '
27
+ with_spinner('Getting Pulpcore DB dump') do
28
+ feature(:pulpcore_database).dump_db(File.join(@backup_dir, 'pulpcore.dump'))
29
+ end
30
+ end
31
+
32
+ def snapshot
33
+ mount_point = mount_location('pgsql')
34
+ FileUtils.mkdir_p(mount_point) unless File.directory?(mount_point)
35
+ if directory_empty?(mount_point)
36
+ with_spinner('Creating snapshot of Postgres') do |spinner|
37
+ lv_info = get_lv_info(feature(:pulpcore_database).data_dir)
38
+ create_lv_snapshot('pgsql-snap', @block_size, lv_info[0])
39
+ spinner.update("Mounting snapshot of Postgres on #{mount_point}")
40
+ mount_snapshot('pgsql', lv_info[1])
41
+ end
42
+ else
43
+ puts 'Snapshot of Postgres is already mounted'
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end