Class: LinuxAdmin::PhysicalVolume

Inherits:
Volume
  • Object
show all
Extended by:
Common
Includes:
Common
Defined in:
lib/linux_admin/physical_volume.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 = {}) ⇒ PhysicalVolume

other fields available internal physical volume number (obsolete) physical volume status physical volume (not) allocatable current number of logical volumes on this physical volume physical extent size in kilobytes total number of physical extents free number of physical extents allocated number of physical extents



25
26
27
28
29
# File 'lib/linux_admin/physical_volume.rb', line 25

def initialize(args = {})
  @device_name  = args[:device_name]
  @volume_group = args[:volume_group]
  @size         = args[:size]
end

Instance Attribute Details

#device_nameObject

physical volume device name



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

def device_name
  @device_name
end

#sizeObject

physical volume size in kilobytes



13
14
15
# File 'lib/linux_admin/physical_volume.rb', line 13

def size
  @size
end

#volume_groupObject

volume group name



10
11
12
# File 'lib/linux_admin/physical_volume.rb', line 10

def volume_group
  @volume_group
end

Class Method Details

.create(device) ⇒ Object

specify disk or partition instance to create physical volume on



39
40
41
42
43
44
45
46
47
48
# File 'lib/linux_admin/physical_volume.rb', line 39

def self.create(device)
  self.scan # initialize local physical volumes
  run!(cmd(:pvcreate),
      :params => { nil => device.path})
  pv  = PhysicalVolume.new(:device_name  => device.path,
                           :volume_group => nil,
                           :size => device.size)
  @pvs << pv
  pv
end

.scanObject



50
51
52
53
54
55
56
57
58
# File 'lib/linux_admin/physical_volume.rb', line 50

def self.scan
  @pvs ||= begin
    scan_volumes(cmd(:pvdisplay)) do |fields, vg|
      PhysicalVolume.new(:device_name  => fields[0],
                         :volume_group => vg,
                         :size         => fields[2].to_i)
     end
  end
end

Instance Method Details

#attach_to(vg) ⇒ Object



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

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