Module: YML
- Defined in:
- generators/gen_yml.rb
Overview
Output YAML file from IBLinkinfo output.
Class Method Summary (collapse)
-
+ (Object) gen(ib, file = 'iblinkinfo.yml')
Generate Yaml output file, from the iblinkinfo data.
Class Method Details
+ (Object) gen(ib, file = 'iblinkinfo.yml')
Generate Yaml output file, from the iblinkinfo data.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'generators/gen_yml.rb', line 6 def self.gen(ib, file='iblinkinfo.yml') #Output Yaml file recording port status for a switch File.open(file, "w") do |fd| port_status = {} ib.switch_location.each do |k,loc| switch_ports = [] v = ib.switches[k] if v != nil (1..loc[4]).each do |i| row = [] l = ib.location[v[i][9]] #Connected host / switch row[0] = v[i][9] #Remote host attached to port row[1] = v[i][7] #Remote Port Number if(l != nil && ib.switches[v[i][9]] != nil) row[2] = "" #Alternate name #fd.print "\t-" else row[2] = "#{l == nil ? v[i][9] : "#{l[2]}/P#{"%02d"%v[i][7]}"}" #Alternate name end switch_ports[i] = row end port_status[k] = switch_ports end end fd.write(port_status.to_yaml) end end |