Class: LogicalVolume

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

Overview

One object of this class for each logical volume.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(lvId = nil, lvName = nil, segmentCount = 0) ⇒ LogicalVolume

Returns a new instance of LogicalVolume.



9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 9

def initialize(lvId = nil, lvName = nil, segmentCount = 0)
  @lvId = lvId                        # the UUID of this logical volume
  @lvName = lvName                    # the logical volume's name
  @lvPath = nil           # native use only
  @segmentCount = segmentCount.to_i   # the number of segments in this LV

  @driveHint = nil          # Drive hint, for windows
  @segments = []               # array of this LV's LvSegment objects
  @status = []
  @vgObj = nil                        # a reference to this LV's volume group

  @superblock = nil         # thin metadata superblock (if this is a thin metadata volume)
end

Instance Attribute Details

#driveHintObject

Returns the value of attribute driveHint.



7
8
9
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 7

def driveHint
  @driveHint
end

#lvIdObject

Returns the value of attribute lvId.



7
8
9
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 7

def lvId
  @lvId
end

#lvNameObject

Returns the value of attribute lvName.



7
8
9
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 7

def lvName
  @lvName
end

#lvPathObject

Returns the value of attribute lvPath.



7
8
9
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 7

def lvPath
  @lvPath
end

#segmentCountObject

Returns the value of attribute segmentCount.



7
8
9
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 7

def segmentCount
  @segmentCount
end

#segmentsObject

Returns the value of attribute segments.



7
8
9
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 7

def segments
  @segments
end

#statusObject

Returns the value of attribute status.



7
8
9
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 7

def status
  @status
end

#vgObjObject

Returns the value of attribute vgObj.



7
8
9
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 7

def vgObj
  @vgObj
end

Instance Method Details

#data_volumeObject



71
72
73
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 71

def data_volume
  thin_pool_segment.data_volume
end

#diskObject

MiqDisk object for volume



29
30
31
32
33
34
35
36
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 29

def disk
  @disk ||= begin
    dInfo = OpenStruct.new
    dInfo.lvObj = self
    dInfo.hardwareId = ""
    MiqDisk.new(Lvm2DiskIO, dInfo, 0)
  end
end

#metadata_volumeObject



67
68
69
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 67

def 
  thin_pool_segment.
end

#superblockObject

will raise exception if LogicalVolume is not thin metadata volume



24
25
26
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 24

def superblock
  @superblock ||= Lvm2Thin::SuperBlock.get self
end

#thin?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 46

def thin?
  !thin_segments.empty?
end

#thin_pool?Boolean

Returns:

  • (Boolean)


63
64
65
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 63

def thin_pool?
  !thin_pool_segments.empty?
end

#thin_pool_segmentObject



59
60
61
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 59

def thin_pool_segment
  thin_pool_segments.first
end

#thin_pool_segmentsObject



55
56
57
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 55

def thin_pool_segments
  @thin_pool_segments ||= segments.select { |segment| segment.thin_pool? }
end

#thin_pool_volumeObject



50
51
52
53
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 50

def thin_pool_volume
  return nil unless thin?
  return thin_segment.thin_pool_volume
end

#thin_segmentObject



42
43
44
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 42

def thin_segment
  thin_segments.first
end

#thin_segmentsObject



38
39
40
# File 'lib/VolumeManager/LVM/logical_volume.rb', line 38

def thin_segments
  @thin_segments ||= segments.select { |segment| segment.thin? }
end