igor@34: #### igor@34: # igor@34: # External variables: igor@34: # * network igor@34: # * domain igor@34: igor@34: igor@35: try: igor@35: domain igor@35: except NameError: igor@35: import sys igor@35: network=sys.modules['__main__'].network igor@35: domain=sys.modules['__main__'].domain igor@34: igor@58: import os,re nata@36: sys.path.append(os.environ['HOME']+"/xentaur") nata@36: os.environ['xendomain']=domain nata@36: igor@58: igor@58: igor@47: igor@47: ############################ igor@47: # default values: igor@58: platform='' igor@47: npe_type='npe-400' igor@47: bridge_bridge_table = { igor@47: } igor@47: igor@58: domains_brief=[] igor@58: domains=[] igor@58: domain_types=[] igor@58: domain_notes=[] igor@58: domain_subtypes=[] igor@58: igor@47: hidden_bridges = [] igor@47: broken_links = [] igor@47: temporary_links = [] igor@47: igor@47: real_bridges=[] igor@47: real_nodes=[] igor@58: # overriden by network config igor@47: ############################ igor@47: igor@58: def process_domains_brief(): igor@58: global domains, domain_types, real_nodes, domain_notes igor@58: node_brief_re=re.compile('([a-zA-Z_0-9-]*)(?::([a-zA-Z_0-9-]*))?(?::([a-zA-Z_0-9-]*))?(\*?)(?:#(.*))?') igor@58: if len(domains)==0: igor@58: domains=map(lambda x:node_brief_re.search(x).groups()[0] or '', domains_brief) igor@58: if len(domain_types)==0: igor@58: domain_types=map(lambda x:node_brief_re.search(x).groups()[1] or '', domains_brief) igor@58: if len(domain_subtypes)==0: igor@58: domain_subtypes=map(lambda x:node_brief_re.search(x).groups()[2] or '', domains_brief) igor@58: if len(real_nodes)==0: igor@58: i=0 igor@58: for brief in domains_brief: igor@58: if node_brief_re.search(brief).groups()[3] == '*': igor@58: real_nodes.append(domains[i]) igor@58: i+=1 igor@58: if len(domain_notes)==0: igor@58: domain_notes=map(lambda x:node_brief_re.search(x).groups()[4] or '', domains_brief) igor@58: igor@58: ############################ igor@35: #try: igor@35: exec 'from %s import *' % (network) igor@35: #except: igor@35: # print "Can't find or interpret module %s with topology description" %(network) igor@35: # sys.exit(1) igor@34: igor@58: process_domains_brief() igor@34: igor@35: N = str(domains.index(domain)) igor@35: name=domain igor@34: igor@34: pae=1 igor@34: if pae: igor@40: kernel = "/boot/vmlinuz-2.6.18-4-xen-686" igor@40: ramdisk = "/boot/initrd.img-2.6.18-4-xen-686" igor@34: else: igor@34: kernel = "/boot/vmlinuz-2.6.18-without-PAE-4-xen-686" igor@34: ramdisk = "/boot/initrd.img-2.6.18-without-PAE-4-xen-686-domU" igor@34: igor@34: #builder='linux' igor@34: cpu_cap = 10 igor@34: igor@56: for br in bridges: igor@56: if not br in vbridges_table.keys(): igor@56: vbridges_table[br]=[] igor@56: igor@56: for domain in domains: igor@56: if not domain in connection_table.keys(): igor@56: connection_table[domain]='true' igor@34: igor@34: vbridges = vbridges_table[name] igor@34: igor@34: vif=[] igor@34: x=1 igor@34: for i in vbridges: igor@34: vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:]) igor@34: x+=1 igor@34: igor@34: 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' ] igor@34: root = "/dev/hda1 ro" igor@34: igor@58: if domain_subtypes[N] != '' and platform == '': igor@58: platform=domain_subtypes[N] igor@58: igor@58: if platform = '': igor@58: platform='7200' igor@42: platform_option="" igor@42: if platform != '7200': igor@42: platform_option=' -P '+platform igor@42: igor@42: npe_option="" igor@42: if platform == '7200': igor@42: npe_option=" -t "+npe_type igor@42: igor@45: mac_option=' -m 00:16:3e:01:'+hex(int(N))[2:]+':01' igor@45: if platform != '7200': igor@45: mac_option ='' igor@34: igor@45: xenomips='/xenomips/ios/'+ios_name+platform_option+npe_option+mac_option igor@45: igor@45: default_network_module={ igor@44: '7200' : 'PA-FE-TX', igor@44: '3600' : 'NM-1FE-TX', igor@44: '3725' : 'NM-1FE-TX', igor@44: '3745' : 'NM-1FE-TX', igor@44: '2691' : 'NM-1FE-TX', igor@44: } igor@44: network_module=default_network_module[platform] igor@44: igor@48: if platform== '7200': igor@48: for i in range(len(vbridges)-1): igor@48: xenomips += ' -p '+str(i+1)+':'+network_module igor@48: else: igor@48: for i in range(len(vbridges)-1): igor@48: xenomips += ' -p '+str(i+1)+':'+network_module igor@48: igor@34: igor@34: for i in range(len(vbridges)): igor@34: xenomips += ' -s '+str(i)+':0:gen_eth:eth'+str(i) igor@34: igor@34: if domain_types[int(N)] == 'quagga': igor@34: extra = "quagga" igor@34: else: igor@34: extra = "xenomips=\""+xenomips+"\"" igor@34: igor@34: on_poweroff = 'destroy' igor@34: on_reboot = 'restart' igor@34: on_crash = 'restart' igor@34: