xen-drbd
view xen-drbd-start.py @ 43:562d6e064e6f
Install packages into domains (apt_get_install_table)
author | igor@manas.xt.vpn |
---|---|
date | Tue Sep 23 11:40:23 2008 +0300 (2008-09-23) |
parents | 26d7bae7dcde |
children | a91c91c166c4 |
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'
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 try:
111 print "kernel = \"%s\""% kernel
112 except:
113 pass
114 try:
115 print "ramdisk = \"%s\""% ramdisk
116 except:
117 pass
118 print "memory = %s"% memory
119 print "vcpus = %s"% vcpus
120 print "disk =", disk
121 print "vif =", vif
122 print "root = \"%s\""% root
123 print "extra = \"%s\""% extra
124 try:
125 print "bootloader = \"%s\""% bootloader
126 except:
127 pass
129 # else: