xentaur

view xendomain.py @ 59:9d54d94a7dff

minifixes
author igor
date Sun Nov 11 19:46:27 2007 +0200 (2007-11-11)
parents 58381d1fe31b
children e7b9761c03e8
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,re
16 sys.path.append(os.environ['HOME']+"/xentaur")
17 os.environ['xendomain']=domain
22 ############################
23 # default values:
24 platform=''
25 npe_type='npe-400'
26 bridge_bridge_table = {
27 }
29 domains_brief=[]
30 domains=[]
31 domain_types=[]
32 domain_notes=[]
33 domain_subtypes=[]
35 hidden_bridges = []
36 broken_links = []
37 temporary_links = []
39 real_bridges=[]
40 real_nodes=[]
41 # overriden by network config
42 ############################
44 def process_domains_brief():
45 global domains, domain_types, real_nodes, domain_notes, domain_subtypes
46 node_brief_re=re.compile('([a-zA-Z_0-9-]*)(?::([a-zA-Z_0-9-]*))?(?::([a-zA-Z_0-9-]*))?(\*?)(?:#(.*))?')
47 if len(domains)==0:
48 domains=map(lambda x:node_brief_re.search(x).groups()[0] or '', domains_brief)
49 if len(domain_types)==0:
50 domain_types=map(lambda x:node_brief_re.search(x).groups()[1] or '', domains_brief)
51 if len(domain_subtypes)==0:
52 domain_subtypes=map(lambda x:node_brief_re.search(x).groups()[2] or '', domains_brief)
53 if len(real_nodes)==0:
54 i=0
55 for brief in domains_brief:
56 if node_brief_re.search(brief).groups()[3] == '*':
57 real_nodes.append(domains[i])
58 i+=1
59 if len(domain_notes)==0:
60 domain_notes=map(lambda x:node_brief_re.search(x).groups()[4] or '', domains_brief)
62 ############################
63 #try:
64 exec 'from %s import *' % (network)
65 #except:
66 # print "Can't find or interpret module %s with topology description" %(network)
67 # sys.exit(1)
69 process_domains_brief()
71 N = domains.index(domain)
72 name=domain
74 pae=1
75 if pae:
76 kernel = "/boot/vmlinuz-2.6.18-4-xen-686"
77 ramdisk = "/boot/initrd.img-2.6.18-4-xen-686"
78 else:
79 kernel = "/boot/vmlinuz-2.6.18-without-PAE-4-xen-686"
80 ramdisk = "/boot/initrd.img-2.6.18-without-PAE-4-xen-686-domU"
82 #builder='linux'
83 cpu_cap = 10
88 for br in bridges:
89 if not br in vbridges_table.keys():
90 vbridges_table[br]=[]
92 for domain in domains:
93 if not domain in connection_table.keys():
94 connection_table[domain]='true'
96 vbridges = vbridges_table[name]
98 vif=[]
99 x=1
100 for i in vbridges:
101 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(N)[2:]+':'+hex(int('c0',16)+x)[2:])
102 x+=1
104 disk = [ 'file:'+xenomips_dir+'xenomips1.img,hda1,r', 'file:'+xenomips_dir+'xenomips-ios1.img,hda2,r', 'file:'+xenomips_dir+'xenomips-config'+str(N)+'.img,hda3,w' ]
105 root = "/dev/hda1 ro"
107 if domain_types[N] == 'quagga':
108 memory = 64
109 else:
110 memory = 400
112 if domain_subtypes[N] != '' and platform == '':
113 platform=domain_subtypes[N]
115 if platform == '':
116 platform='7200'
117 platform_option=""
118 if platform != '7200':
119 platform_option=' -P '+platform
121 npe_option=""
122 if platform == '7200':
123 npe_option=" -t "+npe_type
125 mac_option=' -m 00:16:3e:01:'+hex(N)[2:]+':01'
126 if platform != '7200':
127 mac_option =''
129 xenomips='/xenomips/ios/'+ios_name+platform_option+npe_option+mac_option
131 default_network_module={
132 '7200' : 'PA-FE-TX',
133 '3600' : 'NM-1FE-TX',
134 '3725' : 'NM-1FE-TX',
135 '3745' : 'NM-1FE-TX',
136 '2691' : 'NM-1FE-TX',
137 }
138 network_module=default_network_module[platform]
140 if platform== '7200':
141 for i in range(len(vbridges)-1):
142 xenomips += ' -p '+str(i+1)+':'+network_module
143 else:
144 for i in range(len(vbridges)-1):
145 xenomips += ' -p '+str(i+1)+':'+network_module
148 for i in range(len(vbridges)):
149 xenomips += ' -s '+str(i)+':0:gen_eth:eth'+str(i)
151 if domain_types[N] == 'quagga':
152 extra = "quagga"
153 else:
154 extra = "xenomips=\""+xenomips+"\""
156 on_poweroff = 'destroy'
157 on_reboot = 'restart'
158 on_crash = 'restart'