Class: Lsmap_npiv
- Inherits:
-
Object
- Object
- Lsmap_npiv
- Defined in:
- lib/VIOS/lsmap_npiv.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#data_string_raw ⇒ Object
readonly
Returns the value of attribute data_string_raw.
-
#fc_names ⇒ Object
readonly
Returns the value of attribute fc_names.
-
#sys ⇒ Object
Returns the value of attribute sys.
-
#vios ⇒ Object
Returns the value of attribute vios.
Instance Method Summary collapse
-
#initialize(string = nil, vios = nil, sys = nil) ⇒ Lsmap_npiv
constructor
A new instance of Lsmap_npiv.
- #mapping_for_lpar_id(lpar_id) ⇒ Object
- #parse(string) ⇒ Object
- #to_s(separator = ':') ⇒ Object
- #using_fcs?(name) ⇒ Boolean
- #working_fcs ⇒ Object
- #working_fcs_number ⇒ Object
Constructor Details
#initialize(string = nil, vios = nil, sys = nil) ⇒ Lsmap_npiv
Returns a new instance of Lsmap_npiv.
14 15 16 17 18 19 20 21 |
# File 'lib/VIOS/lsmap_npiv.rb', line 14 def initialize(string = nil, vios = nil, sys = nil) @vios = vios @sys = sys @data = {} @data_string_raw = '' parse(string) unless string.nil? or string.empty? end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
6 7 8 |
# File 'lib/VIOS/lsmap_npiv.rb', line 6 def data @data end |
#data_string_raw ⇒ Object (readonly)
Returns the value of attribute data_string_raw.
7 8 9 |
# File 'lib/VIOS/lsmap_npiv.rb', line 7 def data_string_raw @data_string_raw end |
#fc_names ⇒ Object (readonly)
Returns the value of attribute fc_names.
9 10 11 |
# File 'lib/VIOS/lsmap_npiv.rb', line 9 def fc_names @fc_names end |
#sys ⇒ Object
Returns the value of attribute sys.
12 13 14 |
# File 'lib/VIOS/lsmap_npiv.rb', line 12 def sys @sys end |
#vios ⇒ Object
Returns the value of attribute vios.
11 12 13 |
# File 'lib/VIOS/lsmap_npiv.rb', line 11 def vios @vios end |
Instance Method Details
#mapping_for_lpar_id(lpar_id) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/VIOS/lsmap_npiv.rb', line 45 def mapping_for_lpar_id(lpar_id) result = [] @data.each_pair do |name, entry| result.push(entry) if entry.clntid == lpar_id end result end |
#parse(string) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/VIOS/lsmap_npiv.rb', line 23 def parse(string) @data_string_raw = string if string =~ /Name\s*Physloc/ string.gsub("\nName", '--split--Name').split('--split--').each do |str| entry = Lsmap_npiv_entry.new(str) entry.vios = @vios entry.sys = @sys @data[entry.name] = entry end else string.each_line do |line| entry = Lsmap_npiv_entry.new(line) entry.vios = @vios entry.sys = @sys @data[entry.name] = entry end end working_fcs @data end |
#to_s(separator = ':') ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/VIOS/lsmap_npiv.rb', line 53 def to_s(separator = ':') result = '' @data.each_pair do |name, entry| result += entry.to_s(separator) end result end |
#using_fcs?(name) ⇒ Boolean
81 82 83 |
# File 'lib/VIOS/lsmap_npiv.rb', line 81 def using_fcs?(name) @fc_names.include?(name) end |
#working_fcs ⇒ Object
62 63 64 65 66 67 68 69 |
# File 'lib/VIOS/lsmap_npiv.rb', line 62 def working_fcs result = [] @data.each_pair do |name, entry| result.push(entry.fc_name) end @fc_names = result.uniq @fc_names end |
#working_fcs_number ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/VIOS/lsmap_npiv.rb', line 71 def working_fcs_number result = {} @data.each_pair do |name, entry| result[entry.fc_name] = 0 unless defined? result[entry.fc_name] result[entry.fc_name] += 1 end result end |