From 008c4db00ad126481773f3b0f0bfdabe25553b0e Mon Sep 17 00:00:00 2001 From: Stephen Soltesz Date: Wed, 18 Feb 2009 23:47:38 +0000 Subject: [PATCH] Patch to BootManager to implement the proposed run_level 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 | 2 +- source/BootAPI.py | 1 - source/BootManager.py | 1 + source/steps/StartRunlevelAgent.py | 38 ++++++++++++++++++++++++++++++ source/steps/__init__.py | 1 + 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 source/steps/StartRunlevelAgent.py diff --git a/build.sh b/build.sh index 5cafd43..363c5a5 100755 --- 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 diff --git a/source/BootAPI.py b/source/BootAPI.py index b3bbffb..d69755b 100644 --- a/source/BootAPI.py +++ b/source/BootAPI.py @@ -51,7 +51,6 @@ def create_auth_structure( vars, call_params ): auth = auth_session except: - import traceback; traceback.print_exc() auth['AuthMethod']= 'hmac' try: diff --git a/source/BootManager.py b/source/BootManager.py index 838a8a1..1c3e78f 100755 --- a/source/BootManager.py +++ b/source/BootManager.py @@ -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 index 0000000..57da73d --- /dev/null +++ b/source/steps/StartRunlevelAgent.py @@ -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 + + diff --git a/source/steps/__init__.py b/source/steps/__init__.py index d1979a6..82619f0 100644 --- a/source/steps/__init__.py +++ b/source/steps/__init__.py @@ -24,6 +24,7 @@ __all__ = ["ReadNodeConfiguration", "ChainBootNode", "ValidateNodeInstall", "StartDebug", + "StartRunlevelAgent", "InstallBootstrapFS", "InstallInit", "InstallPartitionDisks", -- 2.43.0