Class: Lsmpio
- Inherits:
-
Object
- Object
- Lsmpio
- Defined in:
- lib/AIX/lsmpio.rb
Instance Attribute Summary collapse
-
#data_string_raw ⇒ Object
Returns the value of attribute data_string_raw.
-
#disks ⇒ Object
readonly
Returns the value of attribute disks.
-
#viosname ⇒ Object
Returns the value of attribute viosname.
Instance Method Summary collapse
-
#initialize(string = '') ⇒ Lsmpio
constructor
A new instance of Lsmpio.
- #parse(string) ⇒ Object
Constructor Details
#initialize(string = '') ⇒ Lsmpio
Returns a new instance of Lsmpio.
9 10 11 12 13 14 15 16 17 |
# File 'lib/AIX/lsmpio.rb', line 9 def initialize(string = '') @data = {} @data_string_raw = '' @disks = {} @disks_raw = {} parse(string) unless string.empty? end |
Instance Attribute Details
#data_string_raw ⇒ Object
Returns the value of attribute data_string_raw.
4 5 6 |
# File 'lib/AIX/lsmpio.rb', line 4 def data_string_raw @data_string_raw end |
#disks ⇒ Object (readonly)
Returns the value of attribute disks.
7 8 9 |
# File 'lib/AIX/lsmpio.rb', line 7 def disks @disks end |
#viosname ⇒ Object
Returns the value of attribute viosname.
5 6 7 |
# File 'lib/AIX/lsmpio.rb', line 5 def viosname @viosname end |
Instance Method Details
#parse(string) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/AIX/lsmpio.rb', line 20 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) if @disks_raw[match[1]].nil? @disks_raw[match[1]] = line + "\n" else @disks_raw[match[1]] += line + "\n" end else raise "wrong line: >#{line}" end end @disks_raw.each_pair do |key, disk_raw| disk = Lsmpio_disk.new(disk_raw) @disks[disk.name] = disk end @_parsed = true end |