xen-drbd

view xen-drbd-start.py @ 53:748e00890579

transition to xen 3.2.1
author root@linux10
date Fri Oct 10 20:35:46 2008 +0000 (2008-10-10)
parents 6964fb4421a5
children dd23766a87c6
line source
1 #!/usr/bin/python
4 # External variables:
5 # * network
6 # * domain
8 import sys
10 #sys.path.append('/etc/xen')
12 try:
13 execfile('/etc/xen/'+network)
14 except:
15 print "Can't find or interpret module %s with topology description" %(network)
16 sys.exit(1)
18 name=domain
19 N = domains.index(domain)
21 if domain_types[N] == 'hvm':
22 kernel='hvmloader'
23 builder='hvm'
24 device_model='qemu-dm'
25 boot='c'
26 sdl=0
27 vnc=1
28 stdvga=0
29 serial='pty'
30 localtime=0
31 else:
32 root="/dev/hda1 ro"
33 extra=""
35 try:
36 execfile('/etc/xen/'+network)
37 except:
38 print "Can't find or interpret module %s with topology description" %(network)
39 sys.exit(1)
41 if domain_types[N] == 'hvm':
42 kernel='hvmloader'
43 builder='hvm'
45 try:
46 memory=mem_table[domain]
47 except:
48 pass
50 try:
51 vcpus=vcpus_table[domain]
52 except:
53 pass
55 disk=[]
56 if domain_types[N] == 'hvm':
57 letters='abcdefghijklmnopqrstuvwxyz'
58 i=0
59 for disk_description in disk_table[domain]:
60 i+=1
61 if disk_description.find(":") == -1:
62 disk_name=disk_description
63 if disk_name.find("=") == -1:
64 disk.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) )
65 else:
66 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
67 else:
68 disk_name=(disk_description.split(':'))[0]
69 if disk_name.find("=") == -1:
70 disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) )
71 else:
72 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
74 else:
75 i=0
76 for disk_description in disk_table[domain]:
77 i+=1
78 if disk_description.find(":") == -1:
79 disk_name=disk_description
80 if disk_name.find("=") == -1:
81 disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) )
82 else:
83 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
84 else:
85 disk_name=(disk_description.split(':'))[0]
86 if disk_name.find("=") == -1:
87 disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) )
88 else:
89 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
91 vif=[]
92 vbridges = vbridges_table[domain]
93 x=1
94 for i in vbridges:
95 if domain_types[N] == 'hvm':
96 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
97 else:
98 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
99 x+=1
103 def print_config():
104 if domain_types[N] == 'hvm':
105 print "name = \"%s\""% name
106 print "kernel = \"%s\""% kernel
107 print "builder = \"%s\""% builder
108 print "memory = %s"% memory
109 print "device_model=\"%s\"" % device_model
110 print "vcpus = %s"% vcpus
111 print "disk =", disk
112 print "vif =", vif
113 print "boot=\"%s\""%boot
114 print "sdl=%s"%sdl
115 print "vnc=%s"%vnc
116 print "localtime=%s"%localtime
117 print "stdvga=%s"%stdvga
118 print "serial=\"%s\""%serial
119 else:
120 print "name = \"%s\""% name
121 try:
122 print "kernel = \"%s\""% kernel
123 except:
124 pass
125 try:
126 print "ramdisk = \"%s\""% ramdisk
127 except:
128 pass
129 print "memory = %s"% memory
130 print "vcpus = %s"% vcpus
131 print "disk =", disk
132 print "vif =", vif
133 print "root = \"%s\""% root
134 print "extra = \"%s\""% extra
135 try:
136 print "bootloader = \"%s\""% bootloader
137 except:
138 pass
140 # else: