3 # Copyright (c) 2003 Intel Corporation
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
14 from Exceptions import *
18 # locations of boot os version files
19 BOOT_VERSION_2X_FILE='/usr/bootme/ID'
20 BOOT_VERSION_3X_FILE='/pl_version'
22 # minimium version of the boot os we need to run, as a (major,minor) tuple
23 MINIMUM_BOOT_VERSION= (3,0)
25 # minimum version of python required to run the boot manager
26 MINIMUM_PYTHON_VERSION= (2,2,0)
31 Setup the boot manager so it can run, do any extra necessary
32 hardware setup (to fix old cd problems)
34 Sets the following variables:
35 PARTITIONS A dictionary of generic partition types and their
37 BOOT_CD_VERSION A two number tuple of the boot cd version
40 log.write( "\n\nStep: Initializing the BootManager.\n" )
42 # define the basic partition paths
44 PARTITIONS["root"]= "/dev/planetlab/root"
45 PARTITIONS["swap"]= "/dev/planetlab/swap"
46 PARTITIONS["vservers"]= "/dev/planetlab/vservers"
47 # Linux 2.6 mounts LVM with device mapper
48 PARTITIONS["mapper-root"]= "/dev/mapper/planetlab-root"
49 PARTITIONS["mapper-swap"]= "/dev/mapper/planetlab-swap"
50 PARTITIONS["mapper-vservers"]= "/dev/mapper/planetlab-vservers"
51 vars["PARTITIONS"]= PARTITIONS
53 log.write( "Opening connection to API server\n" )
55 api_inst= xmlrpclib.Server( vars['BOOT_API_SERVER'], verbose=0 )
57 raise BootManagerException, \
58 "configuration file does not specify API server URL"
60 vars['API_SERVER_INST']= api_inst
62 if not __check_boot_version( vars, log ):
63 raise BootManagerException, \
64 "Boot CD version insufficient to run the Boot Manager"
66 log.write( "Running on boot cd version: %s\n" %
67 str(vars['BOOT_CD_VERSION']) )
69 BOOT_CD_VERSION= vars['BOOT_CD_VERSION']
71 # for anything that needs to know we are running under the boot cd and
73 os.environ['PL_BOOTCD']= "1"
79 def __check_boot_version( vars, log ):
81 identify which version of the boot os we are running on, and whether
82 or not we can run at all on the given version. later, this will be
83 used to identify extra packages to download to enable the boot manager
84 to run on any supported version.
86 2.x cds have the version file in /usr/bootme/ID, which looked like:
87 'PlanetLab BootCD v2.0.3'
89 3.x cds have the version file in /pl_version, which lookes like:
90 'PlanetLab BootCD 3.0-beta0.3'
92 All current known version strings that we support:
94 PlanetLab BootCD 3.0-beta0.1
95 PlanetLab BootCD 3.0-beta0.3
97 PlanetLab BootCD v2.0.1
98 PlanetLab BootCD v2.0.2
99 PlanetLab BootCD v2.0.3
101 Returns 1 if the boot os version is identified and will work
102 to run the boot manager. Two class variables are set:
103 BOOT_OS_MAJOR_VERSION
104 BOOT_OS_MINOR_VERSION
105 version strings with three parts parts to the version ignore the
106 middle number (so 2.0.3 is major 2, minor 3)
108 Returns 0 if the boot os is insufficient to run the boot manager
112 # check for a 3.x version first
113 version_file= file(BOOT_VERSION_3X_FILE,'r')
114 full_version= string.strip(version_file.read())
117 version_parts= string.split(full_version)
118 version= version_parts[-1]
120 version_numbers= string.split(version,".")
121 if len(version_numbers) == 2:
122 BOOT_OS_MAJOR_VERSION= int(version_numbers[0])
123 BOOT_OS_MINOR_VERSION= int(version_numbers[1])
125 # for 3.x cds, if there are more than two parts
126 # separated by a ., its one of the beta cds.
127 # hardcode as a 3.0 cd
128 BOOT_OS_MAJOR_VERSION= 3
129 BOOT_OS_MINOR_VERSION= 0
131 vars['BOOT_CD_VERSION']= (BOOT_OS_MAJOR_VERSION,BOOT_OS_MINOR_VERSION)
133 if (BOOT_OS_MAJOR_VERSION,BOOT_OS_MINOR_VERSION) >= \
134 MINIMUM_BOOT_VERSION:
139 except IndexError, e:
146 # check for a 2.x version first
147 version_file= file(BOOT_VERSION_2X_FILE,'r')
148 full_version= string.strip(version_file.read())
151 version_parts= string.split(full_version)
152 version= version_parts[-1]
153 if version[0] == 'v':
156 version_numbers= string.split(version,".")
157 if len(version_numbers) == 2:
158 BOOT_OS_MAJOR_VERSION= int(version_numbers[0])
159 BOOT_OS_MINOR_VERSION= int(version_numbers[1])
161 BOOT_OS_MAJOR_VERSION= int(version_numbers[0])
162 BOOT_OS_MINOR_VERSION= int(version_numbers[2])
164 vars['BOOT_CD_VERSION']= (BOOT_OS_MAJOR_VERSION,BOOT_OS_MINOR_VERSION)
166 if (BOOT_OS_MAJOR_VERSION,BOOT_OS_MINOR_VERSION) >= \
167 MINIMUM_BOOT_VERSION:
172 except IndexError, e:
182 def _create_cciss_dev_entries():
183 def mkccissnod(dev,node):
184 dev = dev + " b 104 %d" % (node)
185 cmd = "mknod /dev/cciss/%s" %dev
186 utils.sysexec_noerr(cmd)
191 for i in range(0,16):
193 node = mkccissnod(dev,node)
194 for j in range(1,16):
195 subdev = dev + "p%d" % j
196 node = mkccissnod(subdev,node)