This is supported only if there is a receiving server, such as myops, for the
[bootmanager.git] / source / BootManager.py
index 714aa15..4ea06c8 100755 (executable)
@@ -1,5 +1,8 @@
 #!/usr/bin/python -u
-
+#
+# $Id$
+# $URL$
+#
 # Copyright (c) 2003 Intel Corporation
 # All rights reserved.
 #
@@ -15,6 +18,7 @@ from steps import *
 from Exceptions import *
 import notify_messages
 import BootServerRequest
+import utils
 
 # all output is written to this file
 BM_NODE_LOG= "/tmp/bm.log"
@@ -109,7 +113,7 @@ class log:
         self.LogEntry( str, 0, 1 )
     
     # bm log uploading is available back again, as of nodeconfig-5.0-2
-    def Upload( self ):
+    def Upload( self, extra_file=None ):
         """
         upload the contents of the log to the server
         """
@@ -124,11 +128,28 @@ class log:
             hostname= self.VARS['INTERFACE_SETTINGS']['hostname'] + "." + \
                       self.VARS['INTERFACE_SETTINGS']['domainname']
             bs_request = BootServerRequest.BootServerRequest(self.VARS)
-            bs_request.MakeRequest(PartialPath = self.VARS['UPLOAD_LOG_SCRIPT'],
-                                   GetVars = None, PostVars = None,
-                                   FormData = ["log=@" + self.OutputFilePath,
-                                   "hostname=" + hostname, "type=bm.log"],
-                                   DoSSL = True, DoCertCheck = True)
+            try:
+                # this was working until f10
+                bs_request.MakeRequest(PartialPath = self.VARS['UPLOAD_LOG_SCRIPT'],
+                                       GetVars = None, PostVars = None,
+                                       DoSSL = True, DoCertCheck = True,
+                                       FormData = ["log=@" + self.OutputFilePath,
+                                                   "hostname=" + hostname, 
+                                                   "type=bm.log"])
+            except:
+                # new pycurl
+                import pycurl
+                bs_request.MakeRequest(PartialPath = self.VARS['UPLOAD_LOG_SCRIPT'],
+                                       GetVars = None, PostVars = None,
+                                       DoSSL = True, DoCertCheck = True,
+                                       FormData = [('log',(pycurl.FORM_FILE, self.OutputFilePath)),
+                                                   ("hostname",hostname),
+                                                   ("type","bm.log")])
+        if extra_file is not None:
+            # NOTE: for code-reuse, evoke the bash function 'upload_logs'; 
+            # by adding --login, bash reads .bash_profile before execution.
+            utils.sysexec( """bash --login -c "upload_logs %s" """ % extra_file, self)
+
 
 ##############################
 class BootManager:
@@ -211,7 +232,6 @@ class BootManager:
             ret = ValidateNodeInstall.Run( self.VARS, self.LOG )
             if ret == 1:
                 WriteModprobeConfig.Run( self.VARS, self.LOG )
-                MakeInitrd.Run( self.VARS, self.LOG )
                 WriteNetworkConfig.Run( self.VARS, self.LOG )
                 CheckForNewDisks.Run( self.VARS, self.LOG )
                 SendHardwareConfigToPLC.Run( self.VARS, self.LOG )
@@ -347,6 +367,9 @@ def main(argv):
     # the data back to PlanetLab central
     LOG= log( BM_NODE_LOG )
 
+    # NOTE: assume CWD is BM's source directory, but never fail
+    utils.sysexec("./setup_bash_history_scripts.sh || /bin/true", LOG)
+
     LOG.LogEntry( "BootManager started at: %s" % \
                   time.strftime("%a, %d %b %Y %H:%M:%S +0000", time.gmtime()) )