Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add compatibility for Ruby 1.8

Resolves backtrace:

$ iblinkinfo.pl | /tmp/topology.rb -f svg -o top1
/tmp/topology.rb:230: wrong argument type Symbol (expected Proc) (TypeError)
  from /usr/lib/ruby/gems/1.8/gems/graph-2.5.1/lib/graph.rb:152:in `instance_eval'
  from /usr/lib/ruby/gems/1.8/gems/graph-2.5.1/lib/graph.rb:152:in `initialize'
  from /usr/lib/ruby/gems/1.8/gems/graph-2.5.1/lib/graph.rb:567:in `new'
  from /usr/lib/ruby/gems/1.8/gems/graph-2.5.1/lib/graph.rb:567:in `digraph'
  from /tmp/topology.rb:210

Tested-by: Paul Morgan <jumanjiman@gmail.com>

Tested on these Ruby versions:
* RHEL 5:    ruby 1.8.5 (2006-08-25) [x86_64-linux]
* RHEL 6:    ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
* Fedora 17: ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

Test procedure:
I saved the output from iblinkinfo in a test environment, then
provided that as input for this patch using each version of Ruby listed above.
  • Loading branch information...
commit dfcff4edec7c59361eb39951c8cf4aadbddebe73 1 parent f8fb938
@jumanjiman jumanjiman authored
Showing with 3 additions and 1 deletion.
  1. +3 −1 topology.rb
View
4 topology.rb
@@ -225,8 +225,10 @@ def port_label(i, ports, color)
else
proc { |e| true }
end
+
+ id_mapper = proc { |e| e.sw_id }
- sw_list = links.select(&lid_filter).map(&:sw_id).uniq
+ sw_list = links.select(&lid_filter).map(&id_mapper).uniq
sw_list.each do |id|
ports = (1..36).to_a.map { |e| "<p%d> %d" % [e, e] }.join("|")
Please sign in to comment.
Something went wrong with that request. Please try again.