#!/usr/bin/python ''' Created on July 4, 2014 @author: Hovanes Egiyan ''' import os, sys import iocReboot import iocPortMap import procServMgr from iocPortMap import * from procServMgr import * if __name__ == '__main__': checkFile(app_exe) # init_env("/gluex/etc/hdonline.cshrc") functions = { "start" : procServMgr.start_ioc, "stop" : procServMgr.stop_ioc, "restart" : procServMgr.restart_ioc, } # Parsing the options usage = "usage: %prog [-h] [-p iocpath] [-c alt_config] [-i ioc_group] start|stop|restart" usage += "\n\t" usage += "\n\tstart - start iocs specified in config file" usage += "\n\tstop - stop iocs specified in config file" usage += "\n\trestart - stop and start iocs specified in config file" # usage += "" parser = OptionParser(usage) parser.add_option('-p', metavar='ioc_path', dest="path", help='Specify the iocBoot path (default: $CONFIG_DIR).') parser.add_option('-c', metavar='alt_config', dest="config", help='Specify the configuration file (default: $CONFIG_FILE).') parser.add_option('-i', metavar='ioc_group', dest="ioc", help='Specify the ioc group.') (options,args) = parser.parse_args() #print args, " check args[0]", args[0] not in functions.keys(), " len(args)=",len(args) if (len(args)!=1): parser.print_help() print sys.argv sys.exit("The command is missing.") if (args[0] not in functions.keys()): parser.print_help() sys.exit("Unknown command: "+args[0]) ioc='' debug_msg(1, "IOC = " + str(options.ioc)) if (options.ioc): if (options.ioc in iocGroupMap.keys()): debug_msg(1, options.ioc + " is in : iocGroupMap" + str(iocGroupMap[options.ioc])) ioc=options.ioc else: sys.exit("No such IOC group: " + options.ioc) for iocName in iocGroupMap[ioc] : print "Doing " + args[0] + " for " + iocName functions[args[0]](iocName) # sys.exit("The end of iocGroupServMgr.py script is reached.")