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@32
|
35 if domain_types[N] == 'hvm':
|
igor@32
|
36 letters='abcdefghijklmnopqrstuvwxyz'
|
igor@32
|
37 i=0
|
igor@32
|
38 for disk_description in disk_table[domain]:
|
igor@32
|
39 i+=1
|
igor@32
|
40 if disk_description.find(":") == -1:
|
igor@36
|
41 disk_name=disk_description
|
igor@36
|
42 if disk_name.find("=") == -1:
|
igor@36
|
43 disk.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) )
|
igor@36
|
44 else:
|
igor@36
|
45 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
|
igor@32
|
46 else:
|
igor@36
|
47 disk_name=(disk_description.split(':'))[0]
|
igor@36
|
48 if disk_name.find("=") == -1:
|
igor@36
|
49 disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) )
|
igor@36
|
50 else:
|
igor@36
|
51 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
|
igor@36
|
52
|
igor@32
|
53 else:
|
igor@32
|
54 i=0
|
igor@32
|
55 for disk_description in disk_table[domain]:
|
igor@32
|
56 i+=1
|
igor@32
|
57 if disk_description.find(":") == -1:
|
igor@36
|
58 disk_name=disk_description
|
igor@36
|
59 if disk_name.find("=") == -1:
|
igor@36
|
60 disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) )
|
igor@36
|
61 else:
|
igor@36
|
62 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
|
igor@32
|
63 else:
|
igor@36
|
64 disk_name=(disk_description.split(':'))[0]
|
igor@36
|
65 if disk_name.find("=") == -1:
|
igor@36
|
66 disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) )
|
igor@36
|
67 else:
|
igor@36
|
68 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
|
igor@0
|
69
|
igor@0
|
70 vif=[]
|
igor@0
|
71 vbridges = vbridges_table[domain]
|
igor@0
|
72 x=1
|
igor@0
|
73 for i in vbridges:
|
igor@31
|
74 if domain_types[N] == 'hvm':
|
igor@31
|
75 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
|
igor@31
|
76 else:
|
igor@31
|
77 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
|
igor@31
|
78 x+=1
|
igor@31
|
79
|
igor@0
|
80
|
igor@0
|
81 root="/dev/hda1 ro"
|
igor@0
|
82 extra=""
|
igor@0
|
83
|
igor@0
|
84 def print_config():
|
igor@31
|
85 if domain_types[N] == 'hvm':
|
igor@31
|
86 print "name = \"%s\""% name
|
igor@31
|
87 print "kernel = \"%s\""% kernel
|
igor@31
|
88 print "builder = \"%s\""% builder
|
igor@31
|
89 print "memory = %s"% memory
|
igor@31
|
90 print "device_model=\"%s\"" % device_model
|
igor@31
|
91 print "vcpus = %s"% vcpus
|
igor@31
|
92 print "disk =", disk
|
igor@31
|
93 print "vif =", vif
|
igor@31
|
94 print "boot=\"%s\""%boot
|
igor@31
|
95 print "sdl=%s"%sdl
|
igor@31
|
96 print "vnc=%s"%vnc
|
igor@31
|
97 print "vncconsole=%s"%vncconsole
|
igor@31
|
98 print "stdvga=%s"%stdvga
|
igor@31
|
99 print "serial=\"%s\""%serial
|
igor@31
|
100 else:
|
igor@31
|
101 print "name = \"%s\""% name
|
igor@31
|
102 print "kernel = \"%s\""% kernel
|
igor@31
|
103 print "ramdisk = \"%s\""% ramdisk
|
igor@31
|
104 print "memory = %s"% memory
|
igor@31
|
105 print "vcpus = %s"% vcpus
|
igor@31
|
106 print "disk =", disk
|
igor@31
|
107 print "vif =", vif
|
igor@31
|
108 print "root = \"%s\""% root
|
igor@31
|
109 print "extra = \"%s\""% extra
|
igor@31
|
110 # else:
|
igor@0
|
111
|