00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 __facility__ = "Online"
00011 __abstract__ = "VSC controller to send simple actions"
00012 __author__ = "<perazzo@slac.stanford.edu> SLAC - GLAST LAT I&T/Online"
00013 __date__ = "2005/09/06"
00014 __updated__ = "$Date: 2006/03/16 22:53:03 $"
00015 __version__ = "$Revision: 1.5 $"
00016 __release__ = "$Name: HEAD $"
00017 __credits__ = "SLAC"
00018
00019 import LICOS.copyright_SLAC
00020
00021 import VSC
00022
00023 from LICOS.util.gOptions import Options
00024 from LICOS.tools.proxy.VscProxyTools import getip
00025
00026 import sys
00027
00028 VscCtrlPort = 3000
00029
00030 class Controller(VSC.VscProxy.Controller):
00031 def __init__(self, vschostname):
00032 ip_vsc = getip(vschostname)
00033 VSC.VscProxy.Controller.__init__(self, ip_vsc, VscCtrlPort)
00034
00035 def start(self, time=0):
00036 start = VSC.VscProxy.Scheduler(VSC.VscProxy.Start, time)
00037 self.execute(start)
00038
00039 def stop(self):
00040 stop = VSC.VscProxy.Scheduler(VSC.VscProxy.Stop)
00041 self.execute(stop)
00042
00043 def monprimary(self):
00044 cmd = VSC.VscProxy.Monitor(VSC.VscProxy.Primary)
00045 self.execute(cmd)
00046
00047 def monredundant(self):
00048 cmd = VSC.VscProxy.Monitor(VSC.VscProxy.Redundant)
00049 self.execute(cmd)
00050
00051 def monstop(self):
00052 cmd = VSC.VscProxy.Monitor(VSC.VscProxy.None)
00053 self.execute(cmd)
00054
00055
00056 if __name__ == '__main__':
00057 options = Options(['vscip', 'action'])
00058 try:
00059 options.parse()
00060 except Exception, msg:
00061 options.usage(str(msg))
00062 sys.exit()
00063
00064 Actions = {
00065 'start': 'start',
00066 'stop': 'stop',
00067 'monprimary': 'monprimary',
00068 'monredundant': 'monredundant',
00069 'monstop': 'monstop',
00070 }
00071 action = options.action
00072 vscip = options.vscip
00073 if action in Actions.keys():
00074 print 'Sending action \'%s\' to VSC' %(action)
00075 else:
00076 print '*** Action \'%s\' unknown, valid values for --action are: %s' \
00077 %(action, Actions.keys())
00078 sys.exit()
00079
00080 proxy = Controller(vscip)
00081 function = proxy.__class__.__dict__[action]
00082 function(proxy)