xen-drbd

annotate xen-drbd-start.py @ 47:1f60cf97bcd9

minifix
author igor@manas.xt.vpn
date Mon Sep 29 16:21:33 2008 +0300 (2008-09-29)
parents 6964fb4421a5
children dd23766a87c6
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 stdvga=0
igor@31 29 serial='pty'
igor@47 30 localtime=0
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@46 41 if domain_types[N] == 'hvm':
igor@46 42 kernel='hvmloader'
igor@46 43 builder='hvm'
igor@46 44
igor@38 45 try:
igor@38 46 memory=mem_table[domain]
igor@38 47 except:
igor@38 48 pass
igor@38 49
igor@38 50 try:
igor@38 51 vcpus=vcpus_table[domain]
igor@38 52 except:
igor@38 53 pass
igor@0 54
igor@0 55 disk=[]
igor@32 56 if domain_types[N] == 'hvm':
igor@32 57 letters='abcdefghijklmnopqrstuvwxyz'
igor@32 58 i=0
igor@32 59 for disk_description in disk_table[domain]:
igor@32 60 i+=1
igor@32 61 if disk_description.find(":") == -1:
igor@36 62 disk_name=disk_description
igor@36 63 if disk_name.find("=") == -1:
igor@36 64 disk.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) )
igor@36 65 else:
igor@36 66 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
igor@32 67 else:
igor@36 68 disk_name=(disk_description.split(':'))[0]
igor@36 69 if disk_name.find("=") == -1:
igor@36 70 disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) )
igor@36 71 else:
igor@36 72 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
igor@36 73
igor@32 74 else:
igor@32 75 i=0
igor@32 76 for disk_description in disk_table[domain]:
igor@32 77 i+=1
igor@32 78 if disk_description.find(":") == -1:
igor@36 79 disk_name=disk_description
igor@36 80 if disk_name.find("=") == -1:
igor@36 81 disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) )
igor@36 82 else:
igor@36 83 disk.append('phy:/dev/drbd/%s,%s,w' % (domain,(disk_name.split("="))[1]) )
igor@32 84 else:
igor@36 85 disk_name=(disk_description.split(':'))[0]
igor@36 86 if disk_name.find("=") == -1:
igor@36 87 disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) )
igor@36 88 else:
igor@36 89 disk.append('phy:/dev/drbd/%s,%s,w' % ((disk_description.split(':'))[1],(disk_name.split("="))[1]) )
igor@0 90
igor@0 91 vif=[]
igor@0 92 vbridges = vbridges_table[domain]
igor@0 93 x=1
igor@0 94 for i in vbridges:
igor@31 95 if domain_types[N] == 'hvm':
igor@31 96 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
igor@31 97 else:
igor@31 98 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
igor@31 99 x+=1
igor@31 100
igor@0 101
igor@0 102
igor@0 103 def print_config():
igor@31 104 if domain_types[N] == 'hvm':
igor@31 105 print "name = \"%s\""% name
igor@31 106 print "kernel = \"%s\""% kernel
igor@31 107 print "builder = \"%s\""% builder
igor@31 108 print "memory = %s"% memory
igor@31 109 print "device_model=\"%s\"" % device_model
igor@31 110 print "vcpus = %s"% vcpus
igor@31 111 print "disk =", disk
igor@31 112 print "vif =", vif
igor@31 113 print "boot=\"%s\""%boot
igor@31 114 print "sdl=%s"%sdl
igor@31 115 print "vnc=%s"%vnc
igor@47 116 print "localtime=%s"%localtime
igor@31 117 print "stdvga=%s"%stdvga
igor@31 118 print "serial=\"%s\""%serial
igor@31 119 else:
igor@31 120 print "name = \"%s\""% name
igor@41 121 try:
igor@41 122 print "kernel = \"%s\""% kernel
igor@41 123 except:
igor@41 124 pass
igor@41 125 try:
igor@41 126 print "ramdisk = \"%s\""% ramdisk
igor@41 127 except:
igor@41 128 pass
igor@31 129 print "memory = %s"% memory
igor@31 130 print "vcpus = %s"% vcpus
igor@31 131 print "disk =", disk
igor@31 132 print "vif =", vif
igor@31 133 print "root = \"%s\""% root
igor@31 134 print "extra = \"%s\""% extra
igor@41 135 try:
igor@41 136 print "bootloader = \"%s\""% bootloader
igor@41 137 except:
igor@41 138 pass
igor@41 139
igor@31 140 # else:
igor@0 141