xen-drbd

annotate xen-drbd-start.py @ 41:a2e536ffabf7

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