xen-drbd

view xen-drbd-start.py @ 32:189e42c31b69

hvm disk parameter fixed
author igor@manas.xt.vpn
date Mon Aug 18 11:48:34 2008 +0300 (2008-08-18)
parents 5e499179b5ed
children 44efea4507ac
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.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) )
42 else:
43 disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) )
44 else:
45 i=0
46 for disk_description in disk_table[domain]:
47 i+=1
48 if disk_description.find(":") == -1:
49 disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) )
50 else:
51 disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) )
53 vif=[]
54 vbridges = vbridges_table[domain]
55 x=1
56 for i in vbridges:
57 if domain_types[N] == 'hvm':
58 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
59 else:
60 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
61 x+=1
64 root="/dev/hda1 ro"
65 extra=""
67 def print_config():
68 if domain_types[N] == 'hvm':
69 print "name = \"%s\""% name
70 print "kernel = \"%s\""% kernel
71 print "builder = \"%s\""% builder
72 print "memory = %s"% memory
73 print "device_model=\"%s\"" % device_model
74 print "vcpus = %s"% vcpus
75 print "disk =", disk
76 print "vif =", vif
77 print "boot=\"%s\""%boot
78 print "sdl=%s"%sdl
79 print "vnc=%s"%vnc
80 print "vncconsole=%s"%vncconsole
81 print "stdvga=%s"%stdvga
82 print "serial=\"%s\""%serial
83 else:
84 print "name = \"%s\""% name
85 print "kernel = \"%s\""% kernel
86 print "ramdisk = \"%s\""% ramdisk
87 print "memory = %s"% memory
88 print "vcpus = %s"% vcpus
89 print "disk =", disk
90 print "vif =", vif
91 print "root = \"%s\""% root
92 print "extra = \"%s\""% extra
93 # else: