rev |
line source |
igor@0
|
1 #!/usr/bin/python
|
igor@0
|
2
|
igor@0
|
3
|
igor@0
|
4 # External variables:
|
igor@0
|
5 # * network
|
igor@0
|
6 # * domain
|
igor@0
|
7
|
igor@0
|
8 import sys
|
igor@0
|
9
|
eb@5
|
10 sys.path.append('/etc/xen')
|
igor@0
|
11 try:
|
igor@0
|
12 exec 'from %s import *' % (network)
|
igor@0
|
13 except:
|
igor@0
|
14 print "Can't find or interpret module %s with topology description" %(network)
|
igor@0
|
15 sys.exit(1)
|
igor@0
|
16
|
igor@0
|
17 name=domain
|
igor@0
|
18 N = domains.index(domain)
|
igor@0
|
19
|
igor@31
|
20 if domain_types[N] == 'hvm':
|
igor@31
|
21 kernel='hvmloader'
|
igor@31
|
22 builder='hvm'
|
igor@31
|
23 device_model='qemu-dm'
|
igor@31
|
24 boot='c'
|
igor@31
|
25 sdl=0
|
igor@31
|
26 vnc=1
|
igor@31
|
27 vncconsole=0
|
igor@31
|
28 stdvga=0
|
igor@31
|
29 serial='pty'
|
igor@0
|
30
|
igor@0
|
31 memory=mem_table[domain]
|
igor@4
|
32 vcpus=vcpus_table[domain]
|
igor@0
|
33
|
igor@0
|
34 disk=[]
|
igor@0
|
35 i=0
|
igor@0
|
36 for disk_description in disk_table[domain]:
|
igor@0
|
37 i+=1
|
igor@0
|
38 if disk_description.find(":") == -1:
|
igor@0
|
39 disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) )
|
igor@0
|
40 else:
|
igor@4
|
41 disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) )
|
igor@0
|
42
|
igor@0
|
43 vif=[]
|
igor@0
|
44 vbridges = vbridges_table[domain]
|
igor@0
|
45 x=1
|
igor@0
|
46 for i in vbridges:
|
igor@31
|
47 if domain_types[N] == 'hvm':
|
igor@31
|
48 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
|
igor@31
|
49 else:
|
igor@31
|
50 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
|
igor@31
|
51 x+=1
|
igor@31
|
52
|
igor@0
|
53
|
igor@0
|
54 root="/dev/hda1 ro"
|
igor@0
|
55 extra=""
|
igor@0
|
56
|
igor@0
|
57 def print_config():
|
igor@31
|
58 if domain_types[N] == 'hvm':
|
igor@31
|
59 print "name = \"%s\""% name
|
igor@31
|
60 print "kernel = \"%s\""% kernel
|
igor@31
|
61 print "builder = \"%s\""% builder
|
igor@31
|
62 print "memory = %s"% memory
|
igor@31
|
63 print "device_model=\"%s\"" % device_model
|
igor@31
|
64 print "vcpus = %s"% vcpus
|
igor@31
|
65 print "disk =", disk
|
igor@31
|
66 print "vif =", vif
|
igor@31
|
67 print "boot=\"%s\""%boot
|
igor@31
|
68 print "sdl=%s"%sdl
|
igor@31
|
69 print "vnc=%s"%vnc
|
igor@31
|
70 print "vncconsole=%s"%vncconsole
|
igor@31
|
71 print "stdvga=%s"%stdvga
|
igor@31
|
72 print "serial=\"%s\""%serial
|
igor@31
|
73 else:
|
igor@31
|
74 print "name = \"%s\""% name
|
igor@31
|
75 print "kernel = \"%s\""% kernel
|
igor@31
|
76 print "ramdisk = \"%s\""% ramdisk
|
igor@31
|
77 print "memory = %s"% memory
|
igor@31
|
78 print "vcpus = %s"% vcpus
|
igor@31
|
79 print "disk =", disk
|
igor@31
|
80 print "vif =", vif
|
igor@31
|
81 print "root = \"%s\""% root
|
igor@31
|
82 print "extra = \"%s\""% extra
|
igor@31
|
83 # else:
|
igor@0
|
84
|