igor@0: #!/usr/bin/python igor@0: igor@0: igor@0: # External variables: igor@0: # * network igor@0: # * domain igor@0: igor@0: import sys igor@0: igor@38: #sys.path.append('/etc/xen') igor@38: igor@0: try: igor@38: execfile(network) igor@0: except: igor@0: print "Can't find or interpret module %s with topology description" %(network) igor@0: sys.exit(1) igor@0: igor@0: name=domain igor@0: N = domains.index(domain) igor@0: igor@31: if domain_types[N] == 'hvm': igor@31: kernel='hvmloader' igor@31: builder='hvm' igor@31: device_model='qemu-dm' igor@31: boot='c' igor@31: sdl=0 igor@31: vnc=1 igor@31: vncconsole=0 igor@31: stdvga=0 igor@31: serial='pty' igor@0: igor@38: try: igor@38: memory=mem_table[domain] igor@38: except: igor@38: pass igor@38: igor@38: try: igor@38: vcpus=vcpus_table[domain] igor@38: except: igor@38: pass igor@0: igor@0: disk=[] igor@32: if domain_types[N] == 'hvm': igor@32: letters='abcdefghijklmnopqrstuvwxyz' igor@32: i=0 igor@32: for disk_description in disk_table[domain]: igor@32: i+=1 igor@32: if disk_description.find(":") == -1: igor@36: disk_name=disk_description igor@36: if disk_name.find("=") == -1: igor@36: disk.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) ) igor@36: else: igor@36: disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) ) igor@32: else: igor@36: disk_name=(disk_description.split(':'))[0] igor@36: if disk_name.find("=") == -1: igor@36: disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) ) igor@36: else: igor@36: disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) ) igor@36: igor@32: else: igor@32: i=0 igor@32: for disk_description in disk_table[domain]: igor@32: i+=1 igor@32: if disk_description.find(":") == -1: igor@36: disk_name=disk_description igor@36: if disk_name.find("=") == -1: igor@36: disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) ) igor@36: else: igor@36: disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) ) igor@32: else: igor@36: disk_name=(disk_description.split(':'))[0] igor@36: if disk_name.find("=") == -1: igor@36: disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) ) igor@36: else: igor@36: disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) ) igor@0: igor@0: vif=[] igor@0: vbridges = vbridges_table[domain] igor@0: x=1 igor@0: for i in vbridges: igor@31: if domain_types[N] == 'hvm': igor@31: vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:]) igor@31: else: igor@31: vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:]) igor@31: x+=1 igor@31: igor@0: igor@0: root="/dev/hda1 ro" igor@0: extra="" igor@0: igor@0: def print_config(): igor@31: if domain_types[N] == 'hvm': igor@31: print "name = \"%s\""% name igor@31: print "kernel = \"%s\""% kernel igor@31: print "builder = \"%s\""% builder igor@31: print "memory = %s"% memory igor@31: print "device_model=\"%s\"" % device_model igor@31: print "vcpus = %s"% vcpus igor@31: print "disk =", disk igor@31: print "vif =", vif igor@31: print "boot=\"%s\""%boot igor@31: print "sdl=%s"%sdl igor@31: print "vnc=%s"%vnc igor@31: print "vncconsole=%s"%vncconsole igor@31: print "stdvga=%s"%stdvga igor@31: print "serial=\"%s\""%serial igor@31: else: igor@31: print "name = \"%s\""% name igor@31: print "kernel = \"%s\""% kernel igor@31: print "ramdisk = \"%s\""% ramdisk igor@31: print "memory = %s"% memory igor@31: print "vcpus = %s"% vcpus igor@31: print "disk =", disk igor@31: print "vif =", vif igor@31: print "root = \"%s\""% root igor@31: print "extra = \"%s\""% extra igor@31: # else: igor@0: