Class: VirtualSerialAdapter
- Inherits:
-
VirtualAdapter
- Object
- VirtualAdapter
- VirtualSerialAdapter
- Defined in:
- lib/HMC/VirtualSerialAdapter.rb
Instance Attribute Summary collapse
-
#clientOrServer ⇒ Object
Returns the value of attribute clientOrServer.
-
#connectStatus ⇒ Object
below data can be taken only from lshwres, they are exist only for running lpars.
-
#remoteLparID ⇒ Object
Returns the value of attribute remoteLparID.
-
#remoteLparName ⇒ Object
Returns the value of attribute remoteLparName.
-
#remoteSlotNumber ⇒ Object
Returns the value of attribute remoteSlotNumber.
-
#supportsHMC ⇒ Object
Returns the value of attribute supportsHMC.
Attributes inherited from VirtualAdapter
#_type, #frame, #isRequired, #lpar_id, #lpar_name, #state, #vios, #virtualSlotNumber
Instance Method Summary collapse
- #can_parse?(string) ⇒ Boolean
- #decode(string) ⇒ Object (also: #parse)
-
#initialize(string = '') ⇒ VirtualSerialAdapter
constructor
A new instance of VirtualSerialAdapter.
-
#to_s ⇒ Object
virtual-slot-number/client-or-server//[remote-lpar-ID]//[remote-slot-number]/is-required.
Methods inherited from VirtualAdapter
Constructor Details
#initialize(string = '') ⇒ VirtualSerialAdapter
Returns a new instance of VirtualSerialAdapter.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/HMC/VirtualSerialAdapter.rb', line 14 def initialize(string = '') super(string) @clientOrServer = nil @supportsHMC = nil @remoteLparID = nil @remoteLparName = nil @remoteSlotNumber = nil @connectStatus = nil @_type = 'profile' @params = %w[clientOrServer supportsHMC remoteLparID remoteLparName remoteSlotNumber isRequired] @regexp = /^\s*(\d+)\/(server|client)\/([01])\/(\d+|any)\/([\w\-]+|)\/(\d+|any)\/([01])\s*$/ @regexp_real = %r{^\s*lpar_name=([\w\-]+),lpar_id=(\d+),slot_num=(\d+),state=([01]),is_required=([01]),connect_status=(unavailable),adapter_type=(server|client),supports_hmc=([01]),remote_lpar_id=(\d+|any),remote_lpar_name=([\w\-]+|),remote_slot_num=(\d+|any)\s*$} parse(string) unless string.empty? end |
Instance Attribute Details
#clientOrServer ⇒ Object
Returns the value of attribute clientOrServer.
5 6 7 |
# File 'lib/HMC/VirtualSerialAdapter.rb', line 5 def clientOrServer @clientOrServer end |
#connectStatus ⇒ Object
below data can be taken only from lshwres, they are exist only for running lpars
12 13 14 |
# File 'lib/HMC/VirtualSerialAdapter.rb', line 12 def connectStatus @connectStatus end |
#remoteLparID ⇒ Object
Returns the value of attribute remoteLparID.
7 8 9 |
# File 'lib/HMC/VirtualSerialAdapter.rb', line 7 def remoteLparID @remoteLparID end |
#remoteLparName ⇒ Object
Returns the value of attribute remoteLparName.
8 9 10 |
# File 'lib/HMC/VirtualSerialAdapter.rb', line 8 def remoteLparName @remoteLparName end |
#remoteSlotNumber ⇒ Object
Returns the value of attribute remoteSlotNumber.
9 10 11 |
# File 'lib/HMC/VirtualSerialAdapter.rb', line 9 def remoteSlotNumber @remoteSlotNumber end |
#supportsHMC ⇒ Object
Returns the value of attribute supportsHMC.
6 7 8 |
# File 'lib/HMC/VirtualSerialAdapter.rb', line 6 def supportsHMC @supportsHMC end |
Instance Method Details
#can_parse?(string) ⇒ Boolean
33 34 35 36 37 |
# File 'lib/HMC/VirtualSerialAdapter.rb', line 33 def can_parse?(string) return true if @regexp.match(string) or @regexp_real.match(string) false end |
#decode(string) ⇒ Object Also known as: parse
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/HMC/VirtualSerialAdapter.rb', line 40 def decode(string) @data_string_raw = string if match = @regexp.match(string) @virtualSlotNumber = match[1].to_i @clientOrServer = match[2] @supportsHMC = match[3].to_i @remoteLparID = match[4] @remoteLparName = match[5] @remoteSlotNumber = match[6] @isRequired = match[7].to_i elsif match = @regexp_real.match(string) @lpar_name = match[1] @lpar_id = match[2].to_i @virtualSlotNumber = match[3].to_i @state = match[4].to_i @isRequired = match[5].to_i @connectStatus = match[6] @clientOrServer = match[7] @supportsHMC = match[8].to_i @remoteLparID = match[9] @remoteLparName = match[10] @remoteSlotNumber = match[11] @_type = 'real' else raise Exception, "Class VirtualSerialAdapter: RegExp couldn't decode string #{string}" end end |
#to_s ⇒ Object
virtual-slot-number/client-or-server//[remote-lpar-ID]//[remote-slot-number]/is-required
76 77 78 |
# File 'lib/HMC/VirtualSerialAdapter.rb', line 76 def to_s "#{@virtualSlotNumber}/#{@clientOrServer}/#{@supportsHMC}/#{@remoteLparID}/#{@remoteLparName}/#{@remoteSlotNumber}/#{@isRequired}" end |