class LVM::Wrapper::PVS

Constants

ALLOCATABLE

pv_attr attribute handling constants roughly by order referenced in lib/report/report.c:360 (_pvstatus_disp)

ATTRIBUTES_FILE
BASE_COMMAND
EXPORTED

Attributes

attributes[R]
command[R]

Public Class Methods

new(options) click to toggle source
# File lib/lvm/wrapper/pvs.rb, line 12
def initialize(options)
  @attributes = Attributes.load(options[:version], ATTRIBUTES_FILE)
  @command = "#{options[:command]} #{Reporting.build_command(attributes, BASE_COMMAND, options[:additional_arguments])}"
end

Public Instance Methods

list() { |obj| ... } click to toggle source
# File lib/lvm/wrapper/pvs.rb, line 32
def list
  output = External.cmd(@command)
  data = parse(output)
  if block_given?
    return data.each { |obj| yield obj }
  else
    return data
  end
end

Private Instance Methods

parse(output) { |volume| ... } click to toggle source

Parses the output of self.command

# File lib/lvm/wrapper/pvs.rb, line 54
def parse(output)
  volumes = []

  output.split("\n").each do |line|
    args = process_line(attributes, line)

    # now we force some types to ints since we've requested them as bytes
    # without a suffix
    args[:size] = args[:size].to_i

    # we resolve the attributes line to nicer symbols
    args.merge!(parse_pv_attr(args[:attr]))

    # finally build our object
    volume = PhysicalVolume.new(args)

    if block_given?
      yield volume
    else
      volumes << volume
    end
  end

  return volumes
end