Class: Lsvg_p
- Inherits:
-
Object
- Object
- Lsvg_p
- Defined in:
- lib/AIX/lsvg_p.rb
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#disks ⇒ Object
readonly
Returns the value of attribute disks.
-
#missing ⇒ Object
readonly
Returns the value of attribute missing.
-
#volume_group ⇒ Object
readonly
Returns the value of attribute volume_group.
Instance Method Summary collapse
-
#initialize(string) ⇒ Lsvg_p
constructor
A new instance of Lsvg_p.
- #parse(string) ⇒ Object
Constructor Details
#initialize(string) ⇒ Lsvg_p
Returns a new instance of Lsvg_p.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/AIX/lsvg_p.rb', line 11 def initialize(string) @data_string_raw='' @disks = Hash.new @volume_group = nil @active = Array.new @missing = Array.new if string.length > 0 self.parse(string) @data_string_raw = string end end |
Instance Attribute Details
#active ⇒ Object (readonly)
Returns the value of attribute active.
9 10 11 |
# File 'lib/AIX/lsvg_p.rb', line 9 def active @active end |
#disks ⇒ Object (readonly)
Returns the value of attribute disks.
6 7 8 |
# File 'lib/AIX/lsvg_p.rb', line 6 def disks @disks end |
#missing ⇒ Object (readonly)
Returns the value of attribute missing.
8 9 10 |
# File 'lib/AIX/lsvg_p.rb', line 8 def missing @missing end |
#volume_group ⇒ Object (readonly)
Returns the value of attribute volume_group.
5 6 7 |
# File 'lib/AIX/lsvg_p.rb', line 5 def volume_group @volume_group end |
Instance Method Details
#parse(string) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/AIX/lsvg_p.rb', line 28 def parse(string) string.split("\n").each { |line| # pp line match_vg = %r{^([\w\_]+):\s*$}.match(line) match_hdisk = %r{([\w\d]+)\s+(active|missing)\s+(\d+)\s+(\d+)\s+([\d\.]+)}.match(line) if line =~ /^\s*$/ next elsif match_vg @volume_group = match_vg[1] elsif line =~ %r{PV_NAME\s+PV\sSTATE\s+TOTAL\sPPs\s+FREE\sPPs\s+FREE\sDISTRIBUTION} next elsif match_hdisk disk = Hash.new disk['pv_name'] = match_hdisk[1] disk['pv_state'] = match_hdisk[2] disk['total_pps'] = match_hdisk[3].to_i disk['free_pps'] = match_hdisk[4].to_i disk['free_distribution'] = match_hdisk[5] if disk['pv_state'] == 'active' @active.push(disk['pv_name']) elsif disk['pv_state'] == 'missing' @missing.push(disk['pv_name']) else pp line raise 'wrong pv state' end @disks[disk['pv_name']] = disk else pp "Wrong line:>#{line}<" end } end |