xen-drbd

view xen-drbd-start.py @ 36:44efea4507ac

Virtual disk name can be secified after = sign (e.g.: drbd1=sda1:dns:2G )
author igor@manas.xt.vpn
date Sat Aug 30 11:14:50 2008 +0300 (2008-08-30)
parents 189e42c31b69
children 30671fe7fd79
line source
1 #!/usr/bin/python
4 # External variables:
5 # * network
6 # * domain
8 import sys
10 sys.path.append('/etc/xen')
11 try:
12 exec 'from %s import *' % (network)
13 except:
14 print "Can't find or interpret module %s with topology description" %(network)
15 sys.exit(1)
17 name=domain
18 N = domains.index(domain)
20 if domain_types[N] == 'hvm':
21 kernel='hvmloader'
22 builder='hvm'
23 device_model='qemu-dm'
24 boot='c'
25 sdl=0
26 vnc=1
27 vncconsole=0
28 stdvga=0
29 serial='pty'
31 memory=mem_table[domain]
32 vcpus=vcpus_table[domain]
34 disk=[]
35 if domain_types[N] == 'hvm':
36 letters='abcdefghijklmnopqrstuvwxyz'
37 i=0
38 for disk_description in disk_table[domain]:
39 i+=1
40 if disk_description.find(":") == -1:
41 disk_name=disk_description
42 if disk_name.find("=") == -1:
43 disk.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) )
44 else:
45 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
46 else:
47 disk_name=(disk_description.split(':'))[0]
48 if disk_name.find("=") == -1:
49 disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) )
50 else:
51 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
53 else:
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,hda%s,w' % (domain,i) )
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,hda%s,w' % ((disk_description.split(':'))[1],i) )
67 else:
68 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
70 vif=[]
71 vbridges = vbridges_table[domain]
72 x=1
73 for i in vbridges:
74 if domain_types[N] == 'hvm':
75 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
76 else:
77 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
78 x+=1
81 root="/dev/hda1 ro"
82 extra=""
84 def print_config():
85 if domain_types[N] == 'hvm':
86 print "name = \"%s\""% name
87 print "kernel = \"%s\""% kernel
88 print "builder = \"%s\""% builder
89 print "memory = %s"% memory
90 print "device_model=\"%s\"" % device_model
91 print "vcpus = %s"% vcpus
92 print "disk =", disk
93 print "vif =", vif
94 print "boot=\"%s\""%boot
95 print "sdl=%s"%sdl
96 print "vnc=%s"%vnc
97 print "vncconsole=%s"%vncconsole
98 print "stdvga=%s"%stdvga
99 print "serial=\"%s\""%serial
100 else:
101 print "name = \"%s\""% name
102 print "kernel = \"%s\""% kernel
103 print "ramdisk = \"%s\""% ramdisk
104 print "memory = %s"% memory
105 print "vcpus = %s"% vcpus
106 print "disk =", disk
107 print "vif =", vif
108 print "root = \"%s\""% root
109 print "extra = \"%s\""% extra
110 # else: