Class: LVM::VGConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/lvm/vg_config.rb

Instance Method Summary collapse

Constructor Details

#initialize(vg_name, opts = {}) ⇒ VGConfig

Returns a new instance of VGConfig.



16
17
18
19
20
21
22
23
24
25
# File 'lib/lvm/vg_config.rb', line 16

def initialize(vg_name, opts = {})
  @vgcfgbackup_cmd = opts[:vgcfgbackup_command] || 'vgcfgbackup'
  @vg_name = vg_name
  @parser = VgCfgBackupParser.new
  @root = @parser.parse(vgcfgbackup_output)
  if @root.nil?
    raise RuntimeError,
          "Cannot parse vgcfgbackup output: #{@parser.failure_reason}"
  end
end

Instance Method Details

#descriptionObject



31
32
33
# File 'lib/lvm/vg_config.rb', line 31

def description
  @description ||= @root.variable_value('description')
end

#logical_volumesObject



47
48
49
# File 'lib/lvm/vg_config.rb', line 47

def logical_volumes
  @logical_volumes ||= volume_group.groups['logical_volumes'].groups.to_a.inject({}) { |h,v| h[v[0]] = LVM::LVConfig.new(v[1], v[0], self); h }
end

#physical_volumesObject



43
44
45
# File 'lib/lvm/vg_config.rb', line 43

def physical_volumes
  @physical_volumes ||= volume_group.groups['physical_volumes'].groups.to_a.inject({}) { |h,v| h[v[0]] = LVM::PVConfig.new(v[1]); h }
end

#uuidObject



35
36
37
# File 'lib/lvm/vg_config.rb', line 35

def uuid
  @uuid ||= volume_group.variable_value('id')
end

#versionObject



27
28
29
# File 'lib/lvm/vg_config.rb', line 27

def version
  @version ||= @root.variable_value('version')
end

#volume_groupObject



39
40
41
# File 'lib/lvm/vg_config.rb', line 39

def volume_group
  @volume_group ||= @root.groups[@vg_name]
end