class OVSImager::DotWriter

Public Class Methods

new(fname) click to toggle source
# File lib/ovsimager/dotwriter.rb, line 3
def initialize(fname)
  @fname = fname
  @dot = File.open(fname, 'w')
  @dot.puts 'graph interfaces {'
  @dot.puts '  compound=true'
  @dot.puts '  node [shape=rect,margin=0.1]'
  @dot_peers = []
end

Public Instance Methods

bridge(name, br_type) { |bridge_writer| ... } click to toggle source

Draw OVSVS & LinuxBridge

# File lib/ovsimager/dotwriter.rb, line 24
def bridge(name, br_type)
  @dot.puts "  subgraph cluster_br__#{escape(name)} {"
  @dot.puts "    label = \"#{br_type}Bridge #{name}\""

  yield BridgeWriter.new(@dot, @dot_peers)

  @dot.puts "  }"
end
finish(pngname) click to toggle source
# File lib/ovsimager/dotwriter.rb, line 12
def finish(pngname)
  @dot.puts @dot_peers.join "\n"
  @dot.puts '}'
  @dot.close
  @dot = nil

  unless system("dot -Tpng \"#{@fname}\" -o \"#{pngname}\"")
    puts "Failed to execute dot command: #$?"
  end
end
namespace(name) { |ns_writer| ... } click to toggle source

Draw IPNetNS

# File lib/ovsimager/dotwriter.rb, line 34
def namespace(name)
  @dot.puts "  subgraph cluster_ns__#{escape(name)} {"
  @dot.puts "  label = \"Namespace\\n#{name}\""
  @dot.puts "  style = \"filled\""
  @dot.puts "  fillcolor = \"#eeeeee\""
  @dot.puts "  ns__#{escape(name)} " +
    "[label=\"\",style=invis,width=0,height=0,margin=0]"

  yield NSWriter.new(@dot, @dot_peers, name)

  @dot.puts '  }'
end

Private Instance Methods

escape(name) click to toggle source
# File lib/ovsimager/dotwriter.rb, line 48
def escape(name)
  Utils.escape_nodename(name)
end