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