Class: Kscript::KkLvmManageUtils

Inherits:
Base
  • Object
show all
Defined in:
lib/kscript/plugins/kk_lvm_manage_utils.rb

Constant Summary collapse

DEFAULT_CONFIG =
{
  device: '/dev/sdb',
  volume_group: 'vg_data',
  logical_volume: 'lv_data',
  mount_point: '/data'
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Base

#logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#human_output?, inherited, #with_error_handling

Constructor Details

#initialize(*args, **opts) ⇒ KkLvmManageUtils

Initialize the LVM mounter with configuration

Parameters:

  • config (Hash)

    configuration options



23
24
25
26
# File 'lib/kscript/plugins/kk_lvm_manage_utils.rb', line 23

def initialize(*args, **opts)
  super
  @config = DEFAULT_CONFIG.merge(opts)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



19
20
21
# File 'lib/kscript/plugins/kk_lvm_manage_utils.rb', line 19

def config
  @config
end

Class Method Details

.argumentsObject



45
46
47
# File 'lib/kscript/plugins/kk_lvm_manage_utils.rb', line 45

def self.arguments
  '<device> <mount_point>'
end

.authorObject



57
58
59
# File 'lib/kscript/plugins/kk_lvm_manage_utils.rb', line 57

def self.author
  'kk'
end

.descriptionObject



61
62
63
# File 'lib/kscript/plugins/kk_lvm_manage_utils.rb', line 61

def self.description
  'Mount and manage Linux LVM volumes.'
end

.groupObject



53
54
55
# File 'lib/kscript/plugins/kk_lvm_manage_utils.rb', line 53

def self.group
  'system'
end

.usageObject



49
50
51
# File 'lib/kscript/plugins/kk_lvm_manage_utils.rb', line 49

def self.usage
  "kscript lvm_manage /dev/sda2 /mnt/data\nkscript lvm_manage /dev/vg0/lv_home /mnt/home"
end

Instance Method Details

#runObject



28
29
30
31
32
# File 'lib/kscript/plugins/kk_lvm_manage_utils.rb', line 28

def run
  with_error_handling do
    setup
  end
end

#setupObject



34
35
36
37
38
39
40
41
42
43
# File 'lib/kscript/plugins/kk_lvm_manage_utils.rb', line 34

def setup
  validate_device
  ensure_lvm_tools_installed
  setup_physical_volume
  setup_volume_group
  setup_logical_volume
  format_and_mount_volume
  update_fstab
  display_mount_status
end