clearer names for actions, and infer actions better
[monitor.git] / commands / bootman.py
1 #!/usr/bin/python
2
3 # Attempt to reboot a node in debug state.
4
5
6
7 import os
8 import sys
9 import time
10 import random
11 import signal
12 import traceback
13 import subprocess
14 from sets import Set
15 from monitor.bootman import *
16 from monitor.util import file 
17
18 # MAIN -------------------------------------------------------------------
19
20 def main():
21         from monitor import parser as parsermodule
22         parser = parsermodule.getParser()
23
24         parser.set_defaults(child=False, collect=False, nosetup=False, verbose=False, 
25                                                 force=None, quiet=False)
26         parser.add_option("", "--child", dest="child", action="store_true", 
27                                                 help="This is the child mode of this process.")
28         parser.add_option("", "--force", dest="force", metavar="boot_state",
29                                                 help="Force a boot state passed to BootManager.py.")
30         parser.add_option("", "--quiet", dest="quiet", action="store_true", 
31                                                 help="Extra quiet output messages.")
32         parser.add_option("", "--verbose", dest="verbose", action="store_true", 
33                                                 help="Extra debug output messages.")
34         parser.add_option("", "--nonet", dest="nonet", action="store_true", 
35                                                 help="Do not setup the network, use existing log files to re-run a test pass.")
36         parser.add_option("", "--collect", dest="collect", action="store_true", 
37                                                 help="No action, just collect dmesg, and bm.log")
38         parser.add_option("", "--nosetup", dest="nosetup", action="store_true", 
39                                                 help="Do not perform the orginary setup phase.")
40
41         parser = parsermodule.getParser(['nodesets', 'defaults'], parser)
42         config = parsermodule.parse_args(parser)
43
44         if config.nodelist:
45                 nodes = file.getListFromFile(config.nodelist)
46         elif config.node:
47                 nodes = [ config.node ]
48         else:
49                 parser.print_help()
50                 sys.exit(1)
51
52         for node in nodes:
53                 # get sitehist
54                 lb = plccache.plcdb_hn2lb[node]
55                 sitehist = SiteInterface.get_or_make(loginbase=lb)
56                 #reboot(node, config)
57                 restore(sitehist, node, config=None, forced_action=None)
58
59 if __name__ == "__main__":
60         main()