xen-drbd

view xen-drbd-start.py @ 38:30671fe7fd79

Now you can use 'domain' variable inside netowrk topology file
author igor@manas.xt.vpn
date Thu Sep 18 11:42:52 2008 +0300 (2008-09-18)
parents 44efea4507ac
children 26d7bae7dcde
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(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'
32 try:
33 memory=mem_table[domain]
34 except:
35 pass
37 try:
38 vcpus=vcpus_table[domain]
39 except:
40 pass
42 disk=[]
43 if domain_types[N] == 'hvm':
44 letters='abcdefghijklmnopqrstuvwxyz'
45 i=0
46 for disk_description in disk_table[domain]:
47 i+=1
48 if disk_description.find(":") == -1:
49 disk_name=disk_description
50 if disk_name.find("=") == -1:
51 disk.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) )
52 else:
53 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
54 else:
55 disk_name=(disk_description.split(':'))[0]
56 if disk_name.find("=") == -1:
57 disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) )
58 else:
59 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
61 else:
62 i=0
63 for disk_description in disk_table[domain]:
64 i+=1
65 if disk_description.find(":") == -1:
66 disk_name=disk_description
67 if disk_name.find("=") == -1:
68 disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) )
69 else:
70 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
71 else:
72 disk_name=(disk_description.split(':'))[0]
73 if disk_name.find("=") == -1:
74 disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) )
75 else:
76 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
78 vif=[]
79 vbridges = vbridges_table[domain]
80 x=1
81 for i in vbridges:
82 if domain_types[N] == 'hvm':
83 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
84 else:
85 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
86 x+=1
89 root="/dev/hda1 ro"
90 extra=""
92 def print_config():
93 if domain_types[N] == 'hvm':
94 print "name = \"%s\""% name
95 print "kernel = \"%s\""% kernel
96 print "builder = \"%s\""% builder
97 print "memory = %s"% memory
98 print "device_model=\"%s\"" % device_model
99 print "vcpus = %s"% vcpus
100 print "disk =", disk
101 print "vif =", vif
102 print "boot=\"%s\""%boot
103 print "sdl=%s"%sdl
104 print "vnc=%s"%vnc
105 print "vncconsole=%s"%vncconsole
106 print "stdvga=%s"%stdvga
107 print "serial=\"%s\""%serial
108 else:
109 print "name = \"%s\""% name
110 print "kernel = \"%s\""% kernel
111 print "ramdisk = \"%s\""% ramdisk
112 print "memory = %s"% memory
113 print "vcpus = %s"% vcpus
114 print "disk =", disk
115 print "vif =", vif
116 print "root = \"%s\""% root
117 print "extra = \"%s\""% extra
118 # else: