Class: LinuxAdmin::VolumeGroup

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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



24
25
26
# File 'lib/linux_admin/volume_group.rb', line 24

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

Instance Attribute Details

#nameObject

volume group name



4
5
6
# File 'lib/linux_admin/volume_group.rb', line 4

def name
  @name
end

Class Method Details

.create(name, pv) ⇒ Object



41
42
43
44
45
46
47
48
49
# File 'lib/linux_admin/volume_group.rb', line 41

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

.scanObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/linux_admin/volume_group.rb', line 51

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

    out = Common.run!(Common.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



28
29
30
31
32
# File 'lib/linux_admin/volume_group.rb', line 28

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

#extend_with(pv) ⇒ Object



34
35
36
37
38
39
# File 'lib/linux_admin/volume_group.rb', line 34

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