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