Patch to BootManager to implement the proposed run_level
authorStephen Soltesz <soltesz@cs.princeton.edu>
Wed, 18 Feb 2009 23:47:38 +0000 (23:47 +0000)
committerStephen Soltesz <soltesz@cs.princeton.edu>
Wed, 18 Feb 2009 23:47:38 +0000 (23:47 +0000)
http://lists.planet-lab.org/pipermail/devel/2009-February/003283.html

basically:
BM will safe it's session key to make it available to the RunlevelAgent.py
exported by monitor-runlevelagent package.  This script is started and
runs continuously or until the system enter production.

build.sh copies the necessary files from the monitor-runlevelagent package

build.sh
source/BootAPI.py
source/BootManager.py
source/steps/StartRunlevelAgent.py [new file with mode: 0644]
source/steps/__init__.py

index 5cafd43..363c5a5 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -93,7 +93,7 @@ fi
 # Add pypcilib and pyplnet
 extra_libs=`mktemp -d "/tmp/.bootmanager.XXXXXX"`
 mkdir $extra_libs/source
-cp -p $(rpm -ql pypcilib pyplnet | grep -v '\.py[co]$') $extra_libs/source
+cp -p $(rpm -ql pypcilib pyplnet monitor-runlevelagent | grep -v '\.py[co]$') $extra_libs/source
 
 # Embed the uuencoded tarball in the script
 tar -cj -C $srcdir source/ -C $extra_libs source/ | uuencode -m - >> $DEST_SCRIPT
index b3bbffb..d69755b 100644 (file)
@@ -51,7 +51,6 @@ def create_auth_structure( vars, call_params ):
         auth = auth_session
 
     except:
-        import traceback; traceback.print_exc()
         auth['AuthMethod']= 'hmac'
 
         try:
index 838a8a1..1c3e78f 100755 (executable)
@@ -274,6 +274,7 @@ class BootManager:
             InitializeBootManager.Run( self.VARS, self.LOG )
             ReadNodeConfiguration.Run( self.VARS, self.LOG )
             AuthenticateWithPLC.Run( self.VARS, self.LOG )
+            StartRunlevelAgent.Run( self.VARS, self.LOG )
             GetAndUpdateNodeDetails.Run( self.VARS, self.LOG )
 
             # override machine's current state from the command line
diff --git a/source/steps/StartRunlevelAgent.py b/source/steps/StartRunlevelAgent.py
new file mode 100644 (file)
index 0000000..57da73d
--- /dev/null
@@ -0,0 +1,38 @@
+#!/usr/bin/python
+
+# Copyright (c) 2003 Intel Corporation
+# All rights reserved.
+#
+# Copyright (c) 2004-2006 The Trustees of Princeton University
+# All rights reserved.
+
+
+import os
+
+from Exceptions import *
+import BootAPI
+
+
+def Run( vars, log ):
+    """
+        Start the RunlevelAgent.py script.  Should follow
+        AuthenticateWithPLC() in order to guarantee that
+        /etc/planetlab/session is present.
+    """
+
+    log.write( "\n\nStep: Starting RunlevelAgent.py\n" )
+
+    try:
+        cmd = "%s/monitor-runlevelagent" % vars['BM_SOURCE_DIR']
+        # raise error if script is not present.
+        os.stat(cmd)
+        # init script only starts RLA once.
+        os.system("/bin/sh %s start bootmanager" % cmd)
+    except KeyError, var:
+        raise BootManagerException, "Missing variable in vars: %s\n" % var
+    except ValueError, var:
+        raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
+
+    return 1
+    
+
index d1979a6..82619f0 100644 (file)
@@ -24,6 +24,7 @@ __all__ = ["ReadNodeConfiguration",
            "ChainBootNode",
            "ValidateNodeInstall",
            "StartDebug",
+           "StartRunlevelAgent",
            "InstallBootstrapFS",
            "InstallInit",
            "InstallPartitionDisks",