2
##### Edit this python file to reflect the configuration of your system
4
##### This example script requires variable 'ip' to be set, and optionally
5
##### netmask and gatewaty for the kernel command line
8
print >>sys.stderr, """
9
The config file %s requires the following vars to be defined:
10
ip -- List of IP addr(s) for Xen to route to domain
11
e.g. '-Dip=1.2.3.4,5.6.7.8'
12
The following variables may be optionally defined:
13
mem -- Adjust initial memory allocation (default 64MB)
14
netmask -- Override gateway for kernel ip= command line
15
gateway -- Override network for kernel ip= command line
21
print "Set variable 'ip' using '-Dip=1.2.3.4,5.6.7.8'"
24
# STEP 1. Specify kernel image file and otional ramdisk. Can be gzip'ed.
25
image = "/boot/xenolinux.gz"
26
ramdisk = "/boot/initrd.gz"
27
builder_fn='linux' # this is a linux domain
29
# STEP 2. The initial memory allocation (in megabytes) for the new domain.
36
# STEP 3. A handy name for your new domain.
37
# appends either first hostname or last quad of first IP address dependant on value passed
39
quads = string.split(ip, '.')
40
if len(quads) == 4: # fragile heuristic for valid IP verification
41
domain_name = "Xen VM .%s" % quads[3] # use last quad of IP
43
domain_name = "Xen VM: %s" % ip # use hostname passed in
46
# STEP 4. Specify IP address(es), for the new domain. You need to
47
# configure IP addrs within the domain just as you do normally. This
48
# is just to let Xen know about them so it can route packets
51
#vfr_ipaddr = ["111.222.333.444","222.333.444.555"]
52
#vfr_ipaddr = [XenoUtil.add_offset_to_ip(XenoUtil.get_current_ipaddr(),vmid)]
53
vfr_ipaddr = map(socket.gethostbyname,string.split(ip,','))
57
# STEP 5a. Identify any physcial partitions or virtual disks you want the
58
# domain to have access to, and what you want them accessible as
59
# e.g. vbd_list = [ ('phy:sda1','sda1', 'w'),
60
# ('phy:sda%d' % (3+vmid), 'hda2', 'r'),
61
# ('vd:as73gd784dh','hda1','w'),
62
# ('phy:cdrom','hdd','r')
64
vbd_list = [ ('phy:cdrom','hdd','r' ) ]
68
# STEP 5b. Set the VBD expertise level. Most people should leave this
69
# on 0, at least to begin with - this script can detect most dangerous
70
# disk sharing between domains and with this set to zero it will only
71
# allow read only sharing.
76
# STEP 6. Build the command line for the new domain. Edit as req'd.
77
# You only need the ip= line if you're NFS booting or the root file system
78
# doesn't set it later e.g. in ifcfg-eth0 or via DHCP
79
# You can use 'extrabit' to set the runlevel and custom environment
80
# variables used by custom rc scripts (e.g. VMID=, usr= )
83
# see if we have a local IP at all
86
if XenoUtil.check_subnet(i,'169.254.0.0','255.255.0.0'):
91
# if either netmask and gateway has been set from the command line,
92
# associate it with the first IP address that has been specified.
97
netmask = socket.gethostbyname( netmask )
98
gateway = socket.gethostbyname( gateway )
102
netmask = XenoUtil.get_current_ipmask()
103
gateway = XenoUtil.get_current_ipgw()
105
# if we haven't got an address, see if we have one that matches the LAN
108
if netmask and gateway:
110
if XenoUtil.check_subnet(i,gateway,netmask):
114
# if we still haven't got an address, see if there's a link local one
116
if not myip and localip:
118
netmask = '255.255.0.0'
119
gateway = '169.254.1.0'
122
# As a final fallback, through everything down the interface
129
# Calculate the components with which we will build the command line
131
nfsserv = '169.254.1.0'
133
cmdline_ip="ip="+myip+":"+nfsserv+":"+gateway+":"+netmask+"::eth0:off"
134
cmdline_root = "root=/dev/ram0 rw init=/linuxrc"
137
cmdline_extra = "4 LOCALIP=%s" % localip
141
# STEP 7. Set according to whether you want the script to watch the domain
142
# and auto-restart it should it die or exit.