c88b35f430567863e321a42e6e7f2fc339d58bb7
[bootmanager.git] / source / steps / StopRunlevelAgent.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         Stop the RunlevelAgent.py script.  Should proceed
19         kexec to reset run_level to 'boot' before kexec
20     """
21
22     log.write( "\n\nStep: Stopping RunlevelAgent.py\n" )
23
24     try:
25         cmd = "%s/RunlevelAgent.py" % vars['BM_SOURCE_DIR']
26         # raise error if script is not present.
27         os.stat(cmd)
28         os.system("/usr/bin/python %s stop" % cmd)
29     except KeyError, var:
30         raise BootManagerException, "Missing variable in vars: %s\n" % var
31     except ValueError, var:
32         raise BootManagerException, "Variable in vars, shouldn't be: %s\n" % var
33
34     try:
35         update_vals= {}
36         update_vals['run_level']='boot'
37         BootAPI.call_api_function( vars, "ReportRunlevel", (update_vals,) )
38     except BootManagerException, e:
39         log.write( "Unable to update boot state for this node at PLC: %s.\n" % e )
40
41     return 1
42     
43