d4ee55c73ebc1dfc0a4becc20f942de398b655fe
[bootmanager.git] / source / steps / StartRunlevelAgent.py
1 #!/usr/bin/python
2 #
3 # Copyright (c) 2003 Intel Corporation
4 # All rights reserved.
5 #
6 # Copyright (c) 2004-2006 The Trustees of Princeton University
7 # All rights reserved.
8
9
10 import os
11
12 from Exceptions import *
13 import BootAPI
14
15
16 def Run( vars, log ):
17     """
18         Start the RunlevelAgent.py script.  Should follow
19         AuthenticateWithPLC() in order to guarantee that
20         /etc/planetlab/session is present.
21     """
22
23     log.write( "\n\nStep: Starting RunlevelAgent.py\n" )
24
25     try:
26         cmd = "%s/RunlevelAgent.py" % vars['BM_SOURCE_DIR']
27         # raise error if script is not present.
28         os.stat(cmd)
29         # init script only starts RLA once.
30         os.system("/usr/bin/python %s start bootmanager &" % cmd)
31     except KeyError, var:
32         raise BootManagerException, "Missing variable in vars: %s\n" % var
33     except ValueError, var:
34         raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
35
36     return 1
37     
38