xen-drbd
view xen-drbd-start.py @ 45:a91c91c166c4
double xen-drbd pass
author | igor@manas.xt.vpn |
---|---|
date | Thu Sep 25 22:05:19 2008 +0300 (2008-09-25) |
parents | a2e536ffabf7 |
children | 6964fb4421a5 |
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 vncconsole=0
29 stdvga=0
30 serial='pty'
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 memory=mem_table[domain]
43 except:
44 pass
46 try:
47 vcpus=vcpus_table[domain]
48 except:
49 pass
51 disk=[]
52 if domain_types[N] == 'hvm':
53 letters='abcdefghijklmnopqrstuvwxyz'
54 i=0
55 for disk_description in disk_table[domain]:
56 i+=1
57 if disk_description.find(":") == -1:
58 disk_name=disk_description
59 if disk_name.find("=") == -1:
60 disk.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) )
61 else:
62 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
63 else:
64 disk_name=(disk_description.split(':'))[0]
65 if disk_name.find("=") == -1:
66 disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) )
67 else:
68 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
70 else:
71 i=0
72 for disk_description in disk_table[domain]:
73 i+=1
74 if disk_description.find(":") == -1:
75 disk_name=disk_description
76 if disk_name.find("=") == -1:
77 disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) )
78 else:
79 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
80 else:
81 disk_name=(disk_description.split(':'))[0]
82 if disk_name.find("=") == -1:
83 disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) )
84 else:
85 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
87 vif=[]
88 vbridges = vbridges_table[domain]
89 x=1
90 for i in vbridges:
91 if domain_types[N] == 'hvm':
92 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
93 else:
94 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
95 x+=1
99 def print_config():
100 if domain_types[N] == 'hvm':
101 print "name = \"%s\""% name
102 print "kernel = \"%s\""% kernel
103 print "builder = \"%s\""% builder
104 print "memory = %s"% memory
105 print "device_model=\"%s\"" % device_model
106 print "vcpus = %s"% vcpus
107 print "disk =", disk
108 print "vif =", vif
109 print "boot=\"%s\""%boot
110 print "sdl=%s"%sdl
111 print "vnc=%s"%vnc
112 print "vncconsole=%s"%vncconsole
113 print "stdvga=%s"%stdvga
114 print "serial=\"%s\""%serial
115 else:
116 print "name = \"%s\""% name
117 try:
118 print "kernel = \"%s\""% kernel
119 except:
120 pass
121 try:
122 print "ramdisk = \"%s\""% ramdisk
123 except:
124 pass
125 print "memory = %s"% memory
126 print "vcpus = %s"% vcpus
127 print "disk =", disk
128 print "vif =", vif
129 print "root = \"%s\""% root
130 print "extra = \"%s\""% extra
131 try:
132 print "bootloader = \"%s\""% bootloader
133 except:
134 pass
136 # else: