xentaur

diff xentaur.py @ 27:9821c9a972cd

autoredraw + link state
author igor
date Fri Sep 21 20:22:10 2007 +0300 (2007-09-21)
parents 9cef8b150473
children d22ff6f55dc5
line diff
     1.1 --- a/xentaur.py	Fri Sep 21 16:29:16 2007 +0300
     1.2 +++ b/xentaur.py	Fri Sep 21 20:22:10 2007 +0300
     1.3 @@ -102,17 +102,22 @@
     1.4      for host, bridges_raw in vbridges_table.iteritems():
     1.5          i=0
     1.6          for this_bridge in bridges_raw:
     1.7 -            if this_bridge in hidden_bridges:
     1.8 +            if this_bridge in hidden_bridges or not this_bridge:
     1.9                  continue 
    1.10 -            if [ host, this_bridge ] in broken_links:
    1.11 -                links.append(host+" -- "+this_bridge+" [taillabel=\"fa"+str(i)+"/0\",style=dashed]")
    1.12 -            else:
    1.13 +            if not [ host, this_bridge ] in temporary_links:
    1.14                  links.append(host+" -- "+this_bridge+" [taillabel=\"fa"+str(i)+"/0\"]")
    1.15 -            i+=1
    1.16 +                i+=1
    1.17 +       #         if [ host, this_bridge ] in broken_links:
    1.18 +       #             links.append(host+" -- "+this_bridge+" [taillabel=\"fa"+str(i)+"/0\",style=dashed]")
    1.19 +       #         else:
    1.20 +       #             links.append(host+" -- "+this_bridge+" [taillabel=\"fa"+str(i)+"/0\"]")
    1.21  
    1.22      for link in temporary_links:
    1.23          links.append(link[0]+" -- "+link[1]+" [color=blue,len=10,w=5,weight=5]")
    1.24  
    1.25 +    for link in broken_links:
    1.26 +        links.append(link[0]+" -- "+link[1]+" [taillabel=\"fa"+str(i)+"/0\",style=dashed]")
    1.27 +
    1.28      linklist=";\n    ".join(links)
    1.29  
    1.30      graph_dot = {
    1.31 @@ -155,6 +160,9 @@
    1.32      f.close()
    1.33      run_command("neato -Tpng -o xenomips.png xenomips.dot ")
    1.34  
    1.35 +def autoredraw():
    1.36 +    graph()
    1.37 +
    1.38  def start_all():
    1.39          create_bridges_script()
    1.40          create_screens_script()
    1.41 @@ -223,6 +231,11 @@
    1.42          return 1
    1.43      run_command("sudo brctl delif %s vif%s.%s" % (bridge, dom_id, int_number))
    1.44      vbridges_table[domain][int_number]=''
    1.45 +    if [ domain, bridge ] in temporary_links:
    1.46 +        temporary_links.remove([ domain, bridge ])
    1.47 +    else:
    1.48 +        broken_links.append([ domain, bridge ])
    1.49 +    autoredraw()
    1.50  
    1.51  def int_connect(domain, int_number, bridge):
    1.52      """
    1.53 @@ -236,6 +249,11 @@
    1.54          return 1
    1.55      run_command("sudo brctl addif %s vif%s.%s" % (bridge, dom_id, int_number))
    1.56      vbridges_table[domain][int_number]=bridge
    1.57 +    if [ domain, bridge ] in broken_links:
    1.58 +        broken_links.remove([ domain, bridge ])
    1.59 +    else:
    1.60 +        temporary_links.append([ domain, bridge ])
    1.61 +    autoredraw()
    1.62  
    1.63  def int_reconnect(domain, int_number, bridge):
    1.64      """