xentaur
changeset 38:f71b298798c2
real topologies
author | igor |
---|---|
date | Fri Sep 28 13:03:15 2007 +0300 (2007-09-28) |
parents | 3245e12b66d5 |
children | 54b7c7ae50ec |
files | examples/example1.py shapes/all/cisco.png shapes/all/real_switch.png xenomips_vars.py xentaur.py |
line diff
1.1 --- a/examples/example1.py Tue Sep 25 23:31:23 2007 +0300 1.2 +++ b/examples/example1.py Fri Sep 28 13:03:15 2007 +0300 1.3 @@ -3,8 +3,8 @@ 1.4 1.5 network='netw' 1.6 1.7 -domains = [ 'qua1', 'qua2', 'dyn3', 'qua4', 'qua5', 'dyn6', ] 1.8 -domain_types = [ 'quagga', 'quagga', 'xenomips', 'quagga', 'quagga', 'xenomips', ] 1.9 +domains = [ 'qua1', 'qua2', 'dyn3', 'qua4', 'qua5', 'dyn6', 'cisco1', 'cisco2' ] 1.10 +domain_types = [ 'quagga', 'quagga', 'xenomips', 'quagga', 'quagga', 'xenomips','cisco', 'cisco' ] 1.11 bridges = [ 1.12 'br1', 1.13 'br2', 1.14 @@ -12,6 +12,7 @@ 1.15 'br4', 1.16 'br5', 1.17 'br6', 1.18 + 'cat1', 1.19 ] 1.20 1.21 vbridges_table ={ 1.22 @@ -22,12 +23,17 @@ 1.23 'qua5' : [ 'br4' ], 1.24 'dyn6' : [ 'br5', 'br6' ], 1.25 1.26 + 'cisco1' : ['br6','cat1'], 1.27 + 'cisco2' : ['br6','cat1'], 1.28 } 1.29 1.30 hidden_bridges = [] 1.31 broken_links = [] 1.32 temporary_links = [] 1.33 1.34 +real_bridges=['cat1'] 1.35 +real_nodes=['cisco1','cisco2'] 1.36 + 1.37 N=domains.index(domain) 1.38 if domain_types[N] == 'quagga': 1.39 memory = 64
2.1 Binary file shapes/all/cisco.png has changed
3.1 Binary file shapes/all/real_switch.png has changed
4.1 --- a/xenomips_vars.py Tue Sep 25 23:31:23 2007 +0300 4.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 4.3 @@ -1,4 +0,0 @@ 4.4 - 4.5 -N=1 4.6 - 4.7 -
5.1 --- a/xentaur.py Tue Sep 25 23:31:23 2007 +0300 5.2 +++ b/xentaur.py Fri Sep 28 13:03:15 2007 +0300 5.3 @@ -2,8 +2,6 @@ 5.4 5.5 5.6 import sys,os,time 5.7 -import xenomips_vars 5.8 -xenomips_vars.N='1' 5.9 5.10 xentaur_path=os.environ['HOME']+"/xentaur" 5.11 5.12 @@ -39,7 +37,7 @@ 5.13 return output 5.14 5.15 def create_bridges_script(): 5.16 - unbound_bridges=bridges 5.17 + unbound_bridges=set(bridges)-set(real_bridges) 5.18 create_unbound_bridges="\n".join(map(lambda x: "sudo /usr/sbin/brctl show | awk '{print $1}' | grep -q "+x+" || sudo /usr/sbin/brctl addbr "+x, unbound_bridges)) 5.19 create_unbound_bridges+="\n"+"\n".join(map(lambda x: "sudo /bin/ip link set "+x+" up", unbound_bridges)) 5.20 5.21 @@ -51,11 +49,13 @@ 5.22 5.23 def create_domains_script(): 5.24 for domain in domains: 5.25 - print "sudo /usr/sbin/xm create "+xentaur_path+"/xendomain.py "+" domain="+domain+" network="+network+" && sleep 1 && sudo /usr/sbin/xm sched-credit -d $(sudo /usr/sbin/xm list | grep "+domain+" | awk '{print $2}') -c 10 && sleep 1" 5.26 + if not domain in real_nodes: 5.27 + print "sudo /usr/sbin/xm create "+xentaur_path+"/xendomain.py "+" domain="+domain+" network="+network+" && sleep 1 && sudo /usr/sbin/xm sched-credit -d $(sudo /usr/sbin/xm list | grep "+domain+" | awk '{print $2}') -c 10 && sleep 1" 5.28 5.29 def destroy_domains_script(): 5.30 for domain in domains: 5.31 - print "sudo /usr/sbin/xm shutdown "+domain 5.32 + if not domain in real_nodes: 5.33 + print "sudo /usr/sbin/xm shutdown "+domain 5.34 5.35 def create_screens_script(): 5.36 N=1 5.37 @@ -94,7 +94,9 @@ 5.38 def graph_bridge(bridge): 5.39 if bridge in hidden_bridges: 5.40 return "" 5.41 - if bridge in bridges_turned_down: 5.42 + if bridge in real_bridges: 5.43 + return "%s [shape=none,shapefile=\"shapes/all/real_switch.png\"]" % (bridge) 5.44 + elif bridge in bridges_turned_down: 5.45 return "%s [shape=none,shapefile=\"shapes/all/switch_turned_down.png\"]" % (bridge) 5.46 else: 5.47 return "%s [shape=none,shapefile=\"shapes/all/switch.png\"]" % (bridge) 5.48 @@ -232,6 +234,20 @@ 5.49 dump_start(self.name,filter) 5.50 5.51 5.52 +class Domain: 5.53 + def __init__ (self,name): 5.54 + self.name=name 5.55 + def start(self): 5.56 + return "" 5.57 + def stop(self): 5.58 + return "" 5.59 + def start_commandline(self): 5.60 + return "" 5.61 + def graphviz(self): 5.62 + return "" 5.63 + def get_domain_id(self): 5.64 + return get_domain_id(self.name) 5.65 + 5.66 #----------------------------------------------------------------------- 5.67 # DOMAINS 5.68 5.69 @@ -246,6 +262,9 @@ 5.70 """ 5.71 Turn the bridge <bridge> down 5.72 """ 5.73 + if bridge in real_bridges: 5.74 + print "Bridge %s is a real bridge" % (bridge) 5.75 + return -1 5.76 if bridge in bridges_turned_down: 5.77 print "Bridge %s is turned down already" % (bridge) 5.78 else: 5.79 @@ -257,6 +276,9 @@ 5.80 """ 5.81 Turn the bridge <bridge> up 5.82 """ 5.83 + if bridge in real_bridges: 5.84 + print "Bridge %s is a real bridge" % (bridge) 5.85 + return -1 5.86 if not (bridge in bridges_turned_down): 5.87 print "Bridge %s is turned up already" % (bridge) 5.88 else: 5.89 @@ -268,6 +290,9 @@ 5.90 """ 5.91 Show the state of the bridge <bridge> 5.92 """ 5.93 + if bridge in real_bridges: 5.94 + print "Bridge %s is a real bridge" % (bridge) 5.95 + return -1 5.96 run_command("sudo ip link show %s" % bridge) 5.97 5.98 5.99 @@ -295,8 +320,11 @@ 5.100 Connect the interface with the number <int_number> 5.101 of the domain <domain> to the bridge <bridge> 5.102 """ 5.103 + if bridge in real_bridges: 5.104 + print "Bridge %s is a real bridge" % (bridge) 5.105 + return -1 5.106 + 5.107 dom_id=get_domain_id(domain) 5.108 - 5.109 if vbridges_table[domain][int_number]: 5.110 print "Interface %s of the %s domain is connected already to the %s bridge" % (int_number, domain, vbridges_table[domain][int_number]) 5.111 return 1 5.112 @@ -314,6 +342,10 @@ 5.113 of the domain <domain> from the bridge to which 5.114 it is connected to the bridge <bridge> 5.115 """ 5.116 + if bridge in real_bridges: 5.117 + print "Bridge %s is a real bridge" % (bridge) 5.118 + return -1 5.119 + 5.120 int_disconnect(domain, int_number) 5.121 int_connect(domain, int_number, bridge) 5.122 5.123 @@ -326,6 +358,9 @@ 5.124 5.125 5.126 def dump_start(bridge, filter=""): 5.127 + if bridge in real_bridges: 5.128 + print "Bridge %s is a real bridge" % (bridge) 5.129 + return -1 5.130 try: 5.131 print "Writing dump... (press Ctrl-C to stop)" 5.132 run_command("sudo tcpdump -w xentaur.dump -i %s %s > /dev/null 2>&1 " % (bridge,filter))