Sha256: b902e12f8358d9185b02ab375eb85ccba8929f4534d137269cd58223f7c7112b
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
# LinuxAdmin Logical Volume Representation # # Copyright (C) 2013 Red Hat Inc. # Licensed under the MIT License class LinuxAdmin class LogicalVolume < LinuxAdmin # logical volume name attr_accessor :name # volume group name attr_accessor :volume_group # logical volume size in sectors attr_accessor :sectors # 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 def initialize(args = {}) @name = args[:name] @volume_group = args[:volume_group] @sectors = args[:sectors] end def extend_with(vg) run!(cmd(:lvextend), :params => [self.name, vg.name]) self end 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 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 end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
linux_admin-0.2.0 | lib/linux_admin/logical_volume.rb |