xentaur

view xendomain.py @ 57:548bd71dc5fb

+ example
author igor
date Sat Nov 10 20:00:12 2007 +0200 (2007-11-10)
parents 7a1b67a60fce
children 58381d1fe31b
line source
1 ####
2 #
3 # External variables:
4 # * network
5 # * domain
8 try:
9 domain
10 except NameError:
11 import sys
12 network=sys.modules['__main__'].network
13 domain=sys.modules['__main__'].domain
15 import os
16 sys.path.append(os.environ['HOME']+"/xentaur")
17 os.environ['xendomain']=domain
20 ############################
21 # default values:
22 platform='7200'
23 npe_type='npe-400'
24 bridge_bridge_table = {
25 }
27 hidden_bridges = []
28 broken_links = []
29 temporary_links = []
31 real_bridges=[]
32 real_nodes=[]
33 ############################
35 # overriden by network config
36 #try:
37 exec 'from %s import *' % (network)
38 #except:
39 # print "Can't find or interpret module %s with topology description" %(network)
40 # sys.exit(1)
43 N = str(domains.index(domain))
44 name=domain
46 pae=1
47 if pae:
48 kernel = "/boot/vmlinuz-2.6.18-4-xen-686"
49 ramdisk = "/boot/initrd.img-2.6.18-4-xen-686"
50 else:
51 kernel = "/boot/vmlinuz-2.6.18-without-PAE-4-xen-686"
52 ramdisk = "/boot/initrd.img-2.6.18-without-PAE-4-xen-686-domU"
54 #builder='linux'
55 cpu_cap = 10
57 for br in bridges:
58 if not br in vbridges_table.keys():
59 vbridges_table[br]=[]
61 for domain in domains:
62 if not domain in connection_table.keys():
63 connection_table[domain]='true'
65 vbridges = vbridges_table[name]
67 vif=[]
68 x=1
69 for i in vbridges:
70 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
71 x+=1
73 disk = [ 'file:'+xenomips_dir+'xenomips1.img,hda1,r', 'file:'+xenomips_dir+'xenomips-ios1.img,hda2,r', 'file:'+xenomips_dir+'xenomips-config'+N+'.img,hda3,w' ]
74 root = "/dev/hda1 ro"
76 platform_option=""
77 if platform != '7200':
78 platform_option=' -P '+platform
80 npe_option=""
81 if platform == '7200':
82 npe_option=" -t "+npe_type
84 mac_option=' -m 00:16:3e:01:'+hex(int(N))[2:]+':01'
85 if platform != '7200':
86 mac_option =''
88 xenomips='/xenomips/ios/'+ios_name+platform_option+npe_option+mac_option
90 default_network_module={
91 '7200' : 'PA-FE-TX',
92 '3600' : 'NM-1FE-TX',
93 '3725' : 'NM-1FE-TX',
94 '3745' : 'NM-1FE-TX',
95 '2691' : 'NM-1FE-TX',
96 }
97 network_module=default_network_module[platform]
99 if platform== '7200':
100 for i in range(len(vbridges)-1):
101 xenomips += ' -p '+str(i+1)+':'+network_module
102 else:
103 for i in range(len(vbridges)-1):
104 xenomips += ' -p '+str(i+1)+':'+network_module
107 for i in range(len(vbridges)):
108 xenomips += ' -s '+str(i)+':0:gen_eth:eth'+str(i)
110 if domain_types[int(N)] == 'quagga':
111 extra = "quagga"
112 else:
113 extra = "xenomips=\""+xenomips+"\""
115 on_poweroff = 'destroy'
116 on_reboot = 'restart'
117 on_crash = 'restart'