"""
upload the contents of the log to the server
"""
-
- self.LogEntry( "Uploading logs to %s" % UPLOAD_LOG_URL )
-
- self.OutputFile.close()
- self.OutputFile= None
-
- curl_cmd= "%s -s --connect-timeout 60 --max-time 600 " \
- "--form log=@%s --form ifconfig=\</tmp/ifconfig %s" % \
- (CURL_PATH, self.OutputFilePath, UPLOAD_LOG_URL)
- os.system( curl_cmd )
+
+ if self.OutputFile is not None:
+ self.LogEntry( "Uploading logs to %s" % UPLOAD_LOG_URL )
+
+ self.OutputFile.close()
+ self.OutputFile= None
+
+ curl_cmd= "%s -s --connect-timeout 60 --max-time 600 " \
+ "--form log=@%s --form ifconfig=\</tmp/ifconfig %s" % \
+ (CURL_PATH, self.OutputFilePath, UPLOAD_LOG_URL)
+ os.system( curl_cmd )
# further use of log after Upload will only output to screen
log.Upload()
+ # regardless of whether kexec works or not, we need to stop trying to
+ # run anything
+ cancel_boot_flag= "/tmp/CANCEL_BOOT"
+ utils.sysexec( "touch %s" % cancel_boot_flag, log )
+
# on 2.x cds (2.4 kernel) for sure, we need to shutdown everything to
# get kexec to work correctly
utils.sysexec_noerr( "modprobe -r %s" % module, log )
except IOError:
log.write( "Couldn't load /tmp/loadedmodules to unload, continuing.\n" )
-
- utils.sysexec( "kexec --force --initrd=/tmp/initrd " \
- "--append=ramdisk_size=8192 /tmp/kernel" )
+
+ try:
+ utils.sysexec( "kexec --force --initrd=/tmp/initrd " \
+ "--append=ramdisk_size=8192 /tmp/kernel" )
+ except BootManagerException, e:
+ # if kexec fails, we've shut the machine down to a point where nothing
+ # can run usefully anymore (network down, all modules unloaded, file
+ # systems unmounted. write out the error, and cancel the boot process
+
+ log.write( "\n\n" )
+ log.write( "-------------------------------------------------------\n" )
+ log.write( "kexec failed with the following error. Please report\n" )
+ log.write( "this problem to support@planet-lab.org.\n\n" )
+ log.write( str(e) + "\n\n" )
+ log.write( "The boot process has been canceled.\n" )
+ log.write( "-------------------------------------------------------\n\n" )
return