Exemple #1
0
 def render_GET(self, request):
   cmdStr = request.args['op'][0]
   name = request.args.get('name')[0]
   if cmdStr=='Console':
     clientip,pgName,psName = name.split(SEP)
     defQueue = defer.DeferredQueue(1,1)
     defQueue.get().addCallback(lambda x:request.write(getTemplateContent('consoleLog',psLabel='%s:%s'%(pgName,psName),logContent=x['content']))).addBoth(finishRequest,request)
     clientIpDict[clientip]['protocol'].asyncSendJson({'action':'procOp','op':'Console','grp':pgName,'name':psName},defQueue)
   else:      
     names = name.split(SEP)
     ip = names[0]
     msg = '%s remote://%s/%s/%s'%(cmdStr,ip,names[1],names[2])
     def delayRender(msg,alert='info'):
       flash = IFlash(request.getSession())
       flash.msg = msg
       flash.alert = alert
       request.redirect('/clientProc?ip=%s'%ip)
       finishRequest(None,request)
     if cmdStr=='Restart':
       clientIpDict[ip]['protocol'].sendJson(json.dumps({'action':'procOp','op':cmdStr,'grp':names[1],'name':names[2]}))
       reactor.callLater(0.5,delayRender,msg)
     elif cmdStr == 'Update':
       def procInfo(result,msg):
         yamContent = result[0][0]
         lp = LPConfig(yaml.load(yamContent))
         alert = 'info'
         if lp.fileUpdateInfo():
           clientIpDict[ip]['protocol'].sendJson(json.dumps({'action':'procOp','op':cmdStr,'grp':names[1],'name':names[2]}))
         else:
           msg += " invalid"
           alert = 'error'
         delayRender(msg,alert)
       getDb().runQuery('SELECT procInfo FROM Process WHERE clientIp = ? and procGroup = ? and procName = ?',\
       [ip,names[1],names[2]]).addCallback(procInfo,msg)
   return NOT_DONE_YET
Exemple #2
0
 def render_GET(self, request):
   flash = IFlash(request.getSession())
   currentIp = request.args.get('ip')
   if currentIp is None and len(clientIpDict)>0:
     currentIp = iter(clientIpDict.keys()).next()
   elif currentIp:
     currentIp = currentIp[0]
   def procList(result):
     procDict = {}
     for row in result:
       grpName,procName = [row[0],row[1]]
       uniName = uniqueProcName(currentIp,grpName,procName)
       procStatus = getStatus(uniName)
       procRow = [procName,procStatus['status'],fmtDate(procStatus['lastUpdated']),uniName,fmtDate(procStatus.get('fileUpdated')),]
       procGrp =  procDict.get(grpName)
       if procGrp is None:
         procGrp = [procRow]
         procDict[grpName] = procGrp
       else:
         procGrp.append(procRow)
     request.write(getTemplateContent('proc',clientSideArgs=self._initClientSideArgs(currentIp),\
       procDict=procDict,currentIp=currentIp,flash=flash,**activeCssDict))
     finishRequest(None,request,flash)
   getDb().runQuery('SELECT procGroup,procName FROM Process WHERE clientIp = ?',[currentIp]).addCallback(procList).addBoth(finishRequest,request)
   return NOT_DONE_YET
Exemple #3
0
 def render_GET(self, request):
   uniName = request.args.get('name')
   if uniName is None:request.redirect("/")
   ip,grpName,procName = splitProcName(uniName[0])
   def procInfo(result):
     yamContent = result[0][0]
     request.write(getTemplateContent('procConfInfo',clientSideArgs=self._initClientSideArgs(ip),\
       grpName=grpName,procName=procName,ip=ip,yamContent=yamContent,\
       monLog=getMonLog(uniName[0]),uniName=uniName[0],**activeCssDict))
   getDb().runQuery('SELECT procInfo FROM Process WHERE clientIp = ? and procGroup = ? and procName = ?',\
     [ip,grpName,procName]).addCallback(procInfo).addBoth(finishRequest,request)
   return NOT_DONE_YET
Exemple #4
0
 def render_POST(self, request):
   cmdStr = request.args['op'][0]
   ip = request.args.get('ip')[0]
   if cmdStr=='Remove':
     def removeDb(result):
       msg = 'Remove client %s'%(ip)
       del clientIpDict[ip]
       flash = IFlash(request.getSession())
       flash.msg = msg
       request.redirect('/client')
       finishRequest(None,request)
     getDb().runOperation('DELETE from Process where clientIp = ? ',[ip]).addCallback(removeDb)
   else:
     clientIpDict[ip]['protocol'].sendJson(json.dumps({'action':'clientOp','value':cmdStr}))
     msg = 'Send command %s to %s'%(cmdStr,ip)
     time.sleep(0.5)
     flash = IFlash(request.getSession())
     flash.msg = msg
     request.redirect('/client')
     finishRequest(None,request)
   return NOT_DONE_YET