Class: LinuxAdmin::LogicalVolume
- Inherits:
-
LinuxAdmin
- Object
- LinuxAdmin
- LinuxAdmin::LogicalVolume
- Defined in:
- lib/linux_admin/logical_volume.rb
Constant Summary
Constants inherited from LinuxAdmin
Instance Attribute Summary collapse
-
#name ⇒ Object
logical volume name.
-
#sectors ⇒ Object
logical volume size in sectors.
-
#volume_group ⇒ Object
volume group name.
Class Method Summary collapse
Instance Method Summary collapse
- #extend_with(vg) ⇒ Object
-
#initialize(args = {}) ⇒ LogicalVolume
constructor
other fields available: logical volume access logical volume status internal logical volume number open count of logical volume current logical extents associated to logical volume allocated logical extents of logical volume allocation policy of logical volume read ahead sectors of logical volume major device number of logical volume minor device number of logical volume.
Methods included from Common
Constructor Details
#initialize(args = {}) ⇒ LogicalVolume
other fields available: logical volume access logical volume status internal logical volume number open count of logical volume current logical extents associated to logical volume allocated logical extents of logical volume allocation policy of logical volume read ahead sectors of logical volume major device number of logical volume minor device number of logical volume
29 30 31 32 33 |
# File 'lib/linux_admin/logical_volume.rb', line 29 def initialize(args = {}) @name = args[:name] @volume_group = args[:volume_group] @sectors = args[:sectors] end |
Instance Attribute Details
#name ⇒ Object
logical volume name
9 10 11 |
# File 'lib/linux_admin/logical_volume.rb', line 9 def name @name end |
#sectors ⇒ Object
logical volume size in sectors
15 16 17 |
# File 'lib/linux_admin/logical_volume.rb', line 15 def sectors @sectors end |
#volume_group ⇒ Object
volume group name
12 13 14 |
# File 'lib/linux_admin/logical_volume.rb', line 12 def volume_group @volume_group end |
Class Method Details
.create(name, vg, size) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/linux_admin/logical_volume.rb', line 41 def self.create(name, vg, size) self.scan # initialize local logical volumes run!(cmd(:lvcreate), :params => { '-n' => name, nil => vg.name, '-L' => size}) lv = LogicalVolume.new :name => name, :volume_group => vg, :sectors => size @lvs << lv lv end |
.scan ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/linux_admin/logical_volume.rb', line 52 def self.scan @lvs ||= begin vgs = VolumeGroup.scan lvs = [] out = run!(cmd(:lvdisplay), :params => { '-c' => nil}).output out.each_line do |line| fields = line.split(':') vgname = fields[1] vg = vgs.find { |vg| vg.name == vgname } lvs << LogicalVolume.new(:name => fields[0], :volume_group => vg, :sectors => fields[6].to_i) end lvs end end |
Instance Method Details
#extend_with(vg) ⇒ Object
35 36 37 38 39 |
# File 'lib/linux_admin/logical_volume.rb', line 35 def extend_with(vg) run!(cmd(:lvextend), :params => [self.name, vg.name]) self end |