xen-drbd

annotate 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
rev   line source
igor@0 1 #!/usr/bin/python
igor@0 2
igor@0 3
igor@0 4 # External variables:
igor@0 5 # * network
igor@0 6 # * domain
igor@0 7
igor@0 8 import sys
igor@0 9
igor@38 10 #sys.path.append('/etc/xen')
igor@38 11
igor@0 12 try:
igor@40 13 execfile('/etc/xen/'+network)
igor@0 14 except:
igor@0 15 print "Can't find or interpret module %s with topology description" %(network)
igor@0 16 sys.exit(1)
igor@0 17
igor@0 18 name=domain
igor@0 19 N = domains.index(domain)
igor@0 20
igor@31 21 if domain_types[N] == 'hvm':
igor@31 22 kernel='hvmloader'
igor@31 23 builder='hvm'
igor@31 24 device_model='qemu-dm'
igor@31 25 boot='c'
igor@31 26 sdl=0
igor@31 27 vnc=1
igor@31 28 vncconsole=0
igor@31 29 stdvga=0
igor@31 30 serial='pty'
igor@45 31 else:
igor@45 32 root="/dev/hda1 ro"
igor@45 33 extra=""
igor@45 34
igor@45 35 try:
igor@45 36 execfile('/etc/xen/'+network)
igor@45 37 except:
igor@45 38 print "Can't find or interpret module %s with topology description" %(network)
igor@45 39 sys.exit(1)
igor@0 40
igor@38 41 try:
igor@38 42 memory=mem_table[domain]
igor@38 43 except:
igor@38 44 pass
igor@38 45
igor@38 46 try:
igor@38 47 vcpus=vcpus_table[domain]
igor@38 48 except:
igor@38 49 pass
igor@0 50
igor@0 51 disk=[]
igor@32 52 if domain_types[N] == 'hvm':
igor@32 53 letters='abcdefghijklmnopqrstuvwxyz'
igor@32 54 i=0
igor@32 55 for disk_description in disk_table[domain]:
igor@32 56 i+=1
igor@32 57 if disk_description.find(":") == -1:
igor@36 58 disk_name=disk_description
igor@36 59 if disk_name.find("=") == -1:
igor@36 60 disk.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) )
igor@36 61 else:
igor@36 62 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
igor@32 63 else:
igor@36 64 disk_name=(disk_description.split(':'))[0]
igor@36 65 if disk_name.find("=") == -1:
igor@36 66 disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) )
igor@36 67 else:
igor@36 68 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
igor@36 69
igor@32 70 else:
igor@32 71 i=0
igor@32 72 for disk_description in disk_table[domain]:
igor@32 73 i+=1
igor@32 74 if disk_description.find(":") == -1:
igor@36 75 disk_name=disk_description
igor@36 76 if disk_name.find("=") == -1:
igor@36 77 disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) )
igor@36 78 else:
igor@36 79 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
igor@32 80 else:
igor@36 81 disk_name=(disk_description.split(':'))[0]
igor@36 82 if disk_name.find("=") == -1:
igor@36 83 disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) )
igor@36 84 else:
igor@36 85 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
igor@0 86
igor@0 87 vif=[]
igor@0 88 vbridges = vbridges_table[domain]
igor@0 89 x=1
igor@0 90 for i in vbridges:
igor@31 91 if domain_types[N] == 'hvm':
igor@31 92 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
igor@31 93 else:
igor@31 94 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
igor@31 95 x+=1
igor@31 96
igor@0 97
igor@0 98
igor@0 99 def print_config():
igor@31 100 if domain_types[N] == 'hvm':
igor@31 101 print "name = \"%s\""% name
igor@31 102 print "kernel = \"%s\""% kernel
igor@31 103 print "builder = \"%s\""% builder
igor@31 104 print "memory = %s"% memory
igor@31 105 print "device_model=\"%s\"" % device_model
igor@31 106 print "vcpus = %s"% vcpus
igor@31 107 print "disk =", disk
igor@31 108 print "vif =", vif
igor@31 109 print "boot=\"%s\""%boot
igor@31 110 print "sdl=%s"%sdl
igor@31 111 print "vnc=%s"%vnc
igor@31 112 print "vncconsole=%s"%vncconsole
igor@31 113 print "stdvga=%s"%stdvga
igor@31 114 print "serial=\"%s\""%serial
igor@31 115 else:
igor@31 116 print "name = \"%s\""% name
igor@41 117 try:
igor@41 118 print "kernel = \"%s\""% kernel
igor@41 119 except:
igor@41 120 pass
igor@41 121 try:
igor@41 122 print "ramdisk = \"%s\""% ramdisk
igor@41 123 except:
igor@41 124 pass
igor@31 125 print "memory = %s"% memory
igor@31 126 print "vcpus = %s"% vcpus
igor@31 127 print "disk =", disk
igor@31 128 print "vif =", vif
igor@31 129 print "root = \"%s\""% root
igor@31 130 print "extra = \"%s\""% extra
igor@41 131 try:
igor@41 132 print "bootloader = \"%s\""% bootloader
igor@41 133 except:
igor@41 134 pass
igor@41 135
igor@31 136 # else:
igor@0 137