Class: LVM::Wrapper::LVS

Inherits:
Object
  • Object
show all
Includes:
Reporting
Defined in:
lib/lvm/wrapper/lvs.rb

Constant Summary collapse

BASE_COMMAND =
"lvs #{Reporting::BASE_ARGUMENTS}".freeze
ATTRIBUTES_FILE =
"lvs.yaml".freeze
VOLUME_TYPE =

lv_attr attribute handling constants roughly by order referenced in lib/report/report.c:292 (_lvstatus_disp)

{
  "p" => :pvmove,
  "c" => :conversion,
  "M" => :mirror_not_synced,
  "m" => :mirror,
  "i" => :mirror_image,
  "I" => :mirror_image_not_synced,
  "l" => :mirror_log,
  "v" => :virtual,
  "o" => :origin,
  "s" => :snapshot,
  "S" => :invalid_snapshot,
  # custom, empty is a standard volume
  "-" => :normal,
}.freeze
PERMISSIONS =
{
  "w" => :writeable,
  "r" => :readonly,
  # custom, from reading source
  "-" => :locked_by_pvmove,
}.freeze
ALLOCATION_POLICY =
{
  "c" => :contiguous,
  "l" => :cling,
  "n" => :normal,
  "a" => :anywhere,
  "i" => :inherited,
  "C" => :contiguous_locked,
  "L" => :cling_locked,
  "N" => :normal_locked,
  "A" => :anywhere_locked,
  "I" => :inherited_locked,
}.freeze
FIXED_MINOR =
{
  # code says its a boolean
  "m" => true,
}.freeze
STATE =
{
  "s" => :suspended,
  "a" => :active,
  "i" => :inactive_with_table,
  "d" => :inactive_without_table,
  "S" => :suspended_snapshot,
  "I" => :invalid_snapshot,
}.freeze
DEVICE_OPEN =
{
  # code says its a boolean
  "o" => true,
}.freeze

Constants included from Reporting::Constants

Reporting::Constants::BASE_ARGUMENTS, Reporting::Constants::EMPTY, Reporting::Constants::SEPERATOR

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Reporting

build_command, process_line

Constructor Details

#initialize(options) ⇒ LVS

Returns a new instance of LVS.



12
13
14
15
# File 'lib/lvm/wrapper/lvs.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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



9
10
11
# File 'lib/lvm/wrapper/lvs.rb', line 9

def attributes
  @attributes
end

#commandObject (readonly)

Returns the value of attribute command.



10
11
12
# File 'lib/lvm/wrapper/lvs.rb', line 10

def command
  @command
end

Instance Method Details

#listObject



73
74
75
76
77
78
79
80
81
# File 'lib/lvm/wrapper/lvs.rb', line 73

def list
  output = External.cmd(@command)
  data = parse(output)
  if block_given?
    data.each { |obj| yield obj }
  else
    data
  end
end