Class: LVM::VolumeGroups

Inherits:
Object
  • Object
show all
Includes:
Enumerable, Volumes, Wrapper
Defined in:
lib/lvm/volume_groups.rb

Instance Method Summary collapse

Methods included from Volumes

#[], #to_s

Constructor Details

#initialize(options) ⇒ VolumeGroups

Returns a new instance of VolumeGroups.



13
14
15
16
17
# File 'lib/lvm/volume_groups.rb', line 13

def initialize(options)
  @vgs = VGS.new(options)
  @pvs = PhysicalVolumes.new(options)
  @lvs = LogicalVolumes.new(options)
end

Instance Method Details

#eachObject

Gather all information about volume groups and their underlying logical and physical volumes.

This is the best representation of LVM data.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/lvm/volume_groups.rb', line 23

def each 
  vgs = @vgs.list
  
  vgs.each do |vg|
    vg.logical_volumes ||= []
    @lvs.each do |lv|
      if lv.vg_uuid == vg.uuid
        vg.logical_volumes << lv
      end
    end
    vg.physical_volumes ||= []
    @pvs.each do |pv|
      if pv.vg_uuid == vg.uuid
        vg.physical_volumes << pv
      end
    end
  end

  return vgs.each {|v| yield v}
end