xen-drbd
view xen-drbd-start.py @ 60:dd23766a87c6
Minor fixes. Hvmlaoder now can be specified by its path in the netowrk config file.
Also slightly changed drbdadm call
Also slightly changed drbdadm call
author | igor@book.xt.vpn |
---|---|
date | Thu Mar 19 19:42:41 2009 +0200 (2009-03-19) |
parents | 1f60cf97bcd9 |
children | e005bb283f54 |
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 try:
42 hvmloader
43 except:
44 hvmloader='hvmloader'
46 if domain_types[N] == 'hvm':
47 kernel=hvmloader
48 builder='hvm'
50 try:
51 memory=mem_table[domain]
52 except:
53 pass
55 try:
56 vcpus=vcpus_table[domain]
57 except:
58 pass
60 disk=[]
61 if domain_types[N] == 'hvm':
62 letters='abcdefghijklmnopqrstuvwxyz'
63 i=0
64 for disk_description in disk_table[domain]:
65 i+=1
66 if disk_description.find(":") == -1:
67 disk_name=disk_description
68 if disk_name.find("=") == -1:
69 disk.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) )
70 else:
71 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
72 else:
73 disk_name=(disk_description.split(':'))[0]
74 if disk_name.find("=") == -1:
75 disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) )
76 else:
77 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
79 else:
80 i=0
81 for disk_description in disk_table[domain]:
82 i+=1
83 if disk_description.find(":") == -1:
84 disk_name=disk_description
85 if disk_name.find("=") == -1:
86 disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) )
87 else:
88 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
89 else:
90 disk_name=(disk_description.split(':'))[0]
91 if disk_name.find("=") == -1:
92 disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) )
93 else:
94 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
96 vif=[]
97 vbridges = vbridges_table[domain]
98 x=1
99 for i in vbridges:
100 if domain_types[N] == 'hvm':
101 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
102 else:
103 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
104 x+=1
108 def print_config():
109 if domain_types[N] == 'hvm':
110 print "name = \"%s\""% name
111 print "kernel = \"%s\""% kernel
112 print "builder = \"%s\""% builder
113 print "memory = %s"% memory
114 print "device_model=\"%s\"" % device_model
115 print "vcpus = %s"% vcpus
116 print "disk =", disk
117 print "vif =", vif
118 print "boot=\"%s\""%boot
119 print "sdl=%s"%sdl
120 print "vnc=%s"%vnc
121 print "localtime=%s"%localtime
122 print "stdvga=%s"%stdvga
123 print "serial=\"%s\""%serial
124 else:
125 print "name = \"%s\""% name
126 try:
127 print "kernel = \"%s\""% kernel
128 except:
129 pass
130 try:
131 print "ramdisk = \"%s\""% ramdisk
132 except:
133 pass
134 print "memory = %s"% memory
135 print "vcpus = %s"% vcpus
136 print "disk =", disk
137 print "vif =", vif
138 print "root = \"%s\""% root
139 print "extra = \"%s\""% extra
140 try:
141 print "bootloader = \"%s\""% bootloader
142 except:
143 pass
145 # else: