Sha256: b772383538b7b2653fc0be8ac68840f47384f87b7b8cfe794adee24d460df25b

Contents?: true

Size: 1.67 KB

Versions: 4

Compression:

Stored size: 1.67 KB

Contents

module LinuxAdmin
  class VolumeGroup
    include Common
    extend Common

    # volume group name
    attr_accessor :name

    # 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

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

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

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

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
linux_admin-0.14.0 lib/linux_admin/volume_group.rb
linux_admin-0.13.0 lib/linux_admin/volume_group.rb
linux_admin-0.12.1 lib/linux_admin/volume_group.rb
linux_admin-0.12.0 lib/linux_admin/volume_group.rb