xen-drbd

annotate xen-drbd-start.py @ 35:cbd4d942d059

.py eliminated in script calling
author igor@manas.xt.vpn
date Mon Aug 18 21:27:14 2008 +0300 (2008-08-18)
parents 5e499179b5ed
children 44efea4507ac
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
eb@5 10 sys.path.append('/etc/xen')
igor@0 11 try:
igor@0 12 exec 'from %s import *' % (network)
igor@0 13 except:
igor@0 14 print "Can't find or interpret module %s with topology description" %(network)
igor@0 15 sys.exit(1)
igor@0 16
igor@0 17 name=domain
igor@0 18 N = domains.index(domain)
igor@0 19
igor@31 20 if domain_types[N] == 'hvm':
igor@31 21 kernel='hvmloader'
igor@31 22 builder='hvm'
igor@31 23 device_model='qemu-dm'
igor@31 24 boot='c'
igor@31 25 sdl=0
igor@31 26 vnc=1
igor@31 27 vncconsole=0
igor@31 28 stdvga=0
igor@31 29 serial='pty'
igor@0 30
igor@0 31 memory=mem_table[domain]
igor@4 32 vcpus=vcpus_table[domain]
igor@0 33
igor@0 34 disk=[]
igor@32 35 if domain_types[N] == 'hvm':
igor@32 36 letters='abcdefghijklmnopqrstuvwxyz'
igor@32 37 i=0
igor@32 38 for disk_description in disk_table[domain]:
igor@32 39 i+=1
igor@32 40 if disk_description.find(":") == -1:
igor@32 41 disk.append('phy:/dev/drbd/%s,hd%s,w' % (domain,letters[i-1]) )
igor@32 42 else:
igor@32 43 disk.append('phy:/dev/drbd/%s,hd%s,w' % ((disk_description.split(':'))[1],letters[i-1]) )
igor@32 44 else:
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@32 49 disk.append('phy:/dev/drbd/%s,hda%s,w' % (domain,i) )
igor@32 50 else:
igor@32 51 disk.append('phy:/dev/drbd/%s,hda%s,w' % ((disk_description.split(':'))[1],i) )
igor@0 52
igor@0 53 vif=[]
igor@0 54 vbridges = vbridges_table[domain]
igor@0 55 x=1
igor@0 56 for i in vbridges:
igor@31 57 if domain_types[N] == 'hvm':
igor@31 58 vif.append('type=ioemu, bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
igor@31 59 else:
igor@31 60 vif.append('bridge='+i+',mac=00:16:3e:01:'+hex(int(N))[2:]+':'+hex(int('c0',16)+x)[2:])
igor@31 61 x+=1
igor@31 62
igor@0 63
igor@0 64 root="/dev/hda1 ro"
igor@0 65 extra=""
igor@0 66
igor@0 67 def print_config():
igor@31 68 if domain_types[N] == 'hvm':
igor@31 69 print "name = \"%s\""% name
igor@31 70 print "kernel = \"%s\""% kernel
igor@31 71 print "builder = \"%s\""% builder
igor@31 72 print "memory = %s"% memory
igor@31 73 print "device_model=\"%s\"" % device_model
igor@31 74 print "vcpus = %s"% vcpus
igor@31 75 print "disk =", disk
igor@31 76 print "vif =", vif
igor@31 77 print "boot=\"%s\""%boot
igor@31 78 print "sdl=%s"%sdl
igor@31 79 print "vnc=%s"%vnc
igor@31 80 print "vncconsole=%s"%vncconsole
igor@31 81 print "stdvga=%s"%stdvga
igor@31 82 print "serial=\"%s\""%serial
igor@31 83 else:
igor@31 84 print "name = \"%s\""% name
igor@31 85 print "kernel = \"%s\""% kernel
igor@31 86 print "ramdisk = \"%s\""% ramdisk
igor@31 87 print "memory = %s"% memory
igor@31 88 print "vcpus = %s"% vcpus
igor@31 89 print "disk =", disk
igor@31 90 print "vif =", vif
igor@31 91 print "root = \"%s\""% root
igor@31 92 print "extra = \"%s\""% extra
igor@31 93 # else:
igor@0 94