done prettifying
[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 def Run(vars, log):
16     """
17         Start the RunlevelAgent.py script.  Should follow
18         AuthenticateWithPLC() in order to guarantee that
19         /etc/planetlab/session is present.
20     """
21
22     log.write("\n\nStep: Starting RunlevelAgent.py\n")
23
24     try:
25         cmd = "{}/RunlevelAgent.py".format(vars['BM_SOURCE_DIR'])
26         # raise error if script is not present.
27         os.stat(cmd)
28         # init script only starts RLA once.
29         os.system("/usr/bin/python {} start bootmanager &".format(cmd))
30     except KeyError as var:
31         raise BootManagerException("Missing variable in vars: {}\n".format(var))
32     except ValueError as var:
33         raise BootManagerException("Variable in vars, shouldn't be: {}\n".format(var))
34
35     return 1
36     
37