Class: Lsmpio_disk

Inherits:
Object
  • Object
show all
Defined in:
lib/AIX/lsmpio_disk.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string = '') ⇒ Lsmpio_disk

Returns a new instance of Lsmpio_disk.



11
12
13
14
15
# File 'lib/AIX/lsmpio_disk.rb', line 11

def initialize(string = '')
  @name = nil
  @paths = {}
  parse(string) unless string.empty?
end

Instance Attribute Details

#data_string_rawObject

Returns the value of attribute data_string_raw.



5
6
7
# File 'lib/AIX/lsmpio_disk.rb', line 5

def data_string_raw
  @data_string_raw
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/AIX/lsmpio_disk.rb', line 7

def name
  @name
end

#pathsObject (readonly)

Returns the value of attribute paths.



9
10
11
# File 'lib/AIX/lsmpio_disk.rb', line 9

def paths
  @paths
end

#viosnameObject

Returns the value of attribute viosname.



6
7
8
# File 'lib/AIX/lsmpio_disk.rb', line 6

def viosname
  @viosname
end

Instance Method Details

#parse(string) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/AIX/lsmpio_disk.rb', line 17

def parse(string)
  @data_string_raw = string

  regexp = %r{(hdisk\d+)\s+(\d+)\s+(Enabled|Disabled|Failed|Missing)\s+([\w\,]+)\s+(fscsi\d+)\s+(\w+)\,(\w+)}
  string.each_line do |line|

    line = line.strip
    next if line =~ /name/
    next if line =~ /^\s*$/
    next if line =~ /^[=]+$/

    if match = regexp.match(line)
      path = Lsmpio_entry.new(line)
      @paths[path.path_id] = path
      if @name.nil?
        @name = path.name
      else
        raise "Inconsistance data: #{line}" if @name != path.name
      end
    else
      raise "Wrong line:>#{line}<"
    end
  end
end