Class: LspartitionDlpar
- Inherits:
-
Object
- Object
- LspartitionDlpar
- Defined in:
- lib/HMC/lspartition_dlpar.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#data_string_raw ⇒ Object
readonly
Returns the value of attribute data_string_raw.
Instance Method Summary collapse
-
#initialize(string) ⇒ LspartitionDlpar
constructor
A new instance of LspartitionDlpar.
- #parse(string) ⇒ Object
Constructor Details
#initialize(string) ⇒ LspartitionDlpar
Returns a new instance of LspartitionDlpar.
8 9 10 11 12 13 |
# File 'lib/HMC/lspartition_dlpar.rb', line 8 def initialize(string) @data = {} @data_string_raw='' parse(string) unless string.empty? end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/HMC/lspartition_dlpar.rb', line 5 def data @data end |
#data_string_raw ⇒ Object (readonly)
Returns the value of attribute data_string_raw.
6 7 8 |
# File 'lib/HMC/lspartition_dlpar.rb', line 6 def data_string_raw @data_string_raw end |
Instance Method Details
#parse(string) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/HMC/lspartition_dlpar.rb', line 15 def parse(string) @data_string_raw = string string.gsub!("\nActive", 'Active').split("\n").each do |line| if match = /\<\#(\d+)\>\s+Partition:\<\d+\*\w{4}\-\w{3}\*\w{6,7}\,\s+([\w\.]+)\,\s+(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\>Active:\<(0|1)\>\,\sOS:\<(AIX|[\s\,]+)\>,\sDCaps:\<0x2f\>\,\sCmdCaps:\<0x0b,\s0x0b\>,\sPinnedMem:\<(\d+)\>/.match(line) row = {} row['entry'] = match[1].to_i row['lpar_id'] = match[2].to_i row['system'] = match[3] row['lpar_address'] = match[4] row['ip'] = match[5] row['OS'] = match[6] row['DCaps'] = match[7] row['CmdCaps'] = match[8] row['PinnedMem'] = match[9] @data[row['entry']] = row else raise Exception, "Wrong string >#{line}" end end end |