Class: LinuxAdmin::VolumeGroup

Inherits:
Object
  • Object
show all
Extended by:
Common
Includes:
Common
Defined in:
lib/linux_admin/volume_group.rb

Constant Summary

Constants included from Common

Common::BIN_DIRS

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Common

cmd, cmd?, run, run!

Constructor Details

#initialize(args = {}) ⇒ VolumeGroup

other fields available volume group access volume group status internal volume group number maximum number of logical volumes current number of logical volumes open count of all logical volumes in this volume group maximum logical volume size maximum number of physical volumes current number of physical volumes actual number of physical volumes size of volume group in kilobytes physical extent size total number of physical extents for this volume group allocated number of physical extents for this volume group free number of physical extents for this volume group uuid of volume group



27
28
29
# File 'lib/linux_admin/volume_group.rb', line 27

def initialize(args = {})
  @name   = args[:name]
end

Instance Attribute Details

#nameObject

volume group name



7
8
9
# File 'lib/linux_admin/volume_group.rb', line 7

def name
  @name
end

Class Method Details

.create(name, pv) ⇒ Object



44
45
46
47
48
49
50
51
52
# File 'lib/linux_admin/volume_group.rb', line 44

def self.create(name, pv)
  self.scan # initialize local volume groups
  run!(cmd(:vgcreate),
      :params => [name, pv.device_name])
  vg = VolumeGroup.new :name => name
  pv.volume_group = vg
  @vgs << vg
  vg
end

.scanObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/linux_admin/volume_group.rb', line 54

def self.scan
  @vgs ||= begin
    vgs = []

    out = run!(cmd(:vgdisplay), :params => { '-c' => nil}).output

    out.each_line do |line|
      fields = line.lstrip.split(':')
      vgs << VolumeGroup.new(:name => fields[0])
    end

    vgs
  end
end

Instance Method Details

#attach_to(lv) ⇒ Object



31
32
33
34
35
# File 'lib/linux_admin/volume_group.rb', line 31

def attach_to(lv)
  run!(cmd(:lvextend),
      :params => [lv.name, self.name])
  self
end

#extend_with(pv) ⇒ Object



37
38
39
40
41
42
# File 'lib/linux_admin/volume_group.rb', line 37

def extend_with(pv)
  run!(cmd(:vgextend),
      :params => [@name, pv.device_name])
  pv.volume_group = self
  self
end