2 Various functions that are used to allow the boot manager to run on various
3 different cds are included here
10 import BootServerRequest
13 def setup_lvm_2x_cd( vars, log ):
15 make available a set of lvm utilities for 2.x cds that don't have them
18 Expect the following variables to be set:
19 TEMP_PATH somewhere to store what we need to run
20 BOOT_CD_VERSION A tuple of the current bootcd version
21 ALPINA_SERVER_DIR directory on the boot servers containing alpina
22 scripts and support files
23 LVM_SETUP_2X_CD indicates if lvm is downloaded and setup for 2.x cds
25 Set the following variables upon successfully running:
26 LVM_SETUP_2X_CD indicates if lvm is downloaded and setup for 2.x cds
29 # make sure we have the variables we need
31 TEMP_PATH= vars["TEMP_PATH"]
33 raise ValueError, "TEMP_PATH"
35 BOOT_CD_VERSION= vars["BOOT_CD_VERSION"]
36 if BOOT_CD_VERSION == "":
37 raise ValueError, "BOOT_CD_VERSION"
39 ALPINA_SERVER_DIR= vars["ALPINA_SERVER_DIR"]
40 if ALPINA_SERVER_DIR == None:
41 raise ValueError, "ALPINA_SERVER_DIR"
44 raise BootManagerException, "Missing variable in vars: %s\n" % var
45 except ValueError, var:
46 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
49 if BOOT_CD_VERSION[0] != 2:
50 log.write( "Only 2.x boot cds need lvm setup manually.\n" )
54 if 'LVM_SETUP_2X_CD' in vars.keys():
55 LVM_SETUP_2X_CD= vars['LVM_SETUP_2X_CD']
58 log.write( "LVM already downloaded and setup\n" )
61 log.write( "Downloading additional libraries for lvm\n" )
63 bs_request= BootServerRequest.BootServerRequest()
65 utils.makedirs(TEMP_PATH)
67 # download and extract support tarball for this step,
68 # which has everything we need to successfully run
69 step_support_file= "alpina-BootLVM.tar.gz"
70 source_file= "%s/%s" % (ALPINA_SERVER_DIR,step_support_file)
71 dest_file= "%s/%s" % (TEMP_PATH, step_support_file)
73 log.write( "Downloading support file for this step\n" )
74 result= bs_request.DownloadFile( source_file, None, None,
77 raise BootManagerException, "Download failed."
79 log.write( "Extracting support files\n" )
81 utils.chdir( TEMP_PATH )
82 utils.sysexec( "tar -C / -xzf %s" % step_support_file, log )
83 utils.removefile( dest_file )
86 utils.sysexec( "ldconfig", log )
89 log.write( "Loading lvm module\n" )
90 utils.sysexec( "modprobe lvm-mod", log )
92 # take note that we have lvm setup
94 vars['LVM_SETUP_2X_CD']= LVM_SETUP_2X_CD
100 def setup_partdisks_2x_cd( vars, log ):
102 download necessary files to handle partitioning disks on 2.x cds
104 Expect the following variables to be set:
105 TEMP_PATH somewhere to store what we need to run
106 BOOT_CD_VERSION A tuple of the current bootcd version
107 ALPINA_SERVER_DIR directory on the boot servers containing alpina
108 scripts and support files
109 PARTDISKS_SETUP_2X_CD indicates if lvm is downloaded and setup for 2.x cds
111 Set the following variables upon successfully running:
112 PARTDISKS_SETUP_2X_CD indicates if lvm is downloaded and setup for 2.x cds
115 # make sure we have the variables we need
117 TEMP_PATH= vars["TEMP_PATH"]
119 raise ValueError, "TEMP_PATH"
121 BOOT_CD_VERSION= vars["BOOT_CD_VERSION"]
122 if BOOT_CD_VERSION == "":
123 raise ValueError, "BOOT_CD_VERSION"
125 ALPINA_SERVER_DIR= vars["ALPINA_SERVER_DIR"]
126 if ALPINA_SERVER_DIR == None:
127 raise ValueError, "ALPINA_SERVER_DIR"
129 except KeyError, var:
130 raise BootManagerException, "Missing variable in vars: %s\n" % var
131 except ValueError, var:
132 raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
135 if BOOT_CD_VERSION[0] != 2:
136 log.write( "Only 2.x boot cds need partition disk tools setup manually.\n" )
139 PARTDISKS_SETUP_2X_CD= 0
140 if 'PARTDISKS_SETUP_2X_CD' in vars.keys():
141 PARTDISKS_SETUP_2X_CD= vars['PARTDISKS_SETUP_2X_CD']
143 if PARTDISKS_SETUP_2X_CD:
144 log.write( "Partition disk tools already downloaded and setup\n" )
147 log.write( "Downloading additional libraries for partitioning disks\n" )
149 bs_request= BootServerRequest.BootServerRequest()
151 # download and extract support tarball for this step,
152 # which has everything we need to successfully run
153 step_support_file= "alpina-PartDisks.tar.gz"
154 source_file= "%s/%s" % (ALPINA_SERVER_DIR,step_support_file)
155 dest_file= "%s/%s" % (TEMP_PATH, step_support_file)
157 log.write( "Downloading support file for this step\n" )
158 result= bs_request.DownloadFile( source_file, None, None,
161 raise BootManagerException, "Download failed."
163 log.write( "Extracting support files\n" )
165 utils.chdir( TEMP_PATH )
166 utils.sysexec( "tar -xzf %s" % step_support_file, log )
167 utils.removefile( dest_file )
168 utils.chdir( old_wd )
170 # also included in the support package was a list of extra
171 # paths (lib-paths) for /etc/ld.so.conf.
172 # so add those, and rerun ldconfig
173 # so we can make our newly downloaded libraries available
175 ldconf_file= file("/etc/ld.so.conf","a+")
176 lib_paths_file= file( TEMP_PATH + "/lib-paths","r")
178 for line in lib_paths_file:
179 path= string.strip(line)
181 ldconf_file.write( "%s/%s\n" % (TEMP_PATH,path) )
183 lib_paths_file.close()
185 utils.sysexec( "ldconfig", log )
187 # update the PYTHONPATH to include the python modules in
188 # the support package
189 sys.path.append( TEMP_PATH + "/usr/lib/python2.2" )
190 sys.path.append( TEMP_PATH + "/usr/lib/python2.2/site-packages" )
192 # update the environment variable PATH to include
193 # TEMP_PATH/sbin and others there
194 new_paths= ('%s/sbin'% TEMP_PATH,
196 '%s/user/sbin'% TEMP_PATH,
197 '%s/user/bin'% TEMP_PATH)
199 old_path= os.environ['PATH']
200 os.environ['PATH']= old_path + ":" + string.join(new_paths,":")
202 # everything should be setup to import parted. this
203 # import is just to make sure it'll work when this step
205 log.write( "Imported parted\n" )
209 raise BootManagerException, "Unable to import parted."
211 # take note that we have part disks setup
212 PARTDISKS_SETUP_2X_CD= 1
213 vars['PARTDISKS_SETUP_2X_CD']= PARTDISKS_SETUP_2X_CD