Class: Lssysconn_entry
- Inherits:
-
Object
- Object
- Lssysconn_entry
- Defined in:
- lib/HMC/lssysconn_entry.rb
Instance Attribute Summary collapse
-
#_errors ⇒ Object
readonly
Returns the value of attribute _errors.
-
#_states ⇒ Object
readonly
Returns the value of attribute _states.
-
#alt_ipaddr ⇒ Object
readonly
Returns the value of attribute alt_ipaddr.
-
#connection_error_code ⇒ Object
readonly
Returns the value of attribute connection_error_code.
-
#hmc_expected ⇒ Object
Returns the value of attribute hmc_expected.
-
#hmc_real ⇒ Object
Returns the value of attribute hmc_real.
-
#ipaddr ⇒ Object
readonly
Returns the value of attribute ipaddr.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
Returns the value of attribute name.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#resource_type ⇒ Object
readonly
Returns the value of attribute resource_type.
-
#serial_num ⇒ Object
readonly
Returns the value of attribute serial_num.
-
#side ⇒ Object
readonly
Returns the value of attribute side.
-
#sp ⇒ Object
readonly
Returns the value of attribute sp.
-
#sp_phys_loc ⇒ Object
readonly
Returns the value of attribute sp_phys_loc.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#type_model_serial_num ⇒ Object
readonly
Returns the value of attribute type_model_serial_num.
Instance Method Summary collapse
- #hmc_expected_add(string) ⇒ Object
-
#initialize(string = nil) ⇒ Lssysconn_entry
constructor
A new instance of Lssysconn_entry.
- #parse(string) ⇒ Object
- #type_model_serial_num_to_array(string) ⇒ Object
Constructor Details
#initialize(string = nil) ⇒ Lssysconn_entry
Returns a new instance of Lssysconn_entry.
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 |
# 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 |
Instance Attribute Details
#_errors ⇒ Object (readonly)
Returns the value of attribute _errors.
21 22 23 |
# File 'lib/HMC/lssysconn_entry.rb', line 21 def _errors @_errors end |
#_states ⇒ Object (readonly)
Returns the value of attribute _states.
20 21 22 |
# File 'lib/HMC/lssysconn_entry.rb', line 20 def _states @_states end |
#alt_ipaddr ⇒ Object (readonly)
Returns the value of attribute alt_ipaddr.
10 11 12 |
# File 'lib/HMC/lssysconn_entry.rb', line 10 def alt_ipaddr @alt_ipaddr end |
#connection_error_code ⇒ Object (readonly)
Returns the value of attribute connection_error_code.
12 13 14 |
# File 'lib/HMC/lssysconn_entry.rb', line 12 def connection_error_code @connection_error_code end |
#hmc_expected ⇒ Object
Returns the value of attribute hmc_expected.
24 25 26 |
# File 'lib/HMC/lssysconn_entry.rb', line 24 def hmc_expected @hmc_expected end |
#hmc_real ⇒ Object
Returns the value of attribute hmc_real.
23 24 25 |
# File 'lib/HMC/lssysconn_entry.rb', line 23 def hmc_real @hmc_real end |
#ipaddr ⇒ Object (readonly)
Returns the value of attribute ipaddr.
9 10 11 |
# File 'lib/HMC/lssysconn_entry.rb', line 9 def ipaddr @ipaddr end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
15 16 17 |
# File 'lib/HMC/lssysconn_entry.rb', line 15 def model @model end |
#name ⇒ Object
Returns the value of attribute name.
26 27 28 |
# File 'lib/HMC/lssysconn_entry.rb', line 26 def name @name end |
#owner ⇒ Object
Returns the value of attribute owner.
27 28 29 |
# File 'lib/HMC/lssysconn_entry.rb', line 27 def owner @owner end |
#resource_type ⇒ Object (readonly)
Returns the value of attribute resource_type.
5 6 7 |
# File 'lib/HMC/lssysconn_entry.rb', line 5 def resource_type @resource_type end |
#serial_num ⇒ Object (readonly)
Returns the value of attribute serial_num.
16 17 18 |
# File 'lib/HMC/lssysconn_entry.rb', line 16 def serial_num @serial_num end |
#side ⇒ Object (readonly)
Returns the value of attribute side.
18 19 20 |
# File 'lib/HMC/lssysconn_entry.rb', line 18 def side @side end |
#sp ⇒ Object (readonly)
Returns the value of attribute sp.
7 8 9 |
# File 'lib/HMC/lssysconn_entry.rb', line 7 def sp @sp end |
#sp_phys_loc ⇒ Object (readonly)
Returns the value of attribute sp_phys_loc.
8 9 10 |
# File 'lib/HMC/lssysconn_entry.rb', line 8 def sp_phys_loc @sp_phys_loc end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
11 12 13 |
# File 'lib/HMC/lssysconn_entry.rb', line 11 def state @state end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
14 15 16 |
# File 'lib/HMC/lssysconn_entry.rb', line 14 def type @type end |
#type_model_serial_num ⇒ Object (readonly)
Returns the value of attribute type_model_serial_num.
6 7 8 |
# File 'lib/HMC/lssysconn_entry.rb', line 6 def type_model_serial_num @type_model_serial_num end |
Instance Method Details
#hmc_expected_add(string) ⇒ Object
158 159 160 161 162 |
# File 'lib/HMC/lssysconn_entry.rb', line 158 def hmc_expected_add(string) string.split(',').each { |hmc| @hmc_expected.push(hmc) } end |
#parse(string) ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# 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) ⇒ Object
152 153 154 155 156 |
# 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 |