xentaur

diff xentaur.py @ 30:55b03e2a35c0

another shape added
author igor
date Fri Sep 21 22:40:26 2007 +0300 (2007-09-21)
parents d22ff6f55dc5
children 532f2ed25f70
line diff
     1.1 --- a/xentaur.py	Fri Sep 21 20:48:40 2007 +0300
     1.2 +++ b/xentaur.py	Fri Sep 21 22:40:26 2007 +0300
     1.3 @@ -9,6 +9,8 @@
     1.4  xen_config_name='fabergeN'
     1.5  exec 'from '+xen_config_name+' import bridges,vbridges_table, hidden_bridges, domains, broken_links, temporary_links, domain_types'
     1.6  
     1.7 +bridges_turned_down=[]
     1.8 +
     1.9  from IPython.Shell import IPShellEmbed
    1.10  
    1.11  
    1.12 @@ -85,6 +87,15 @@
    1.13          i+=1
    1.14      return node+" [label=\"  "+node+"\",shapefile=\"shapes/all/"+domain_type[node]+".png\",fontcolor=navy,fontsize=14]"
    1.15  
    1.16 +def graph_bridge(bridge):
    1.17 +    if bridge in hidden_bridges:
    1.18 +        return ""
    1.19 +    if bridge in bridges_turned_down:
    1.20 +        return "%s [shape=none,shapefile=\"shapes/all/switch_turned_down.png\"]" % (bridge)
    1.21 +    else:
    1.22 +        return "%s [shape=none,shapefile=\"shapes/all/switch.png\"]" % (bridge)
    1.23 +
    1.24 +
    1.25  def graph():
    1.26      nodelist=""
    1.27      bridgelist=""
    1.28 @@ -95,7 +106,7 @@
    1.29      nodelist=";\n    ".join(map(graph_node,nodes))
    1.30      if nodelist: nodelist += ";"
    1.31  
    1.32 -    bridgelist=";\n    ".join(set(bridges)-set(hidden_bridges))
    1.33 +    bridgelist=";\n    ".join(map(graph_bridge,bridges))
    1.34      if bridgelist: bridgelist += ";"
    1.35  
    1.36      links=[]
    1.37 @@ -203,13 +214,23 @@
    1.38      """
    1.39      Turn the bridge <bridge> down
    1.40      """
    1.41 -    run_command("sudo ip link set %s down" % bridge)
    1.42 +    if bridge in bridges_turned_down:
    1.43 +        print "Bridge %s is turned down already" % (bridge)
    1.44 +    else:
    1.45 +        bridges_turned_down.append(bridge)
    1.46 +        run_command("sudo ip link set %s down" % bridge)
    1.47 +        autoredraw()
    1.48  
    1.49  def bridge_up(bridge):
    1.50      """
    1.51      Turn the bridge <bridge> up
    1.52      """
    1.53 -    run_command("sudo ip link set %s up" % bridge)
    1.54 +    if not (bridge in bridges_turned_down):
    1.55 +        print "Bridge %s is turned up already" % (bridge)
    1.56 +    else:
    1.57 +        bridges_turned_down.remove(bridge)
    1.58 +        run_command("sudo ip link set %s up" % bridge)
    1.59 +        autoredraw()
    1.60  
    1.61  def show_bridge(bridge):
    1.62      """
    1.63 @@ -273,6 +294,7 @@
    1.64  
    1.65  
    1.66  def dump_start(bridge, filter=""):
    1.67 +    run_command("sudo tcpdump -w xentaur.dump -i %s %s" % (bridge,filter))
    1.68      return 0
    1.69  
    1.70  def dump_stop():