5 # Copyright (c) 2003 Intel Corporation
8 # Copyright (c) 2004-2006 The Trustees of Princeton University
16 from Exceptions import *
20 # locations of boot os version files
21 BOOT_VERSION_2X_FILE='/usr/bootme/ID'
22 BOOT_VERSION_3X_FILE='/pl_version'
24 # minimium version of the boot os we need to run, as a (major,minor) tuple
25 MINIMUM_BOOT_VERSION= (3,0)
27 # minimum version of python required to run the boot manager
28 MINIMUM_PYTHON_VERSION= (2,2,0)
33 Setup the boot manager so it can run, do any extra necessary
34 hardware setup (to fix old cd problems)
36 Sets the following variables:
37 PARTITIONS A dictionary of generic partition types and their
39 BOOT_CD_VERSION A two number tuple of the boot cd version
42 log.write( "\n\nStep: Initializing the BootManager.\n" )
44 # define the basic partition paths
46 PARTITIONS["root"]= "/dev/planetlab/root"
47 PARTITIONS["swap"]= "/dev/planetlab/swap"
48 PARTITIONS["vservers"]= "/dev/planetlab/vservers"
49 # Linux 2.6 mounts LVM with device mapper
50 PARTITIONS["mapper-root"]= "/dev/mapper/planetlab-root"
51 PARTITIONS["mapper-swap"]= "/dev/mapper/planetlab-swap"
52 PARTITIONS["mapper-vservers"]= "/dev/mapper/planetlab-vservers"
53 vars["PARTITIONS"]= PARTITIONS
55 log.write( "Opening connection to API server\n" )
57 api_inst= xmlrpclib.Server( vars['BOOT_API_SERVER'], verbose=0 )
59 raise BootManagerException, \
60 "configuration file does not specify API server URL"
62 vars['API_SERVER_INST']= api_inst
64 if not __check_boot_version( vars, log ):
65 raise BootManagerException, \
66 "Boot CD version insufficient to run the Boot Manager"
68 log.write( "Running on boot cd version: %s\n" %
69 str(vars['BOOT_CD_VERSION']) )
71 BOOT_CD_VERSION= vars['BOOT_CD_VERSION']
73 # for anything that needs to know we are running under the boot cd and
75 os.environ['PL_BOOTCD']= "1"
81 def __check_boot_version( vars, log ):
83 identify which version of the boot os we are running on, and whether
84 or not we can run at all on the given version. later, this will be
85 used to identify extra packages to download to enable the boot manager
86 to run on any supported version.
88 2.x cds have the version file in /usr/bootme/ID, which looked like:
89 'PlanetLab BootCD v2.0.3'
91 3.x cds have the version file in /pl_version, which lookes like:
92 'PlanetLab BootCD 3.0-beta0.3'
94 All current known version strings that we support:
96 PlanetLab BootCD 3.0-beta0.1
97 PlanetLab BootCD 3.0-beta0.3
99 PlanetLab BootCD v2.0.1
100 PlanetLab BootCD v2.0.2
101 PlanetLab BootCD v2.0.3
103 Returns 1 if the boot os version is identified and will work
104 to run the boot manager. Two class variables are set:
105 BOOT_OS_MAJOR_VERSION
106 BOOT_OS_MINOR_VERSION
107 version strings with three parts parts to the version ignore the
108 middle number (so 2.0.3 is major 2, minor 3)
110 Returns 0 if the boot os is insufficient to run the boot manager
114 # check for a 3.x version first
115 version_file= file(BOOT_VERSION_3X_FILE,'r')
116 full_version= string.strip(version_file.read())
119 version_parts= string.split(full_version)
120 version= version_parts[-1]
122 version_numbers= string.split(version,".")
123 if len(version_numbers) == 2:
124 BOOT_OS_MAJOR_VERSION= int(version_numbers[0])
125 BOOT_OS_MINOR_VERSION= int(version_numbers[1])
127 # for 3.x cds, if there are more than two parts
128 # separated by a ., its one of the beta cds.
129 # hardcode as a 3.0 cd
130 BOOT_OS_MAJOR_VERSION= 3
131 BOOT_OS_MINOR_VERSION= 0
133 vars['BOOT_CD_VERSION']= (BOOT_OS_MAJOR_VERSION,BOOT_OS_MINOR_VERSION)
135 if (BOOT_OS_MAJOR_VERSION,BOOT_OS_MINOR_VERSION) >= \
136 MINIMUM_BOOT_VERSION:
141 except IndexError, e:
148 # check for a 2.x version first
149 version_file= file(BOOT_VERSION_2X_FILE,'r')
150 full_version= string.strip(version_file.read())
153 version_parts= string.split(full_version)
154 version= version_parts[-1]
155 if version[0] == 'v':
158 version_numbers= string.split(version,".")
159 if len(version_numbers) == 2:
160 BOOT_OS_MAJOR_VERSION= int(version_numbers[0])
161 BOOT_OS_MINOR_VERSION= int(version_numbers[1])
163 BOOT_OS_MAJOR_VERSION= int(version_numbers[0])
164 BOOT_OS_MINOR_VERSION= int(version_numbers[2])
166 vars['BOOT_CD_VERSION']= (BOOT_OS_MAJOR_VERSION,BOOT_OS_MINOR_VERSION)
168 if (BOOT_OS_MAJOR_VERSION,BOOT_OS_MINOR_VERSION) >= \
169 MINIMUM_BOOT_VERSION:
174 except IndexError, e:
184 def _create_cciss_dev_entries():
185 def mkccissnod(dev,node):
186 dev = dev + " b 104 %d" % (node)
187 cmd = "mknod /dev/cciss/%s" %dev
188 utils.sysexec_noerr(cmd)
193 for i in range(0,16):
195 node = mkccissnod(dev,node)
196 for j in range(1,16):
197 subdev = dev + "p%d" % j
198 node = mkccissnod(subdev,node)