class Lssysconn_entry
Attributes
_errors[R]
_states[R]
alt_ipaddr[R]
connection_error_code[R]
hmc_expected[RW]
hmc_real[RW]
ipaddr[R]
model[R]
name[RW]
owner[RW]
resource_type[R]
serial_num[R]
side[R]
sp[R]
sp_phys_loc[R]
state[R]
type[R]
type_model_serial_num[R]
Public Class Methods
new(string = nil)
click to toggle source
# File lib/HMC/lssysconn_entry.rb, line 29 def initialize(string = nil) @resource_type = nil @type_model_serial_num = nil @sp = nil @ipaddr = nil @alt_ipaddr = nil @state = nil @connection_error_code = nil @hmc_real = nil @hmc_expected = [] @owner = nil # in case of type 'sys', owner is fame name # can be taken from commands: # lssyscfg -r sys -F name,serial_num # lssyscfg -r frame -F name,serial_num @name = nil @_states = [ 'pending authentication - password updates required', 'No Connection', 'Failed Authentication', 'Connecting', 'Connected', 'Version Mismatch' ] @_errors = [ 'Incorrect password \w{4}-\w{4}-\w{8}', 'Connecting\s+\w{4}-\w{4}-\w{8}', 'Connection not allowed\s+\w{4}-\w{4}-\w{8}', 'Already connected\s+\w{4}-\w{4}-\w{8}', 'Firmware Password locked\s+\w{4}-\w{4}-\w{8}', 'Version\smismatch\s+\w{4}-\w{4}-\w{8}' ] parse(string) unless string.nil? end
Public Instance Methods
hmc_expected_add(string)
click to toggle source
# File lib/HMC/lssysconn_entry.rb, line 158 def hmc_expected_add(string) string.split(',').each { |hmc| @hmc_expected.push(hmc) } end
parse(string)
click to toggle source
# File lib/HMC/lssysconn_entry.rb, line 69 def parse(string) states = @_states.join('|') errors = @_errors.join('|') sp = 'primary|secondary|unavailable' ip = '\d+\.\d+\.\d+\.\d+' tmsn = '\w{4}\-\w{3}\*\w{7,8}|unavailable' sp_phys_loc = '[\w\.\-]+|unavailable' # resource_type=sys,type_model_serial_num=9117-570*100729E,sp=unavailable,ipaddr=10.0.0.247,alt_ipaddr=unavailable,state=No Connection,connection_error_code=Connecting 0000-0000-00000000 if match = /resource_type=(sys),type_model_serial_num=(#{tmsn}),sp=(#{sp}),ipaddr=(#{ip}),alt_ipaddr=(unavailable),state=(#{states}),connection_error_code=(Connecting \w{4}-\w{4}-\w{8})/i.match(string) @resource_type = match[1] @type_model_serial_num = match[2] @sp = match[3] @ipaddr = match[4] @alt_ipaddr = match[5] @state = match[6] @connection_error_code = match[7] @type, @model, @serial_num = type_model_serial_num_to_array(@type_model_serial_num) elsif match = /resource_type=(sys),type_model_serial_num=(#{tmsn}),sp=(#{sp}),sp_phys_loc=(#{sp_phys_loc}),ipaddr=(#{ip}),alt_ipaddr=(unavailable),state=(#{states}),connection_error_code=(#{errors})/i.match(string) @resource_type = match[1] @type_model_serial_num = match[2] @sp = match[3] @sp_phys_loc = match[4] @ipaddr = match[5] @alt_ipaddr = match[6] @state = match[7] @connection_error_code = match[8] @type, @model, @serial_num = type_model_serial_num_to_array(@type_model_serial_num) elsif match = /resource_type=(sys),type_model_serial_num=(#{tmsn}),sp=(#{sp}),sp_phys_loc=(#{sp_phys_loc}),ipaddr=(#{ip}),alt_ipaddr=(unavailable),state=(#{states})/i.match(string) @resource_type = match[1] @type_model_serial_num = match[2] @sp = match[3] @sp_phys_loc = match[4] @ipaddr = match[5] @alt_ipaddr = match[6] @state = match[7] @type, @model, @serial_num = type_model_serial_num_to_array(@type_model_serial_num) elsif match = /resource_type=(frame),type_model_serial_num=(#{tmsn}),side=(a|b),ipaddr=(#{ip}),state=(#{states})/i.match(string) @resource_type = match[1] @type_model_serial_num = match[2] @side = match[3] @ipaddr = match[4] @state = match[5] @type, @model, @serial_num = type_model_serial_num_to_array(@type_model_serial_num) elsif match = /resource_type=(frame),type_model_serial_num=(#{tmsn}),side=(a|b),ipaddr=(#{ip}),alt_ipaddr=(unavailable),state=(#{states})/i.match(string) @resource_type = match[1] @type_model_serial_num = match[2] @side = match[3] @ipaddr = match[4] @alt_ipaddr = match[5] @state = match[6] @type, @model, @serial_num = type_model_serial_num_to_array(@type_model_serial_num) elsif match = /resource_type=(frame),type_model_serial_num=(#{tmsn}),side=(unavailable),ipaddr=(#{ip}),alt_ipaddr=(unavailable),state=(#{states}),connection_error_code=(#{errors})/i.match(string) @resource_type = match[1] @type_model_serial_num = match[2] @side = match[3] @ipaddr = match[4] @alt_ipaddr = match[5] @state = match[6] @connection_error_code = match[7] @type, @model, @serial_num = type_model_serial_num_to_array(@type_model_serial_num) else pp string raise 'wrong string to parse' end end
type_model_serial_num_to_array(string)
click to toggle source
# File lib/HMC/lssysconn_entry.rb, line 152 def type_model_serial_num_to_array(string) if (match = /(\w{4})\-(\w{3})\*(\w{7,8})/.match(string)) [match[1], match[2], match[3]] end end