Module: ForemanMaintain::Cli::BackupCommon::ClassMethods

Defined in:
lib/foreman_maintain/cli/backup_command.rb

Instance Method Summary collapse

Instance Method Details

#common_backup_optionsObject

rubocop:disable Metrics/MethodLength



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
# File 'lib/foreman_maintain/cli/backup_command.rb', line 33

def common_backup_options
  # TODO: BACKUP_DIR in f-m config - should be default?
  parameter 'BACKUP_DIR', 'Path to backup dir',
            :completion => { :type => :directory },
            :attribute_name => :backup_root_dir do |dir|
    File.expand_path(dir)
  end
  option ['-s', '--skip-pulp-content'], :flag, 'Do not backup Pulp content'
  option ['-p', '--preserve-directory'], :flag, 'Do not create a time-stamped subdirectory'
  option ['-t', '--split-pulp-tar'], 'SPLIT_SIZE',
         'Split pulp data into files of a specified size, i.e. (100M, 50G). ' \
         "See '--tape-length' in 'info tar' for all sizes" do |size|
    self.class.valid_tape_size(size)
  end
  option ['-i', '--incremental'], 'PREVIOUS_BACKUP_DIR',
         'Backup changes since previous backup',
         :completion => { :type => :directory } do |dir|
    unless File.directory?(dir)
      raise ArgumentError, "Previous backup directory does not exist: #{dir}"
    end

    dir
  end
  proxy_name = ForemanMaintain.detector.feature(:capsule) ? 'Capsule' : 'Foreman Proxy'
  option '--features', 'FEATURES',
         "#{proxy_name} features to include in the backup. " \
             'Valid features are tftp, dns, dhcp, openscap, and all.', :multivalued => true
end

#valid_tape_size(size) ⇒ Object

rubocop:enable Metrics/MethodLength



63
64
65
66
67
68
69
70
# File 'lib/foreman_maintain/cli/backup_command.rb', line 63

def valid_tape_size(size)
  begin
    ForemanMaintain.detector.feature(:tar).validate_volume_size(size)
  rescue ForemanMaintain::Error::Validation => e
    raise ArgumentError, e.message
  end
  size
end