Sha256: e6de52029e9be33c124e280a80cb99c16b0e1a21e3555dd649ddab4ea9e1cd15

Contents?: true

Size: 1.63 KB

Versions: 21

Compression:

Stored size: 1.63 KB

Contents

module LinuxAdmin
  class PhysicalVolume < Volume
    # physical volume device name
    attr_accessor :device_name

    # volume group name
    attr_accessor :volume_group

    # physical volume size in kilobytes
    attr_accessor :size

    # 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

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

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

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

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

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
linux_admin-4.0.0 lib/linux_admin/physical_volume.rb
linux_admin-3.0.0 lib/linux_admin/physical_volume.rb
linux_admin-2.0.2 lib/linux_admin/physical_volume.rb
linux_admin-2.0.1 lib/linux_admin/physical_volume.rb
linux_admin-2.0.0 lib/linux_admin/physical_volume.rb
linux_admin-1.2.4 lib/linux_admin/physical_volume.rb
linux_admin-1.2.3 lib/linux_admin/physical_volume.rb
linux_admin-1.2.2 lib/linux_admin/physical_volume.rb
linux_admin-1.2.1 lib/linux_admin/physical_volume.rb
linux_admin-1.0.1 lib/linux_admin/physical_volume.rb
linux_admin-1.2.0 lib/linux_admin/physical_volume.rb
linux_admin-1.1.0 lib/linux_admin/physical_volume.rb
linux_admin-1.0.0 lib/linux_admin/physical_volume.rb
linux_admin-0.20.2 lib/linux_admin/physical_volume.rb
linux_admin-0.20.1 lib/linux_admin/physical_volume.rb
linux_admin-0.20.0 lib/linux_admin/physical_volume.rb
linux_admin-0.19.0 lib/linux_admin/physical_volume.rb
linux_admin-0.18.0 lib/linux_admin/physical_volume.rb
linux_admin-0.17.0 lib/linux_admin/physical_volume.rb
linux_admin-0.16.0 lib/linux_admin/physical_volume.rb