class NetStatHandler(WebHandler):

    AUTH_PROPS = "all"

    def web_createDBinstance(self):
            print "Create Instance"
            self.DB = SAMDB()
            print 'DB connected'

    def web_getData(self):
            self.DB = SAMDB()
            states = self.DB.getNetStat()['Value']
            print states
            result=[]
            for st in states:
              temp = {}
              temp['site'] = st[0]
              temp['host'] = st[1]
              temp['cetype'] = st[2]
              temp['avgping'] = float(st[3])
              temp['passed'] = float(st[4])
              temp['description'] = st[5]
#              temp['rate'] = trunc(int(st[2])*1.0/int(st[3]))
              result.append(temp)
            self.write({"result":result})
Пример #2
0
 def execute( self ):
   """ Main execution method
   """
   # Get list of running jobs
   dao = SAMDB()
   runningTests = dao.getRunningTests()['Value']
   # Leave only old
   testsToStop = []
   for test in runningTests:
     print test[2]
     if isTimeExceed(test[2], 600):
       testsToStop.append(test)
   # Send JobKill through REST
   for test in testsToStop:
     result = deleteJob(test[1])
     if result:
       dao.setResult('Fail', test[0], 'Failed after 10 min of silence')
   return S_OK()
class SAMHandler(WebHandler):

    AUTH_PROPS = "all"

    def web_getData(self):
        self.DB = SAMDB()
        states = self.DB.getState()['Value']
        result=[]
        for st in states:
            temp = {}
            temp['site'] = st[0]
            temp['test'] = st[1]
            temp['result'] = st[2]
            temp['received'] = st[3]
            temp['description'] = st[4]
            result.append(temp)
        self.write({"result":result})

    def selectFromDB(self, site, test):
        selectSQL = "SELECT R.last_update, R.state, R.description FROM Results R, Sites S, Tests T WHERE R.last_update > DATE_SUB(NOW(), INTERVAL 1 WEEK) AND R.site_id=S.Site_id AND R.test_id=T.test_id AND S.name='%s' AND T.name='%s'"%(site, test)
        result = self.DB._query( selectSQL )
        return result

    def web_getSiteMonthAvailability(self):
        self.DB = SAMDB()
        site = self.request.arguments['site'][0]
        test = self.request.arguments['test'][0]
        result = self.selectFromDB(site, test)
        if result['OK']:
            toSend = []
            for st in result['Value']:
                if st[1] in STATE_MAP:
                    temp = {}
                    temp['time'] = str(st[0])
                    temp['state'] = getStateNumber(st[1])
                    temp['description'] = st[2]
                    toSend.append(temp)
                  
            self.write({"result":toSend})
        else:
            print 'Error during selecting from DB'
    def web_getData(self):
            self.DB = SAMDB()
            states = self.DB.getDMSLatency()['Value']
            result=[]
            for st in states:
              temp = {}
              temp['site'] = st[0]
              temp['destination'] = st[1]
              temp['latency'] = float(st[2])
#              temp['rate'] = trunc(int(st[2])*1.0/int(st[3]))
              result.append(temp)
            self.write({"result":result})
 def web_getData(self):
     self.DB = SAMDB()
     states = self.DB.getState()['Value']
     result=[]
     for st in states:
         temp = {}
         temp['site'] = st[0]
         temp['test'] = st[1]
         temp['result'] = st[2]
         temp['received'] = st[3]
         temp['description'] = st[4]
         result.append(temp)
     self.write({"result":result})
    def web_getData(self):
            self.DB = SAMDB()
            states = self.DB.getNetStat()['Value']
            print states
            result=[]
            for st in states:
              temp = {}
              temp['site'] = st[0]
              temp['host'] = st[1]
              temp['cetype'] = st[2]
              temp['avgping'] = float(st[3])
              temp['passed'] = float(st[4])
              temp['description'] = st[5]
#              temp['rate'] = trunc(int(st[2])*1.0/int(st[3]))
              result.append(temp)
            self.write({"result":result})
 def web_getSiteMonthAvailability(self):
     self.DB = SAMDB()
     site = self.request.arguments['site'][0]
     test = self.request.arguments['test'][0]
     result = self.selectFromDB(site, test)
     if result['OK']:
         toSend = []
         for st in result['Value']:
             if st[1] in STATE_MAP:
                 temp = {}
                 temp['time'] = str(st[0])
                 temp['state'] = getStateNumber(st[1])
                 temp['description'] = st[2]
                 toSend.append(temp)
               
         self.write({"result":toSend})
     else:
         print 'Error during selecting from DB'
class DMSLatencyHandler(WebHandler):

    AUTH_PROPS = "all"

    def web_createDBinstance(self):
            print "Create Instance"
            self.DB = SAMDB()
            print 'DB connected'

    def web_getData(self):
            self.DB = SAMDB()
            states = self.DB.getDMSLatency()['Value']
            result=[]
            for st in states:
              temp = {}
              temp['site'] = st[0]
              temp['destination'] = st[1]
              temp['latency'] = float(st[2])
#              temp['rate'] = trunc(int(st[2])*1.0/int(st[3]))
              result.append(temp)
            self.write({"result":result})
Пример #9
0
  def execute( self ):
    """ Main execution method
    """
    self.log.info( "    TICK!!" )
    self.log.info( self.am_getOption("PollingTime") )
    # Get list of tests
    dao = SAMDB()
    testList = dao.getTestsToRun()['Value']
    print testList
    # Leave only old and Finished
    testsToRun = []
    for test in testList:
      self.log.info(str(test[3])+"  "+str(test[4]))
      self.log.info(str(getTimeNow())+"  "+str(long(test[3].strftime('%s'))))
      self.log.info(getTimeNow()-long(test[3].strftime('%s')))

      if isTimeExceed(test[3], test[4]):
        self.log.info(str(test[3])+"  "+str(test[4]))
        self.log.info(str(getTimeNow())+"  "+str(long(test[3].strftime('%s'))))
        self.log.info(getTimeNow()-long(test[3].strftime('%s')))
        testsToRun.append(test)
    # Create new Result db entity
    for test in testsToRun:
      result_id = dao.createNewResult(test[6], test[7])
      wms_id = sendJob(test[0], test[2], result_id['Value'])
      print 'wms_id ',  wms_id
      if wms_id != 0:
        dao.createJob(wms_id,test[6], result_id['Value'])
      else:
        dao.setResult('Fail', result_id['Value'], 'Failed to submit the job')
    # Try to send job
      #IF failed to get job_id - mark FAIL
      #NEXT
    # Create Job db entity
    # Update result
    return S_OK()
from DIRAC import S_OK, S_ERROR, gLogger, gConfig, exit
from DIRAC.Core.Base import Script
Script.parseCommandLine( ignoreErrors = False )

from DIRAC.FrameworkSystem.DB.SAMDB import SAMDB
x = SAMDB()

from pprint import pprint

result = x.addNewTest('WMS-test', 'wms_test.py', 3600, 3000, 'Check if site is able to execute SAM tests')
pprint(result)
x.addNewTest('CVMFS-test', 'cvmfs_test.py', 3600, 3000, 'Check if CVMFS is correct')
pprint(result)
x.addNewTest('BOSS-test', 'bossexe_test.py&boss.sh', 3600, 3000, 'Check the work of BOSS')
pprint(result)
 def web_createDBinstance(self):
         print "Create Instance"
         self.DB = SAMDB()
         print 'DB connected'