xentaur

changeset 58:58381d1fe31b

domains_brief support
author igor
date Sun Nov 11 19:22:52 2007 +0200 (2007-11-11)
parents 548bd71dc5fb
children 9d54d94a7dff
files xendomain.py
line diff
     1.1 --- a/xendomain.py	Sat Nov 10 20:00:12 2007 +0200
     1.2 +++ b/xendomain.py	Sun Nov 11 19:22:52 2007 +0200
     1.3 @@ -12,33 +12,61 @@
     1.4      network=sys.modules['__main__'].network
     1.5      domain=sys.modules['__main__'].domain
     1.6  
     1.7 -import os
     1.8 +import os,re
     1.9  sys.path.append(os.environ['HOME']+"/xentaur")
    1.10  os.environ['xendomain']=domain
    1.11  
    1.12 +        
    1.13 +        
    1.14  
    1.15  ############################
    1.16  # default values:
    1.17 -platform='7200'
    1.18 +platform=''
    1.19  npe_type='npe-400'
    1.20  bridge_bridge_table = {
    1.21  }
    1.22  
    1.23 +domains_brief=[]
    1.24 +domains=[]
    1.25 +domain_types=[]
    1.26 +domain_notes=[]
    1.27 +domain_subtypes=[]
    1.28 +
    1.29  hidden_bridges = []
    1.30  broken_links = []
    1.31  temporary_links = []
    1.32  
    1.33  real_bridges=[]
    1.34  real_nodes=[]
    1.35 +# overriden by network config
    1.36  ############################
    1.37  
    1.38 -# overriden by network config
    1.39 +def process_domains_brief():
    1.40 +    global domains, domain_types, real_nodes, domain_notes
    1.41 +    node_brief_re=re.compile('([a-zA-Z_0-9-]*)(?::([a-zA-Z_0-9-]*))?(?::([a-zA-Z_0-9-]*))?(\*?)(?:#(.*))?')
    1.42 +    if len(domains)==0:
    1.43 +        domains=map(lambda x:node_brief_re.search(x).groups()[0] or '', domains_brief)
    1.44 +    if len(domain_types)==0:
    1.45 +        domain_types=map(lambda x:node_brief_re.search(x).groups()[1] or '', domains_brief)
    1.46 +    if len(domain_subtypes)==0:
    1.47 +        domain_subtypes=map(lambda x:node_brief_re.search(x).groups()[2] or '', domains_brief)
    1.48 +    if len(real_nodes)==0:
    1.49 +        i=0
    1.50 +        for brief in domains_brief:
    1.51 +            if node_brief_re.search(brief).groups()[3] == '*':
    1.52 +                real_nodes.append(domains[i])
    1.53 +            i+=1
    1.54 +    if len(domain_notes)==0:
    1.55 +        domain_notes=map(lambda x:node_brief_re.search(x).groups()[4] or '', domains_brief)
    1.56 +
    1.57 +############################
    1.58  #try:
    1.59  exec 'from %s import *' % (network)
    1.60  #except:
    1.61  #    print "Can't find or interpret module %s with topology description" %(network)
    1.62  #    sys.exit(1)
    1.63  
    1.64 +process_domains_brief()
    1.65  
    1.66  N = str(domains.index(domain))
    1.67  name=domain
    1.68 @@ -73,6 +101,11 @@
    1.69  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' ]
    1.70  root = "/dev/hda1 ro"
    1.71  
    1.72 +if domain_subtypes[N] != '' and platform == '':
    1.73 +    platform=domain_subtypes[N]
    1.74 +
    1.75 +if platform = '': 
    1.76 +    platform='7200'
    1.77  platform_option=""
    1.78  if platform != '7200':
    1.79      platform_option=' -P '+platform