From 88cfdd881bbd5191eaaf6408e0b8d57bfdf51438 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Mon, 8 May 2006 21:42:55 +0000 Subject: [PATCH] use BootServerRequest to upload logs to the right server --- source/BootManager.py | 18 +++++++++--------- source/BootServerRequest.py | 9 +++++++-- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/source/BootManager.py b/source/BootManager.py index af5efa3..b49d978 100755 --- a/source/BootManager.py +++ b/source/BootManager.py @@ -56,13 +56,13 @@ from gzip import GzipFile from steps import * from Exceptions import * import notify_messages +import BootServerRequest # all output is written to this file LOG_FILE= "/tmp/bm.log" -CURL_PATH= "curl" -UPLOAD_LOG_URL = "http://boot.planet-lab.org/alpina-logs/upload.php" +UPLOAD_LOG_PATH = "/alpina-logs/upload.php" # the new contents of PATH when the boot manager is running BIN_PATH= ('/usr/local/bin', @@ -119,15 +119,16 @@ class log: """ if self.OutputFile is not None: - self.LogEntry( "Uploading logs to %s" % UPLOAD_LOG_URL ) + self.LogEntry( "Uploading logs to %s" % UPLOAD_LOG_PATH ) self.OutputFile.close() self.OutputFile= None - - curl_cmd= "%s -s --connect-timeout 60 --max-time 600 " \ - "--form log=@%s %s" % \ - (CURL_PATH, self.OutputFilePath, UPLOAD_LOG_URL) - os.system( curl_cmd ) + + bs_request = BootServerRequest.BootServerRequest() + bs_request.MakeRequest(PartialPath = UPLOAD_LOG_PATH, + GetVars = None, PostVars = None, + FormData = ["log=@" + self.OutputFilePath], + DoSSL = True, DoCertCheck = True) @@ -315,7 +316,6 @@ class BootManager: InstallInit.Run( self.VARS, self.LOG ) InstallPartitionDisks.Run( self.VARS, self.LOG ) InstallBootstrapRPM.Run( self.VARS, self.LOG ) - InstallBase.Run( self.VARS, self.LOG ) InstallWriteConfig.Run( self.VARS, self.LOG ) InstallBuildVServer.Run( self.VARS, self.LOG ) InstallNodeInit.Run( self.VARS, self.LOG ) diff --git a/source/BootServerRequest.py b/source/BootServerRequest.py index f37b2ce..a81ca9b 100644 --- a/source/BootServerRequest.py +++ b/source/BootServerRequest.py @@ -210,7 +210,8 @@ class BootServerRequest: def MakeRequest( self, PartialPath, GetVars, PostVars, DoSSL, DoCertCheck, ConnectTimeout= DEFAULT_CURL_CONNECT_TIMEOUT, - MaxTransferTime= DEFAULT_CURL_MAX_TRANSFER_TIME): + MaxTransferTime= DEFAULT_CURL_MAX_TRANSFER_TIME, + FormData= None): if PYCURL_LOADED == 0: self.Error( "MakeRequest method requires pycurl." ) @@ -291,7 +292,11 @@ class BootServerRequest: if dopostdata: curl.setopt(pycurl.POSTFIELDS, postdata) - + + # setup multipart/form-data upload + if FormData: + curl.setopt(pycurl.HTTPPOST, FormData) + curl.setopt(pycurl.URL, url) self.Message( "URL: %s" % url ) -- 2.43.0