Class: Vtd
- Inherits:
-
Object
- Object
- Vtd
- Defined in:
- lib/VIOS/Vtd.rb
Instance Attribute Summary collapse
-
#backing_device ⇒ Object
Returns the value of attribute backing_device.
-
#lun ⇒ Object
Returns the value of attribute lun.
-
#mirrored ⇒ Object
Returns the value of attribute mirrored.
-
#name ⇒ Object
Returns the value of attribute name.
-
#physloc ⇒ Object
Returns the value of attribute physloc.
-
#status ⇒ Object
Returns the value of attribute status.
Instance Method Summary collapse
- #decode(string) ⇒ Object (also: #parse)
-
#initialize(string = '') ⇒ Vtd
constructor
A new instance of Vtd.
- #make_spaces(spaces = 1) ⇒ Object
-
#to_s(fields = 'all', separator = ':') ⇒ Object
list of possible fields taken from: www.ibm.com/support/knowledgecenter/TI0003M/p8hcg/p8hcg_lsmap.htm fields_possible = %w[svsa physloc mirrored clientid vtd lun backing bdphysloc status].
- #to_s_long(spaces = 1) ⇒ Object
- #to_s_long_fixed(spaces = 8) ⇒ Object
Constructor Details
Instance Attribute Details
#backing_device ⇒ Object
Returns the value of attribute backing_device.
12 13 14 |
# File 'lib/VIOS/Vtd.rb', line 12 def backing_device @backing_device end |
#lun ⇒ Object
Returns the value of attribute lun.
11 12 13 |
# File 'lib/VIOS/Vtd.rb', line 11 def lun @lun end |
#mirrored ⇒ Object
Returns the value of attribute mirrored.
14 15 16 |
# File 'lib/VIOS/Vtd.rb', line 14 def mirrored @mirrored end |
#name ⇒ Object
Returns the value of attribute name.
9 10 11 |
# File 'lib/VIOS/Vtd.rb', line 9 def name @name end |
#physloc ⇒ Object
Returns the value of attribute physloc.
13 14 15 |
# File 'lib/VIOS/Vtd.rb', line 13 def physloc @physloc end |
#status ⇒ Object
Returns the value of attribute status.
10 11 12 |
# File 'lib/VIOS/Vtd.rb', line 10 def status @status end |
Instance Method Details
#decode(string) ⇒ Object Also known as: parse
27 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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/VIOS/Vtd.rb', line 27 def decode(string) regExp = %r{^\s*VTD\s+([\w\_\-]+)\s* Status\s+(Available|Defined)\s+ LUN\s+(0x\w+)\s+ Backing\sdevice\s+([\w\-\_\.]+)\s+ Physloc\s+([\w\.\-]+)\s+ Mirrored\s+(false|true)\s*$}mx regExp2 = %r{^\s*VTD\s+([\w\_\-]+)\s* Status\s+(Available|Defined)\s+ LUN\s+(0x\w+)\s+ Backing\sdevice\s+([\w\-\_\.]+)\s+ Physloc\s*$}mx regExp3 = %r{^\s*VTD\s+([\w\_\-]+)\s* LUN\s+(0x\w+)\s+ Backing\sdevice\s+([\w\-\_\.]+)\s+ Physloc\s*$}mx regExp4 = %r{^\s*VTD\s+([\w\_\-]+)\s* Status\s+(Available|Defined)\s+ LUN\s+(0x\w+)\s+ Backing\sdevice\s+([\w\-\_\.]+)\s+ Physloc\s+([\w\.\-]+)\s*$}mx if match = regExp.match(string) @name = match[1] @status = match[2] @lun = match[3] @backing_device = match[4] @physloc = match[5] @mirrored = match[6] elsif match = regExp2.match(string) @name = match[1] @status = match[2] @lun = match[3] @backing_device = match[4] @physloc = match[5].to_s elsif match = regExp3.match(string) @name = match[1] @lun = match[2] @backing_device = match[3] @physloc = match[4].to_s elsif match = regExp4.match(string) @name = match[1] @status = match[2] @lun = match[3] @backing_device = match[4] @physloc = match[5].to_s else raise "VIOS->Vtd: parse: RegExp couldn't decode string >>#{string}<<" end end |
#make_spaces(spaces = 1) ⇒ Object
152 153 154 155 156 |
# File 'lib/VIOS/Vtd.rb', line 152 def make_spaces(spaces = 1) string = '' 1.step(spaces) { |i| string += ' ' } string end |
#to_s(fields = 'all', separator = ':') ⇒ Object
list of possible fields taken from: www.ibm.com/support/knowledgecenter/TI0003M/p8hcg/p8hcg_lsmap.htm fields_possible = %w[svsa physloc mirrored clientid vtd lun backing bdphysloc status]
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/VIOS/Vtd.rb', line 95 def to_s(fields = 'all', separator = ':') result = [] # fields = "physloc:mirrored:vtd:lun:backing:bdphysloc:status" if fields == 'all' fields = "physloc:mirrored:lun:backing:status" if fields == 'all' fields = fields.split(separator) unless fields.kind_of?(Array) fields.each do |field| case field when 'physloc' then result.push(@physloc) when 'mirrored' then result.push(@mirrored) when 'lun' then result.push(@lun) when 'backing' then result.push(@backing_device) #when 'bdphysloc' then result.push(@) when 'status' then result.push(@status) when 'vtd' then result.push(@name) when 'svsa' then next else raise Exception, "Unknown field #{field}" end end result.join(separator) end |
#to_s_long(spaces = 1) ⇒ Object
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/VIOS/Vtd.rb', line 119 def to_s_long(spaces = 1) string = "VTD#{make_spaces(1)}#{@name}" string += "\nStatus#{make_spaces(1)}#{@status}" unless @status.nil? string += "\nLUN#{make_spaces(1)}#{@lun}" unless @lun.nil? string += "\nBacking device#{make_spaces(1)}#{@backing_device}" unless @backing_device.nil? string += if @physloc.empty? "\nPhysloc\n" else "\nPhysloc#{make_spaces(1)}#{@physloc}\n" end string += "Mirrored#{make_spaces(1)}#{@mirrored}\n" unless @mirrored.nil? string end |
#to_s_long_fixed(spaces = 8) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/VIOS/Vtd.rb', line 135 def to_s_long_fixed(spaces = 8) string = "VTD #{make_spaces(spaces)}#{@name}" string += "\nStatus #{make_spaces(spaces)}#{@status}" unless @status.nil? string += "\nLUN #{make_spaces(spaces)}#{@lun}" unless @lun.nil? string += "\nBacking device#{make_spaces(spaces)}#{@backing_device}" unless @backing_device.nil? string += if @physloc.nil? || @physloc.empty? "\nPhysloc\n" else "\nPhysloc #{make_spaces(spaces)}#{@physloc}\n" end string += "Mirrored #{make_spaces(spaces)}#{@mirrored}\n" unless @mirrored.nil? string end |