Class: OVSImager::DotWriter::BridgeWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/ovsimager/dotwriter.rb

Direct Known Subclasses

NSWriter

Instance Method Summary collapse

Constructor Details

#initialize(dot, dot_peers) ⇒ BridgeWriter

Returns a new instance of BridgeWriter.



53
54
55
56
# File 'lib/ovsimager/dotwriter.rb', line 53

def initialize(dot, dot_peers)
  @dot = dot
  @dot_peers = dot_peers
end

Instance Method Details

#add_iface(name, mark, dump, inet, tag, peer, remote = nil, ns = :root) ⇒ Object



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/ovsimager/dotwriter.rb', line 58

def add_iface(name, mark, dump, inet, tag, peer, remote=nil, ns=:root)
  fill = mark ? "fillcolor=#{mark2color(mark)},style=filled," : ''
  label = "#{name}<BR/><FONT POINT-SIZE=\"10\">#{inet.join('<BR/>')}"
  if tag or remote
    label += "<BR/>#{tag}#{remote && remote.gsub('>','&gt;')}"
  end
  if dump
    label += " </FONT><FONT COLOR=\"blue\">"
    if dump[0] && dump[2] && dump[0] == dump[3] && dump[1] == dump[2]
      label += "<BR/>[#{dump[0]} &lt;-&gt; #{dump[1]}]"
    else
      label += "<BR/>[#{dump[0]} --&gt; #{dump[1]}]" if dump[0]
      label += "<BR/>[#{dump[3]} &lt;-- #{dump[2]}]" if dump[2]
    end
    if dump[4] && dump[4][:cap]
      cap = dump[4][:cap]
      label += "<BR/><FONT POINT-SIZE=\"10\">(#{cap[2]} #{cap[3]} " +
        "#{cap[0]}&lt;=&gt;#{cap[1]})</FONT>"
    end
  end
  label += " </FONT>"
  ename = escape(name) + (ns == :root ? '' : "___" + escape(ns.to_s))
  @dot.puts "    #{ename} [#{fill}label=<#{label}>]"
  if peer
    if peer[0] == ' '
      @dot_peers << "  #{escape(peer.strip)} -- #{ename}"
    elsif name <= peer
      @dot_peers << "  #{ename} -- #{escape(peer)}"
    end
  end
end