Class: VolumeGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/VolumeManager/LVM/volume_group.rb

Overview

One object of this class for each volume group.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(vgId = nil, vgName = nil, extentSize = nil, seqNo = nil) ⇒ VolumeGroup

Returns a new instance of VolumeGroup.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/VolumeManager/LVM/volume_group.rb', line 7

def initialize(vgId = nil, vgName = nil, extentSize = nil, seqNo = nil)
  @vgId = vgId                        # the UUID of this volme group
  @vgName = vgName                    # the name of this volume group
  @extentSize = extentSize.to_i       # the size of all physical and logical extents (in sectors)
  @seqNo = seqNo

  @lvmType = nil
  @status = []
  @physicalVolumes = {}         # PhysicalVolume objects, hashed by name
  @logicalVolumes = {}          # LogicalVolume objects, hashed by name
end

Instance Attribute Details

#extentSizeObject

Returns the value of attribute extentSize.



5
6
7
# File 'lib/VolumeManager/LVM/volume_group.rb', line 5

def extentSize
  @extentSize
end

#logicalVolumesObject

Returns the value of attribute logicalVolumes.



5
6
7
# File 'lib/VolumeManager/LVM/volume_group.rb', line 5

def logicalVolumes
  @logicalVolumes
end

#lvmTypeObject

Returns the value of attribute lvmType.



5
6
7
# File 'lib/VolumeManager/LVM/volume_group.rb', line 5

def lvmType
  @lvmType
end

#physicalVolumesObject

Returns the value of attribute physicalVolumes.



5
6
7
# File 'lib/VolumeManager/LVM/volume_group.rb', line 5

def physicalVolumes
  @physicalVolumes
end

#seqNoObject

Returns the value of attribute seqNo.



5
6
7
# File 'lib/VolumeManager/LVM/volume_group.rb', line 5

def seqNo
  @seqNo
end

#statusObject

Returns the value of attribute status.



5
6
7
# File 'lib/VolumeManager/LVM/volume_group.rb', line 5

def status
  @status
end

#vgIdObject

Returns the value of attribute vgId.



5
6
7
# File 'lib/VolumeManager/LVM/volume_group.rb', line 5

def vgId
  @vgId
end

#vgNameObject

Returns the value of attribute vgName.



5
6
7
# File 'lib/VolumeManager/LVM/volume_group.rb', line 5

def vgName
  @vgName
end

Instance Method Details

#dumpObject

def getLvs



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/VolumeManager/LVM/volume_group.rb', line 57

def dump
  $log.info "#{@vgName}:"
  $log.info "\tID: #{@vgId}"
  $log.info "\tseqno: #{@seqNo}"
  $log.info "\textent_size: #{@extentSize}"
  $log.info "\tstatus:"
  vg.status.each { |s| $log.info "\t\t#{s}" }

  $log.info "\n\tPhysical Volumes:"
  vg.physicalVolumes.each do |pvName, pv|
    $log.info "\t\t#{pvName}:"
    $log.info "\t\t\tID: #{pv.pvId}"
    $log.info "\t\t\tdevice: #{pv.device}"
    $log.info "\t\t\tdev_size: #{pv.deviceSize}"
    $log.info "\t\t\tpe_start: #{pv.peStart}"
    $log.info "\t\t\tpe_count: #{pv.peCount}"
    $log.info "\t\t\tstatus:"
    pv.status.each { |s| $log.info "\t\t\t\t#{s}" }
  end

  $log.info "\n\tLogical Volumes:"
  @logicalVolumes.each do |lvName, lv|
    $log.info "\t\t#{lvName}:"
    $log.info "\t\t\tID: #{lv.lvId}"
    $log.info "\t\t\tstatus:"
    lv.status.each { |s| $log.info "\t\t\t\t#{s}" }
    $log.info "\n\t\t\tSegments, count = #{lv.segmentCount}:"
    i = 0
    lv.segments.each do |s|
      $log.info "\t\t\t\tsegment - #{i}:"
      $log.info "\t\t\t\t\tstart_extent: #{s.startExtent}"
      $log.info "\t\t\t\t\textent_count: #{s.extentCount}"
      $log.info "\t\t\t\t\ttype: #{s.type}"
      $log.info "\t\t\t\t\tstripe_count: #{s.stripeCount}"
      $log.info "\n\t\t\t\t\tstripes:"
      s.stripes.each { |si| $log.info "\t\t\t\t\t\t#{si}" }
      i += 1
    end
  end
end

#getLvsObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/VolumeManager/LVM/volume_group.rb', line 27

def getLvs
  lvList  = []
  skipLvs = []
  @logicalVolumes.each_value do |lvObj|
    # remove logical volumes w/ 'thin-pool' segments as they are handled internally
    if lvObj.thin_pool?
      skipLvs << lvObj.lvName unless skipLvs.include?(lvObj.lvName)
       = lvObj.thin_pool_segments.collect { |tps| tps. }
      data_volume_names     = lvObj.thin_pool_segments.collect { |tps| tps.pool     }
      ( + data_volume_names).each do |vol|
        skipLvs <<  vol unless skipLvs.include?(vol)
      end
    end
  end

  @logicalVolumes.each_value do |lvObj|
    if skipLvs.include?(lvObj.lvName)
      $log.debug "Ignoring thin volume: #{lvObj.lvName}"
      next
    end

    begin
      lvList << lvObj.disk
    rescue => err
      $log.warn "Failed to load MiqDisk for <#{lvObj.disk.dInfo.fileName}>.  Message:<#{err}> #{err.backtrace}"
    end
  end
  lvList
end

#thin_pool_volumesObject



19
20
21
# File 'lib/VolumeManager/LVM/volume_group.rb', line 19

def thin_pool_volumes
  @thin_pool_volumes ||= logicalVolumes.values.select { |lv| lv.thin_pool? }
end

#thin_volumesObject



23
24
25
# File 'lib/VolumeManager/LVM/volume_group.rb', line 23

def thin_volumes
  @thin_volumes ||= logicalVolumes.values.select { |lv| lv.thin? }
end