コード例 #1
0
    def submit(self):
        pagestart = time()
        RPC = getRPCClient("ResourceStatus/ResourceStatus")
        if request.params.has_key("siteName") and len(
                request.params["siteName"]) > 0:
            siteName = str(request.params["siteName"])
            RPC = getRPCClient("ResourceStatus/ResourceStatus")
            result = RPC.publisher('Site', siteName, 'Site_View')
#      return result
        else:
            result = {}
            result["OK"] = ""
            result["Message"] = "The parameter 'siteName' is absent"
        if result["OK"]:
            tmpResult = result["Value"]
            gLogger.info("\033[0;31m CALL RESPONSE: \033[0m %s" % tmpResult)
            result = {}
            #      try:
            for i in tmpResult:
                if i.has_key("Site_Panel"):
                    result["Site_Panel"] = {}
                    for j in i["Site_Panel"]:
                        if j.has_key("Res"):
                            result["Site_Panel"]["Stat"] = j["Res"]
                        if j.has_key("InfoForPanel"):
                            result["Site_Panel"]["Info"] = j["InfoForPanel"]
                if i.has_key("Service_Computing_Panel"):
                    result["Computing_Panel"] = {}
                    for j in i["Service_Computing_Panel"]:
                        if j.has_key("Res"):
                            result["Computing_Panel"]["Stat"] = j["Res"]
                        if j.has_key("InfoForPanel"):
                            result["Computing_Panel"]["Info"] = j[
                                "InfoForPanel"]
                if i.has_key("Service_Storage_Panel"):
                    result["Storage_Panel"] = {}
                    for j in i["Service_Storage_Panel"]:
                        if j.has_key("Res"):
                            result["Storage_Panel"]["Stat"] = j["Res"]
                        if j.has_key("InfoForPanel"):
                            result["Storage_Panel"]["Info"] = j["InfoForPanel"]
            if not result.has_key("Storage_Panel"):
                result["Storage_Panel"] = 'None'
#      except:
#        result = {}
#        result["OK"] = ""
#        result["Message"] = "Exception while parsing the service response 47-70"
        if result.has_key("Message"):
            c.result = {"success": "false", "error": result["Message"]}
        else:
            c.result = {"success": "true", "result": result}
        return c.result
コード例 #2
0
ファイル: Site.py プロジェクト: DIRACGrid/DIRACWeb
  def submit(self):
    pagestart = time()
    RPC = getRPCClient("ResourceStatus/ResourceStatus")
    if request.params.has_key("siteName") and len(request.params["siteName"]) > 0:
      siteName = str(request.params["siteName"])
      RPC = getRPCClient("ResourceStatus/ResourceStatus")
      result = RPC.publisher('Site', siteName, 'Site_View')
#      return result
    else:
      result = {}
      result["OK"] = ""
      result["Message"] = "The parameter 'siteName' is absent"
    if result["OK"]:
      tmpResult = result["Value"]
      gLogger.info("\033[0;31m CALL RESPONSE: \033[0m %s" % tmpResult)
      result = {}
#      try:
      for i in tmpResult:
        if i.has_key("Site_Panel"):
          result["Site_Panel"] = {}
          for j in i["Site_Panel"]:
            if j.has_key("Res"):
              result["Site_Panel"]["Stat"] = j["Res"]
            if j.has_key("InfoForPanel"):
              result["Site_Panel"]["Info"] = j["InfoForPanel"]
        if i.has_key("Service_Computing_Panel"):
          result["Computing_Panel"] = {}
          for j in i["Service_Computing_Panel"]:
            if j.has_key("Res"):
              result["Computing_Panel"]["Stat"] = j["Res"]
            if j.has_key("InfoForPanel"):
              result["Computing_Panel"]["Info"] = j["InfoForPanel"]
        if i.has_key("Service_Storage_Panel"):
          result["Storage_Panel"] = {}
          for j in i["Service_Storage_Panel"]:
            if j.has_key("Res"):
              result["Storage_Panel"]["Stat"] = j["Res"]
            if j.has_key("InfoForPanel"):
              result["Storage_Panel"]["Info"] = j["InfoForPanel"]
      if not result.has_key("Storage_Panel"):
        result["Storage_Panel"] = 'None'
#      except:
#        result = {}
#        result["OK"] = ""
#        result["Message"] = "Exception while parsing the service response 47-70"
    if result.has_key("Message"):
      c.result = {"success":"false","error":result["Message"]}
    else:
      c.result = {"success":"true","result":result}
    return c.result
コード例 #3
0
ファイル: monitor.py プロジェクト: yant-ihepcc/BESDIRAC
    def req(self):
        result_of_files = {'num': 0, 'data': []}
        if not request.params.has_key("req_id"):
            return result_of_files
        try:
            reqid = int(request.params["req_id"])
        except ValueError:
            return result_of_files

        RPC = getRPCClient("Transfer/TransferRequest")
        cond = {"trans_req_id": reqid}
        res = RPC.show(cond)
        if not res["OK"]:
            return result_of_files
        result = res["Value"]

        def quickconv(d):
            from datetime import datetime
            # submit time is the 5th.
            return dict(
                zip(
                    TransFileListEntryWithID._fields,
                    tuple(
                        r.strftime("%Y-%m-%d %H:%M [UTC]"
                                   ) if isinstance(r, datetime) else r
                        for r in d)))

        result = map(quickconv, result)

        result_of_files["num"] = len(result)
        result_of_files["data"] = result

        return result_of_files
コード例 #4
0
ファイル: datasets.py プロジェクト: hanyl/belle2DIRAC
 def getSiteList(self, dataset=None):
     #XXX - remove sites with no SE
     callback = {}
     if dataset is None:
         #RPC = getRPCClient("ResourceStatus/ResourceStatus")
         RPC = getRPCClient("WorkloadManagement/JobMonitoring")
         #result = RPC.getSitesStatusList()
         result = RPC.getSites()
         print result
         gLogger.info("\033[0;31m LIST: \033[0m %s" % result)
         if result["OK"]:
             response = []
             if len(result["Value"]) > 0:
                 sites = []
                 result["Value"].remove("ANY")
                 for site in result['Value']:
                     sites.append({'sitename': site})
                 callback['Value'] = sites
                 return callback
             else:
                 response = [["Nothing to display"]]
         else:
             response = [["Error during RPC call"]]
         return {"success": "true", "result": response}
     else:
         pass
コード例 #5
0
 def getPlotData( self ):
   retVal = self.__parseFormParams()
   if not retVal[ 'OK' ]:
     c.error = retVal[ 'Message' ]
     return render( "/error.mako" )
   params = retVal[ 'Value' ]
   repClient = ReportsClient( rpcClient = getRPCClient( "Accounting/ReportGenerator" ) )
   retVal = repClient.getReport( *params )
   if not retVal[ 'OK' ]:
     c.error = retVal[ 'Message' ]
     return render( "/error.mako" )
   rawData = retVal[ 'Value' ]
   groupKeys = rawData[ 'data' ].keys()
   groupKeys.sort()
   if 'granularity' in rawData:
     granularity = rawData[ 'granularity' ]
     data = rawData['data']
     tS = int( Time.toEpoch( params[2] ) )
     timeStart = tS - tS % granularity
     strData = "epoch,%s\n" % ",".join( groupKeys )
     for timeSlot in range( timeStart, int( Time.toEpoch( params[3] ) ), granularity ):
       lineData = [ str( timeSlot ) ]
       for key in groupKeys:
         if timeSlot in data[ key ]:
           lineData.append( str( data[ key ][ timeSlot ] ) )
         else:
           lineData.append( "" )
       strData += "%s\n" % ",".join( lineData )
   else:
     strData = "%s\n" % ",".join( groupKeys )
     strData += ",".join( [ str( rawData[ 'data' ][ k ] ) for k in groupKeys ] )
   response.headers['Content-type'] = 'text/csv'
   response.headers['Content-Disposition'] = 'attachment; filename="%s.csv"' % md5( str( params ) ).hexdigest()
   response.headers['Content-Length'] = len( strData )
   return strData
コード例 #6
0
    def datasets(self):
        result_of_reqs = {'num': 0, 'data': []}
        RPC = getRPCClient("Transfer/Dataset")

        cond = {}
        res = RPC.showtotal(cond)

        if not res["OK"]:
            return result_of_reqs
        result_of_reqs["num"] = res["Value"]

        # get start/limit
        start = 0
        limit = result_of_reqs["num"]
        orderby = ["id:DESC"]

        if request.params.has_key("start"):
            start = int(request.params["start"])
        if request.params.has_key("limit"):
            limit = int(request.params["limit"])

        res = RPC.show(cond, orderby, start, limit)
        if not res["OK"]:
            gLogger.error(res)
            return result_of_reqs
        result = res["Value"]

        result_of_reqs["data"] = [
            dict(zip(DatasetEntryWithID._fields, r)) for r in result
        ]

        return result_of_reqs
コード例 #7
0
ファイル: SiteGateway.py プロジェクト: DIRACGrid/DIRACWeb
  def __getSelectionData(self):
    callback = {}
    lhcbGroup = credentials.getSelectedGroup()
    lhcbUser = str(credentials.getUsername())
    RPC = getRPCClient( "ResourceStatus/ResourceStatus" )
    client = ResourceStatusClient( serviceIn = RPC )
    if len(request.params) > 0:
      tmp = {}
      for i in request.params:
        tmp[i] = str(request.params[i])
      callback["extra"] = tmp
####
    result = client.getSitePresent( meta = { 'columns' : 'SiteName' } )
    if result["OK"]:
      sites = result["Value"]
      try:
        sites = list(sites)
      except Exception,x:
        gLogger.error("Exception during convertion to a list: %s" % str(x))
        sites = [] # Will return error on length check
      tier1 = gConfig.getValue("/Website/PreferredSites",[]) # Always return a list
      if len(sites)>0:
        tier1.reverse()
        tier1 = [[x] for x in tier1]
        sites = [x for x in sites if x not in tier1] # Removes sites which are in tier1 list
        for i in tier1:
          sites.insert(0,i)
        sites.insert(0,["All"])
      else:
        sites = [["Nothing to display"]]
コード例 #8
0
  def getViewsList( self ):
    try:
      start = int( request.params[ 'start' ] )
    except:
      start = 0
    try:
      limit = int( request.params[ 'limit' ] )
    except:
      limit = 0

    try:
      sortField = str( request.params[ 'sortField' ] )
      sortDir = str( request.params[ 'sortDirection' ] )
      sort = [ ( sortField, sortDir ) ]
    except:
      sort = []
    rpcClient = getRPCClient( "Framework/Monitoring" )
    retVal = rpcClient.getViews( False )
    if not retVal[ 'OK' ]:
      return retVal
    svcData = retVal[ 'Value' ]
    data = { 'numViews' : len( svcData ), 'views' : [] }
    for record in svcData[ start : start + limit ]:
      data[ 'views' ].append( { 'id': record[0],
                                'name' : record[1],
                                'variableData' : record[2], } )
    return data
コード例 #9
0
ファイル: JobMonitor.py プロジェクト: nikolalazovski/DIRACWeb
 def submit(self):
   pagestart = time()
   RPC = getRPCClient("WorkloadManagement/JobMonitoring")
   user = str(credentials.getUsername())
   result = RPC.getOwners()
   if result["OK"]:
     defaultGroup = gConfig.getValue("/Registry/DefaultGroup","")
     if defaultGroup == "":
       return {"success":"false","error":"Option /Registry/DefaultGroup is undefined, please set the default group in the CS"}
     group = str(credentials.getSelectedGroup())
     groupProperty = credentials.getProperties(group)
     if user not in result["Value"] and ( "JobAdministrator" or "JobSharing" ) not in groupProperty:
       c.result = {"success":"false","error":"You don't have any jobs in the DIRAC system"}
       return c.result
   else:
     c.result = {"success":"false","error":result["Message"]}
     return c.result
   req = self.__request()
   gLogger.always("getJobPageSummaryWeb(%s,%s,%s,%s)" % (req,globalSort,pageNumber,numberOfJobs))
   result = RPC.getJobPageSummaryWeb(req,globalSort,pageNumber,numberOfJobs)
   gLogger.always(" - REZ: " %result)
   if result["OK"]:
     result = result["Value"]
     gLogger.info("ReS",result)
     if result.has_key("TotalRecords"):
       if  result["TotalRecords"] > 0:
         if result.has_key("ParameterNames") and result.has_key("Records"):
           if len(result["ParameterNames"]) > 0:
             if len(result["Records"]) > 0:
               c.result = []
               jobs = result["Records"]
               head = result["ParameterNames"]
               headLength = len(head)
               for i in jobs:
                 tmp = {}
                 for j in range(0,headLength):
                   tmp[head[j]] = i[j]
                 c.result.append(tmp)
               total = result["TotalRecords"]
               timestamp = Time.dateTime().strftime("%Y-%m-%d %H:%M [UTC]")
               if result.has_key("Extras"):
                 st = self.__dict2string(req)
                 extra = result["Extras"]
                 c.result = {"success":"true","result":c.result,"total":total,"extra":extra,"request":st,"date":timestamp}
               else:
                 c.result = {"success":"true","result":c.result,"total":total,"date":timestamp}
             else:
               c.result = {"success":"false","result":"","error":"There are no data to display"}
           else:
             c.result = {"success":"false","result":"","error":"ParameterNames field is missing"}
         else:
           c.result = {"success":"false","result":"","error":"Data structure is corrupted"}
       else:
         c.result = {"success":"false","result":"","error":"There were no data matching your selection"}
     else:
       c.result = {"success":"false","result":"","error":"Data structure is corrupted"}
   else:
     c.result = {"success":"false","error":result["Message"]}
   gLogger.info("\033[0;31mJOB SUBMIT REQUEST:\033[0m %s" % (time() - pagestart))
   return c.result
コード例 #10
0
  def getActivitiesList( self ):
    try:
      start = int( request.params[ 'start' ] )
    except:
      start = 0
    try:
      limit = int( request.params[ 'limit' ] )
    except:
      limit = 0

    try:
      sortField = str( request.params[ 'sortField' ] ).replace( "_", "." )
      sortDir = str( request.params[ 'sortDirection' ] )
      sort = [ ( sortField, sortDir ) ]
    except:
      sort = []
    rpcClient = getRPCClient( "Framework/Monitoring" )
    retVal = rpcClient.getActivitiesContents( {}, sort, start, limit )
    if not retVal[ 'OK' ]:
      return retVal
    svcData = retVal[ 'Value' ]
    data = { 'numActivities' : svcData[ 'TotalRecords' ], 'activities' : [] }
    now = Time.toEpoch()
    for record in svcData[ 'Records' ]:
      formatted = {}
      for i in range( len( svcData[ 'Fields' ] ) ):
        formatted[ svcData[ 'Fields' ][i].replace( ".", "_" ) ] = record[i]
      if 'activities_lastUpdate' in formatted:
        formatted[ 'activities_lastUpdate' ] = now - int( formatted[ 'activities_lastUpdate' ] )
      data[ 'activities' ].append( formatted )
    return data
コード例 #11
0
 def getHistoryValues(self):
     try:
         dbVars = [str(f) for f in simplejson.loads(request.params['vars'])]
     except:
         dbVars = ['Load', 'Jobs', 'TransferredFiles']
     try:
         timespan = int(request.params['timespan'])
     except:
         timespan = 86400
     rpcClient = getRPCClient("WorkloadManagement/VirtualMachineManager")
     result = rpcClient.getHistoryValues(3600, {}, dbVars, timespan)
     if not result['OK']:
         return S_ERROR(result['Message'])
     svcData = result['Value']
     data = []
     olderThan = Time.toEpoch() - 400
     for record in svcData['Records']:
         rL = []
         for iP in range(len(svcData['ParameterNames'])):
             param = svcData['ParameterNames'][iP]
             if param == 'Update':
                 rL.append(Time.toEpoch(record[iP]))
             else:
                 rL.append(record[iP])
         if rL[0] < olderThan:
             data.append(rL)
     return S_OK({'data': data, 'fields': svcData['ParameterNames']})
コード例 #12
0
ファイル: monitor.py プロジェクト: besdiracgrid/BESDIRAC
    def req(self):
        result_of_files = {"num": 0, "data": []}
        if not request.params.has_key("req_id"):
            return result_of_files
        try:
            reqid = int(request.params["req_id"])
        except ValueError:
            return result_of_files

        RPC = getRPCClient("Transfer/TransferRequest")
        cond = {"trans_req_id": reqid}
        res = RPC.show(cond)
        if not res["OK"]:
            return result_of_files
        result = res["Value"]

        def quickconv(d):
            from datetime import datetime

            # submit time is the 5th.
            return dict(
                zip(
                    TransFileListEntryWithID._fields,
                    tuple(r.strftime("%Y-%m-%d %H:%M [UTC]") if isinstance(r, datetime) else r for r in d),
                )
            )

        result = map(quickconv, result)

        result_of_files["num"] = len(result)
        result_of_files["data"] = result

        return result_of_files
コード例 #13
0
 def getPlotListAndSelectionValues(self):
     result = {}
     try:
         typeName = str(request.params['typeName'])
     except:
         return S_ERROR("Missing or invalid type name!")
     retVal = self.__getUniqueKeyValues(typeName)
     if not retVal['OK'] and 'rpcStub' in retVal:
         del (retVal['rpcStub'])
         return retVal
     selectionValues = retVal['Value']
     data = AccountingplotsController.__keysCache.get("reportsList:%s" %
                                                      typeName)
     if not data:
         repClient = ReportsClient(
             rpcClient=getRPCClient("Accounting/ReportGenerator"))
         retVal = repClient.listReports(typeName)
         if not retVal['OK']:
             return retVal
         data = simplejson.dumps(retVal['Value'])
         AccountingplotsController.__keysCache.add(
             "reportsList:%s" % typeName, 300, data)
     try:
         plotsList = eval(data)
     except:
         return S_ERROR('Failed to convert a string to a list!')
     return S_OK({'SelectionData': selectionValues, 'PlotList': plotsList})
コード例 #14
0
ファイル: virtualmachines.py プロジェクト: acasajus/VMDIRAC
 def getHistoryValues( self ):
   try:
     dbVars = [ str( f ) for f in simplejson.loads( request.params[ 'vars' ] ) ]
   except:
     dbVars = [ 'Load', 'Jobs', 'TransferredFiles' ]
   try:
     timespan = int( request.params[ 'timespan' ] )
   except:
     timespan = 86400
   rpcClient = getRPCClient( "WorkloadManagement/VirtualMachineManager" )
   result = rpcClient.getHistoryValues( 3600, {}, dbVars, timespan )
   if not result[ 'OK' ]:
     return S_ERROR( result[ 'Message' ] )
   svcData = result[ 'Value' ]
   data = []
   olderThan = Time.toEpoch() - 400
   for record in svcData[ 'Records' ]:
     rL = []
     for iP in range( len( svcData[ 'ParameterNames' ] ) ):
       param = svcData[ 'ParameterNames' ][iP]
       if param == 'Update':
         rL.append( Time.toEpoch( record[iP] ) )
       else:
         rL.append( record[iP] )
     if rL[0] < olderThan:
       data.append( rL )
   return S_OK( { 'data': data, 'fields' : svcData[ 'ParameterNames' ] } )
コード例 #15
0
    def __getUniqueKeyValues(self, typeName):
        userGroup = getSelectedGroup()
        if 'NormalUser' in CS.getPropertiesForGroup(userGroup):
            cacheKey = (getUserName(), userGroup, getSelectedSetup(), typeName)
        else:
            cacheKey = (userGroup, getSelectedSetup(), typeName)
        data = AccountingplotsController.__keysCache.get(cacheKey)
        if not data:
            rpcClient = getRPCClient("Accounting/ReportGenerator")
            retVal = rpcClient.listUniqueKeyValues(typeName)
            if 'rpcStub' in retVal:
                del (retVal['rpcStub'])
            if not retVal['OK']:
                return retVal

            #Site ordering based on TierLevel / alpha
            if 'Site' in retVal['Value']:
                siteLevel = {}
                for siteName in retVal['Value']['Site']:
                    sitePrefix = siteName.split(".")[0].strip()
                    level = gConfig.getValue(
                        "/Resources/Sites/%s/%s/MoUTierLevel" %
                        (sitePrefix, siteName), 10)
                    if level not in siteLevel:
                        siteLevel[level] = []
                    siteLevel[level].append(siteName)
                orderedSites = []
                for level in sorted(siteLevel):
                    orderedSites.extend(sorted(siteLevel[level]))
                retVal['Value']['Site'] = orderedSites
            data = retVal
            AccountingplotsController.__keysCache.add(cacheKey, 300, data)
        return data
コード例 #16
0
ファイル: MetaCatalogue.py プロジェクト: msapunov/DIRACWeb
 def __request(self):
   req = {}  
   global R_NUMBER
   global P_NUMBER
   R_NUMBER = 25
   if request.params.has_key("limit") and len(request.params["limit"]) > 0:
     R_NUMBER = int(request.params["limit"])
   P_NUMBER = 0
   if request.params.has_key("start") and len(request.params["start"]) > 0:
     P_NUMBER = int(request.params["start"])
   result = gConfig.getOption("/Website/ListSeparator")
   if result["OK"]:
     separator = result["Value"]
   else:
     separator = ":::"
   RPC = getRPCClient("DataManagement/FileCatalog")
   result = RPC.getMetadataFields()
   gLogger.always(" +++ ",result)
   if not result["OK"]:
     return {}
   result = result["Value"]
   meta = []
   for key,value in result.items():
     for j in value:
       meta.append(j)
   gLogger.always(" * * * ",meta)
   for i in request.params:
     if i in meta:
       meta_list = str(request.params[i]).split(separator)
       if len(meta_list) == 1:
         meta_list = meta_list[0]
       req[i] = meta_list
   gLogger.always(" * * * ",req)
   return req
コード例 #17
0
ファイル: ProductionMonitor.py プロジェクト: sfayer/DIRACWeb
 def __fileRetry(self, prodid, mode):
     id = int(prodid)
     RPC = getRPCClient("Transformation/TransformationManager")
     if mode == "proc":
         res = RPC.getTransformationFilesCount(prodid, "ErrorCount", {"Status": "Processed"})
     elif mode == "not":
         res = RPC.getTransformationFilesCount(prodid, "ErrorCount", {"Status": ["Unused", "Assigned", "Failed"]})
     elif mode == "all":
         res = RPC.getTransformationFilesCount(prodid, "ErrorCount")
     else:
         return {"success": "false", "error": res["Message"]}
     if not res["OK"]:
         c.result = {"success": "false", "error": res["Message"]}
     else:
         resList = []
         total = res["Value"].pop("Total")
         if total == 0:
             c.result = {"success": "false", "error": "No files found"}
         else:
             for status in sortList(res["Value"].keys()):
                 count = res["Value"][status]
                 percent = "%.1f" % ((count * 100.0) / total)
                 resList.append((status, str(count), percent))
             resList.append(("Total", total, "-"))
             c.result = {"success": "true", "result": resList}
     gLogger.info("#######", res)
     return c.result
コード例 #18
0
ファイル: acct.py プロジェクト: atsareg/BESDIRAC
  def __getUniqueKeyValues( self, typeName ):
    userGroup = getSelectedGroup()
    if 'NormalUser' in CS.getPropertiesForGroup( userGroup ):
      cacheKey = ( getUsername(), userGroup, getSelectedSetup(), typeName )
    else:
      cacheKey = ( userGroup, getSelectedSetup(), typeName )
    data = AcctController.__keysCache.get( cacheKey )
    if not data:
      rpcClient = getRPCClient( "Accounting/ReportGenerator" )
      retVal = rpcClient.listUniqueKeyValues( typeName )
      if 'rpcStub' in retVal:
        del( retVal[ 'rpcStub' ] )
      if not retVal[ 'OK' ]:
        return retVal

      #Site ordering based on TierLevel / alpha
      if 'Site' in retVal[ 'Value' ]:
        siteLevel = {}
        for siteName in retVal[ 'Value' ][ 'Site' ]:
          sitePrefix = siteName.split( "." )[0].strip()
          level = gConfig.getValue( "/Resources/Sites/%s/%s/MoUTierLevel" % ( sitePrefix, siteName ), 10 )
          if level not in siteLevel:
            siteLevel[ level ] = []
          siteLevel[ level ].append( siteName )
        orderedSites = []
        for level in sorted( siteLevel ):
          orderedSites.extend( sorted( siteLevel[ level ] ) )
        retVal[ 'Value' ][ 'Site' ] = orderedSites
      data = retVal
      AcctController.__keysCache.add( cacheKey, 300, data )
    return data
コード例 #19
0
 def __logProduction(self, prodid):
     id = int(prodid)
     RPC = getRPCClient("Transformation/TransformationManager")
     result = RPC.getTransformationLogging(id)
     if result["OK"]:
         result = result["Value"]
         if len(result) > 0:
             c.result = []
             resultUser = gConfig.getSections("/Security/Users")
             if resultUser["OK"]:
                 users = resultUser["Value"]
                 dndb = {}
                 for j in users:
                     dndb[gConfig.getValue("/Security/Users/%s/DN" % j)] = j
             else:
                 dndb = {}
             for i in result:
                 DN = i["AuthorDN"]
                 if dndb.has_key(DN):
                     i["AuthorDN"] = dndb[DN]
                 else:
                     i["AuthorDN"] = DN  #"Owner Unknown"
                 date = Time.toString(i["MessageDate"])
                 c.result.append([i["Message"], i["AuthorDN"], date])
             c.result = {"success": "true", "result": c.result}
         else:
             c.result = {"success": "false", "error": "Nothing to display"}
     else:
         c.result = {"success": "false", "error": result["Message"]}
     gLogger.info("PRODUCTION LOG:", id)
     return c.result
コード例 #20
0
    def __globalStatJob(self, siteName):

        RPC = getRPCClient("WorkloadManagement/JobMonitoring")
        result = RPC.getStates()
        stat = []
        if result["OK"] and len(result["Value"]) > 0:
            for i in result["Value"]:
                stat.append(str(i))
        result = RPC.getJobPageSummaryWeb({'Site': [siteName]},
                                          [["JobID", "DESC"]], 0, 1, False)
        if result["OK"]:
            result = result["Value"]
            back = []
            if result.has_key("Extras"):
                extra = result["Extras"]
                if len(stat) > 0:
                    for i in sortList(stat):
                        if i in sortList(extra.keys()):
                            back.append([i, extra[i]])
                        else:
                            back.append([i, "-"])
                else:
                    for i in sortList(extra.keys()):
                        back.append([i, extra[i]])
            c.result = {"success": "true", "result": back}
            c.result = back
        else:
            c.result = {"success": "false", "error": result["Message"]}
        gLogger.info("\033[0;31m R E S U L T: \033[0m", c.result)
        return c.result
コード例 #21
0
 def __fileRetry(self,prodid,mode):
   id = int(prodid)
   RPC = getRPCClient('Transformation/TransformationManager')
   if mode == "proc":
     res = RPC.getTransformationFilesCount(prodid,"ErrorCount",{'Status':'Processed'})
   elif mode == "not":
     res = RPC.getTransformationFilesCount(prodid,"ErrorCount",{'Status':['Unused','Assigned','Failed']})
   elif mode == "all":
     res = RPC.getTransformationFilesCount(prodid,"ErrorCount")
   else:
     return {"success":"false","error":res["Message"]}
   if not res['OK']:
     c.result = {"success":"false","error":res["Message"]}
   else:
     resList = []
     total = res['Value'].pop('Total')
     if total == 0:
       c.result = {"success":"false","error":"No files found"}
     else:
       for status in sortList(res['Value'].keys()):
         count = res['Value'][status]
         percent = "%.1f" % ((count*100.0)/total)
         resList.append((status,str(count),percent))
       resList.append(('Total',total,'-'))
       c.result = {"success":"true","result":resList}
   gLogger.info("#######",res)
   return c.result
コード例 #22
0
    def getViewsList(self):
        try:
            start = int(request.params['start'])
        except:
            start = 0
        try:
            limit = int(request.params['limit'])
        except:
            limit = 0

        try:
            sortField = str(request.params['sortField'])
            sortDir = str(request.params['sortDirection'])
            sort = [(sortField, sortDir)]
        except:
            sort = []
        rpcClient = getRPCClient("Framework/Monitoring")
        retVal = rpcClient.getViews(False)
        if not retVal['OK']:
            return retVal
        svcData = retVal['Value']
        data = {'numViews': len(svcData), 'views': []}
        for record in svcData[start:start + limit]:
            data['views'].append({
                'id': record[0],
                'name': record[1],
                'variableData': record[2],
            })
        return data
コード例 #23
0
ファイル: RequestMonitor.py プロジェクト: acasajus/DIRACWeb
  def submit(self):
    RPC = getRPCClient("RequestManagement/centralURL")
    result = self.__request()
    result = RPC.getRequestSummaryWeb(result,globalSort,pageNumber,numberOfJobs)
    if result["OK"]:
      result = result["Value"]
      gLogger.info("\033[0;31mRESULT:\033[0m %s" % result["ParameterNames"])
      if result.has_key("ParameterNames") and result.has_key("Records"):
        if len(result["ParameterNames"]) > 0:
          if len(result["Records"]) > 0:
            c.result = []
            jobs = result["Records"]
            head = result["ParameterNames"]
            headLength = len(head)
            for i in jobs:
              tmp = {}
              for j in range(0,headLength):
                if j == 2:
                  if i[j] == "None":
                    i[j] = "-"
                tmp[head[j]] = i[j]
              c.result.append(tmp)
            total = result["TotalRecords"]
            gLogger.info(" c.result ",c.result)
            c.result = {"success":"true","result":c.result,"total":total}
          else:
            c.result = {"success":"false","result":"","error":"There are no data to display"}
        else:
          c.result = {"success":"false","result":"","error":"ParameterNames field is missing"}
      else:
        c.result = {"success":"false","result":"","error":"Data structure is corrupted"}
    else:
      c.result = {"success":"false","error":result["Message"]}
#    gLogger.info("\033[0;31mRESULT:\033[0m ")
    return c.result
コード例 #24
0
ファイル: ProductionMonitor.py プロジェクト: sfayer/DIRACWeb
 def __logProduction(self, prodid):
     id = int(prodid)
     RPC = getRPCClient("Transformation/TransformationManager")
     result = RPC.getTransformationLogging(id)
     if result["OK"]:
         result = result["Value"]
         if len(result) > 0:
             c.result = []
             resultUser = gConfig.getSections("/Security/Users")
             if resultUser["OK"]:
                 users = resultUser["Value"]
                 dndb = {}
                 for j in users:
                     dndb[gConfig.getValue("/Security/Users/%s/DN" % j)] = j
             else:
                 dndb = {}
             for i in result:
                 DN = i["AuthorDN"]
                 if dndb.has_key(DN):
                     i["AuthorDN"] = dndb[DN]
                 else:
                     i["AuthorDN"] = DN  # "Owner Unknown"
                 date = Time.toString(i["MessageDate"])
                 c.result.append([i["Message"], i["AuthorDN"], date])
             c.result = {"success": "true", "result": c.result}
         else:
             c.result = {"success": "false", "error": "Nothing to display"}
     else:
         c.result = {"success": "false", "error": result["Message"]}
     gLogger.info("PRODUCTION LOG:", id)
     return c.result
コード例 #25
0
    def getActivitiesList(self):
        try:
            start = int(request.params['start'])
        except:
            start = 0
        try:
            limit = int(request.params['limit'])
        except:
            limit = 0

        try:
            sortField = str(request.params['sortField']).replace("_", ".")
            sortDir = str(request.params['sortDirection'])
            sort = [(sortField, sortDir)]
        except:
            sort = []
        rpcClient = getRPCClient("Framework/Monitoring")
        retVal = rpcClient.getActivitiesContents({}, sort, start, limit)
        if not retVal['OK']:
            return retVal
        svcData = retVal['Value']
        data = {'numActivities': svcData['TotalRecords'], 'activities': []}
        now = Time.toEpoch()
        for record in svcData['Records']:
            formatted = {}
            for i in range(len(svcData['Fields'])):
                formatted[svcData['Fields'][i].replace(".", "_")] = record[i]
            if 'activities_lastUpdate' in formatted:
                formatted['activities_lastUpdate'] = now - int(
                    formatted['activities_lastUpdate'])
            data['activities'].append(formatted)
        return data
コード例 #26
0
 def __fileRetry(self, prodid, mode):
     id = int(prodid)
     RPC = getRPCClient('Transformation/TransformationManager')
     if mode == "proc":
         res = RPC.getTransformationFilesCount(prodid, "ErrorCount",
                                               {'Status': 'Processed'})
     elif mode == "not":
         res = RPC.getTransformationFilesCount(
             prodid, "ErrorCount",
             {'Status': ['Unused', 'Assigned', 'Failed']})
     elif mode == "all":
         res = RPC.getTransformationFilesCount(prodid, "ErrorCount")
     else:
         return {"success": "false", "error": res["Message"]}
     if not res['OK']:
         c.result = {"success": "false", "error": res["Message"]}
     else:
         resList = []
         total = res['Value'].pop('Total')
         if total == 0:
             c.result = {"success": "false", "error": "No files found"}
         else:
             for status in sortList(res['Value'].keys()):
                 count = res['Value'][status]
                 percent = "%.1f" % ((count * 100.0) / total)
                 resList.append((status, str(count), percent))
             resList.append(('Total', total, '-'))
             c.result = {"success": "true", "result": resList}
     gLogger.info("#######", res)
     return c.result
コード例 #27
0
ファイル: dataset.py プロジェクト: atsareg/BESDIRAC
  def datasets(self):
    result_of_reqs = {'num': 0, 'data': []}
    RPC = getRPCClient("Transfer/Dataset")

    cond = {}
    res = RPC.showtotal(cond)

    if not res["OK"]:
      return result_of_reqs
    result_of_reqs["num"] = res["Value"]
    
    # get start/limit
    start = 0
    limit = result_of_reqs["num"]
    orderby = ["id:DESC"]

    if request.params.has_key("start"):
      start = int(request.params["start"])
    if request.params.has_key("limit"):
      limit = int(request.params["limit"])

    res = RPC.show(cond, orderby, start, limit)
    if not res["OK"]:
      gLogger.error(res)
      return result_of_reqs
    result = res["Value"]

    result_of_reqs["data"] = [dict(zip(DatasetEntryWithID._fields, r)) for r in result]

    return result_of_reqs
コード例 #28
0
ファイル: ErrorConsole.py プロジェクト: DIRACGrid/DIRACWeb
  def submit( self ):
    RPC = getRPCClient( "Framework/SystemLoggingReport" )
    result = self.__request()
    result = RPC.getGroupedMessages( result, globalSort, pageNumber, numberOfJobs )
    gLogger.info( "- REQUEST:", result )
    if result["OK"]:
      result = result["Value"]
      c.result = []
      jobs = result["Records"]
      if result.has_key( "ParameterNames" ) and result.has_key( "Records" ):
        if len( result["ParameterNames"] ) > 0:
          if len( result["Records"] ) > 0:
            c.result = []
            jobs = result["Records"]
            head = result["ParameterNames"]
            headLength = len( head )
            for i in jobs:
              tmp = {}
              for j in range( 0, headLength ):
                tmp[head[j]] = i[j]
              c.result.append( tmp )
            total = result["TotalRecords"]
            timestamp = Time.dateTime().strftime("%Y-%m-%d %H:%M [UTC]")
#            c.result = {"success":"true", "result":c.result, "total":total,"date":timestamp}
            c.result = {"success":"true", "result":c.result, "total":total}
          else:
            c.result = {"success":"false", "result":"", "error":"There are no data to display"}
        else:
          c.result = {"success":"false", "result":"", "error":"ParameterNames field is missing"}
      else:
        c.result = {"success":"false", "result":"", "error":"Data structure is corrupted"}
    else:
      c.result = {"success":"false", "error":result["Message"]}
    gLogger.info( "\033[0;31mRESULT:\033[0m" )
    return c.result
コード例 #29
0
ファイル: acct.py プロジェクト: atsareg/BESDIRAC
 def getPlotData( self ):
   retVal = self.__parseFormParams()
   if not retVal[ 'OK' ]:
     c.error = retVal[ 'Message' ]
     return render( "/error.mako" )
   params = retVal[ 'Value' ]
   repClient = ReportsClient( rpcClient = getRPCClient( "Accounting/ReportGenerator" ) )
   retVal = repClient.getReport( *params )
   if not retVal[ 'OK' ]:
     c.error = retVal[ 'Message' ]
     return render( "/error.mako" )
   rawData = retVal[ 'Value' ]
   groupKeys = rawData[ 'data' ].keys()
   groupKeys.sort()
   if 'granularity' in rawData:
     granularity = rawData[ 'granularity' ]
     data = rawData['data']
     tS = int( Time.toEpoch( params[2] ) )
     timeStart = tS - tS % granularity
     strData = "epoch,%s\n" % ",".join( groupKeys )
     for timeSlot in range( timeStart, int( Time.toEpoch( params[3] ) ), granularity ):
       lineData = [ str( timeSlot ) ]
       for key in groupKeys:
         if timeSlot in data[ key ]:
           lineData.append( str( data[ key ][ timeSlot ] ) )
         else:
           lineData.append( "" )
       strData += "%s\n" % ",".join( lineData )
   else:
     strData = "%s\n" % ",".join( groupKeys )
     strData += ",".join( [ str( rawData[ 'data' ][ k ] ) for k in groupKeys ] )
   response.headers['Content-type'] = 'text/csv'
   response.headers['Content-Disposition'] = 'attachment; filename="%s.csv"' % md5( str( params ) ).hexdigest()
   response.headers['Content-Length'] = len( strData )
   return strData
コード例 #30
0
    def __getSelectionData(self):
        callback = {}
        lhcbGroup = credentials.getSelectedGroup()
        lhcbUser = str(credentials.getUsername())
        RPC = getRPCClient("ResourceStatus/ResourceStatus")
        client = ResourceStatusClient(serviceIn=RPC)
        if len(request.params) > 0:
            tmp = {}
            for i in request.params:
                tmp[i] = str(request.params[i])
            callback["extra"] = tmp
####
        result = client.getSitePresent(meta={'columns': 'SiteName'})
        if result["OK"]:
            sites = result["Value"]
            try:
                sites = list(sites)
            except Exception, x:
                gLogger.error("Exception during convertion to a list: %s" %
                              str(x))
                sites = []  # Will return error on length check
            tier1 = gConfig.getValue("/Website/PreferredSites",
                                     [])  # Always return a list
            if len(sites) > 0:
                tier1.reverse()
                tier1 = [[x] for x in tier1]
                sites = [x for x in sites if x not in tier1
                         ]  # Removes sites which are in tier1 list
                for i in tier1:
                    sites.insert(0, i)
                sites.insert(0, ["All"])
            else:
                sites = [["Nothing to display"]]
コード例 #31
0
ファイル: Site.py プロジェクト: DIRACGrid/DIRACWeb
 def __getSiteList(self):
   callback = {}
   RPC = getRPCClient("ResourceStatus/ResourceStatus")
   result = RPC.getSitesStatusList()
   gLogger.info("\033[0;31m LIST: \033[0m %s" % result)
   if result["OK"]:
     response = []
     tier1 = list(["LCG.CERN.ch","LCG.CNAF.it","LCG.GRIDKA.de","LCG.IN2P3.fr","LCG.NIKHEF.nl","LCG.PIC.es","LCG.RAL.uk","LCG.SARA.nl"])
     if len(result["Value"])>0:
       siteTemp = result["Value"]
       site = {}
       for i in siteTemp:
         site[i[0]] = i[1]
       for i in tier1:
         if site.has_key(i):
           countryCode = i.rsplit(".",1)[1]
           response.append({"site":str(i),"code":str(countryCode),"mask":str(site[i])})
           del site[i]
       for key in sorted(site.iterkeys()):
         countryCode = key.rsplit(".",1)[1]
         response.append({"site":str(key),"code":str(countryCode),"mask":str(site[key])})
     else:
       response = [["Nothing to display"]]
   else:
     response = [["Error during RPC call"]]
   return {"success":"true","result":response}
コード例 #32
0
ファイル: Site.py プロジェクト: DIRACGrid/DIRACWeb
  def __globalStatJob(self,siteName):

    RPC = getRPCClient("WorkloadManagement/JobMonitoring")
    result = RPC.getStates()
    stat = []
    if result["OK"] and len(result["Value"])>0:
      for i in result["Value"]:
        stat.append(str(i))
    result = RPC.getJobPageSummaryWeb({'Site': [siteName]},[["JobID","DESC"]],0,1,False)
    if result["OK"]:
      result = result["Value"]
      back = []
      if result.has_key("Extras"):
        extra = result["Extras"]
        if len(stat) > 0:
          for i in sortList(stat):
            if i in sortList(extra.keys()):
              back.append([i,extra[i]])
            else:
              back.append([i,"-"])
        else:
          for i in sortList(extra.keys()):
            back.append([i,extra[i]])
      c.result = {"success":"true","result":back}
      c.result = back
    else:
      c.result = {"success":"false","error":result["Message"]}
    gLogger.info("\033[0;31m R E S U L T: \033[0m",c.result)
    return c.result
コード例 #33
0
 def __getModificator(self):
     rpcClient = getRPCClient(
         gConfig.getValue("/DIRAC/Configuration/MasterServer",
                          "Configuration/Server"))
     commiter = "%s@%s - %s" % (
         credentials.getUsername(), credentials.getSelectedGroup(),
         Time.dateTime().strftime("%Y-%m-%d %H:%M:%S"))
     return Modificator(rpcClient, commiter)
コード例 #34
0
 def plotStaticViews(self):
     rpcClient = getRPCClient("Framework/Monitoring")
     retVal = rpcClient.getViews(True)
     if not retVal['OK']:
         c.error = retVal['Message']
         return render("/error.mako")
     c.viewsList = simplejson.dumps(retVal['Value'])
     return render("/systems/activitiesMonitoring/plotViews.mako")
コード例 #35
0
 def __queryForPlot( self ):
   retVal = self.__parseFormParams()
   if not retVal[ 'OK' ]:
     return retVal
   params = retVal[ 'Value' ]
   repClient = ReportsClient( rpcClient = getRPCClient( "Accounting/ReportGenerator" ) )
   retVal = repClient.generateDelayedPlot( *params )
   return retVal
コード例 #36
0
ファイル: configuration.py プロジェクト: sfayer/DIRACWeb
 def __getModificator(self):
     rpcClient = getRPCClient(gConfig.getValue("/DIRAC/Configuration/MasterServer", "Configuration/Server"))
     commiter = "%s@%s - %s" % (
         credentials.getUsername(),
         credentials.getSelectedGroup(),
         Time.dateTime().strftime("%Y-%m-%d %H:%M:%S"),
     )
     return Modificator(rpcClient, commiter)
コード例 #37
0
 def plotStaticViews( self ):
   rpcClient = getRPCClient( "Framework/Monitoring" )
   retVal = rpcClient.getViews( True )
   if not retVal[ 'OK' ]:
     c.error = retVal[ 'Message' ]
     return render( "/error.mako" )
   c.viewsList = simplejson.dumps( retVal[ 'Value' ] )
   return render( "/systems/activitiesMonitoring/plotViews.mako" )
コード例 #38
0
ファイル: acct.py プロジェクト: atsareg/BESDIRAC
 def __queryForPlot( self ):
   retVal = self.__parseFormParams()
   if not retVal[ 'OK' ]:
     return retVal
   params = retVal[ 'Value' ]
   repClient = ReportsClient( rpcClient = getRPCClient( "Accounting/ReportGenerator" ) )
   retVal = repClient.generateDelayedPlot( *params )
   return retVal
コード例 #39
0
ファイル: PilotMonitor.py プロジェクト: acasajus/DIRACWeb
 def __getPilotLoggingInfo(self,pilotReference):
   RPC = getRPCClient("WorkloadManagement/WMSAdministrator")
   result = RPC.getPilotLoggingInfo(pilotReference)
   if result["OK"]:
     c.result = result["Value"]
     c.result = {"success":"true","result":c.result}
   else:
     c.result = {"success":"false","error":result["Message"]}
   return c.result
コード例 #40
0
ファイル: PilotMonitor.py プロジェクト: acasajus/DIRACWeb
 def __getPilotLoggingInfo(self, pilotReference):
     RPC = getRPCClient("WorkloadManagement/WMSAdministrator")
     result = RPC.getPilotLoggingInfo(pilotReference)
     if result["OK"]:
         c.result = result["Value"]
         c.result = {"success": "true", "result": c.result}
     else:
         c.result = {"success": "false", "error": result["Message"]}
     return c.result
コード例 #41
0
 def __globalStat(self):
     RPC = getRPCClient("Transformation/TransformationManager")
     result = RPC.getTransformationStatusCounters()
     if result["OK"]:
         result = result["Value"]
         back = []
         for i in sortList(result.keys()):
             back.append([i, result[i]])
         return back
コード例 #42
0
ファイル: ProductionMonitor.py プロジェクト: sfayer/DIRACWeb
 def __globalStat(self):
     RPC = getRPCClient("Transformation/TransformationManager")
     result = RPC.getTransformationStatusCounters()
     if result["OK"]:
         result = result["Value"]
         back = []
         for i in sortList(result.keys()):
             back.append([i, result[i]])
         return back
コード例 #43
0
ファイル: JobMonitor.py プロジェクト: nikolalazovski/DIRACWeb
 def __getLoggingInfo(self,id):
   RPC = getRPCClient("WorkloadManagement/JobMonitoring")
   result = RPC.getJobLoggingInfo(id)
   if result["OK"]:
     c.result = result["Value"]
     c.result = {"success":"true","result":c.result}
   else:
     c.result = {"success":"false","error":result["Message"]}
   gLogger.info("LoggingInfo:",id)
   return c.result
コード例 #44
0
ファイル: projects.py プロジェクト: belle2/belle2DIRAC
  def getProjectsList( self ):
    try:
      start = int( request.params[ 'start' ] )
    except:
      start = 0
    try:
      limit = int( request.params[ 'limit' ] )
    except:
      limit = 0
    try:
      sortField = str( request.params[ 'sortField' ] ).replace( "_", "." )
      sortDir = str( request.params[ 'sortDirection' ] )
      sort = [ ( sortField, sortDir ) ]
    except:
      return S_ERROR( "Oops! Couldn't understand the request" )
    condDict = {}
    #This is our connection to the Job database
    rpcClient = getRPCClient( "WorkloadManagement/JobMonitoring" )
    # use the last 2 weeks of job data, to speed loading time
    #lastFortnight =  (datetime.today() - timedelta(365/26)).isoformat()
    lastFortnight =  (datetime.today() - timedelta(365/360)).isoformat()
    username = credentials.getUsername()
    group = credentials.getSelectedGroup()

    if group != 'dirac_admin':
        condDict = {'Owner': username}
    result = rpcClient.getJobGroups( condDict, lastFortnight )
    #result = rpcClient.getJobGroups()
    if not result[ 'OK' ]:
      return result
    data = { 'numRecords' : len(result[ 'Value' ]), 'projects' : [] }
    for record in result['Value']:
      rD = {}
      counters = rpcClient.getCounters(['Status', 'Owner','OwnerGroup','LastUpdateTime','SubmissionTime'], {'JobGroup' : record})
      if not counters['OK']:
        return counters
      else:
        rD['LastUpdate'] = self.timeToNUnitAgo(self.mostRecentTime(counters['Value'], 'LastUpdateTime'))
        #rD['counters'] = counters['Value']
        rD['percentage'] = self.statusToPercentage(counters['Value'])
        rD['colours'] = self.statusToColours(counters['Value'])
	if rD['percentage'] == 1:
          if rD['colours'][0] > 0:
            rD['status'] = "Done - with failures"
          else:
            rD['status'] = "Done"
        else:
          rD['status'] = "Running"
      rD['SubmissionTime'] = str(self.mostRecentTime(counters['Value'],'SubmissionTime'))
      #cheat - get the first owner as they're all the same
      rD['Owner'] = counters["Value"][0][0]["Owner"]
      rD['OwnerGroup'] = counters["Value"][0][0]["OwnerGroup"]
      rD['proj_Name'] = record
      data['projects'].append( rD )
    return data
コード例 #45
0
ファイル: ProductionMonitor.py プロジェクト: sfayer/DIRACWeb
 def showFileStatus(self):
     req = {}
     if request.params.has_key("limit") and len(request.params["limit"]) > 0:
         limit = int(request.params["limit"])
         if request.params.has_key("start") and len(request.params["start"]) > 0:
             start = int(request.params["start"])
         else:
             start = 0
     else:
         limit = 25
         start = 0
     if request.params.has_key("prodID"):
         id = int(request.params["prodID"])
     else:
         return {"success": "false", "error": "Transformation ID(s) is not defined"}
     if request.params.has_key("getFileStatus"):
         status = str(request.params["getFileStatus"])
     else:
         return {"success": "false", "error": "Files status is not defined"}
     RPC = getRPCClient("Transformation/TransformationManager")
     result = RPC.getTransformationFilesSummaryWeb(
         {"TransformationID": id, "Status": status}, [["FileID", "ASC"]], start, limit
     )
     if not result["OK"]:
         c.result = {"success": "false", "error": result["Message"]}
     else:
         result = result["Value"]
         if result.has_key("TotalRecords") and result["TotalRecords"] > 0:
             if result.has_key("ParameterNames") and result.has_key("Records"):
                 if len(result["ParameterNames"]) > 0:
                     if len(result["Records"]) > 0:
                         c.result = []
                         jobs = result["Records"]
                         head = result["ParameterNames"]
                         headLength = len(head)
                         for i in jobs:
                             tmp = {}
                             for j in range(0, headLength):
                                 tmp[head[j]] = i[j]
                             c.result.append(tmp)
                         total = result["TotalRecords"]
                         if result.has_key("Extras"):
                             extra = result["Extras"]
                             c.result = {"success": "true", "result": c.result, "total": total, "extra": extra}
                         else:
                             c.result = {"success": "true", "result": c.result, "total": total}
                     else:
                         c.result = {"success": "false", "result": "", "error": "There are no data to display"}
                 else:
                     c.result = {"success": "false", "result": "", "error": "ParameterNames field is undefined"}
             else:
                 c.result = {"success": "false", "result": "", "error": "Data structure is corrupted"}
         else:
             c.result = {"success": "false", "result": "", "error": "There were no data matching your selection"}
     return c.result
コード例 #46
0
ファイル: MetaCatalog.py プロジェクト: sposs/DIRACWeb
 def __getSelector(self,select="All"):
   RPC = getRPCClient("DataManagement/FileCatalog")
   result = RPC.getMetadataFields()
   if not result["OK"]:
     return {"success":"false","error":result["Message"]}
   result = result["Value"]
   gLogger.always(" * * * ",result)
   for key,value in result.items():
     result[key] = value.lower()
   gLogger.always(" * * * ",result)
   return {"success":"true","result":result}
コード例 #47
0
 def __getSelector(self, select="All"):
     RPC = getRPCClient("DataManagement/FileCatalog")
     result = RPC.getMetadataFields()
     if not result["OK"]:
         return {"success": "false", "error": result["Message"]}
     result = result["Value"]
     gLogger.always(" * * * ", result)
     for key, value in result.items():
         result[key] = value.lower()
     gLogger.always(" * * * ", result)
     return {"success": "true", "result": result}
コード例 #48
0
 def queryFieldValue(self):
     """
 Query a value for a field
 """
     fieldQuery = str(request.params['queryField'])
     definedFields = simplejson.loads(request.params['selectedFields'])
     rpcClient = getRPCClient("Framework/Monitoring")
     result = rpcClient.queryField(fieldQuery, definedFields)
     if 'rpcStub' in result:
         del (result['rpcStub'])
     return result
コード例 #49
0
 def showRunStatus(self):
   req = {}
   if request.params.has_key("limit") and len(request.params["limit"]) > 0:
     limit = int(request.params["limit"])
     if request.params.has_key("start") and len(request.params["start"]) > 0:
       start = int(request.params["start"])
     else:
       start = 0
   else:
     limit = 25
     start = 0
   if request.params.has_key("getRunStatus"):
     id = int(request.params["getRunStatus"])
   else:
     return {"success":"false","error":"Run status is not defined"}
   RPC = getRPCClient("Transformation/TransformationManager")
   result = RPC.getTransformationRunsSummaryWeb({'TransformationID':id},[["RunNumber","DESC"]],start,limit)
   if not result['OK']:
     c.result = {"success":"false","error":result["Message"]}
   else:
     result = result["Value"]
     if result.has_key("TotalRecords") and  result["TotalRecords"] > 0:
       total = result["TotalRecords"]
       if result.has_key("Extras"):
         extra = result["Extras"]
       if result.has_key("ParameterNames") and result.has_key("Records"):
         head = result["ParameterNames"]
         if len(head) > 0:
           headLength = len(head)
           if len(result["Records"]) > 0:
             c.result = []
             jobs = result["Records"]
             for i in jobs:
               if len(i) != headLength:
                 gLogger.info("Faulty record: %s" % i)
                 c.result = {"success":"false","result":c.result,"total":total,"error":"One of the records in service response is corrupted"}
                 return c.result
               tmp = {}
               for j in range(0,headLength):
                 tmp[head[j]] = i[j]
               c.result.append(tmp)
             if extra:
               c.result = {"success":"true","result":c.result,"total":total,"extra":extra}
             else:
               c.result = {"success":"true","result":c.result,"total":total}
           else:
             c.result = {"success":"false","result":"","error":"There are no data to display"}
         else:
           c.result = {"success":"false","result":"","error":"ParameterNames field is undefined"}
       else:
         c.result = {"success":"false","result":"","error":"Data structure is corrupted"}
     else:
       c.result = {"success":"false","result":"","error":"There were no data matching your selection"}
   return c.result
コード例 #50
0
 def queryFieldValue( self ):
   """
   Query a value for a field
   """
   fieldQuery = str( request.params[ 'queryField' ] )
   definedFields = simplejson.loads( request.params[ 'selectedFields' ] )
   rpcClient = getRPCClient( "Framework/Monitoring" )
   result = rpcClient.queryField( fieldQuery, definedFields )
   if 'rpcStub' in result:
     del( result[ 'rpcStub' ] )
   return result
コード例 #51
0
 def submit(self):
     RPC = getRPCClient("Framework/SystemLoggingReport")
     result = self.__request()
     result = RPC.getGroupedMessages(result, globalSort, pageNumber,
                                     numberOfJobs)
     gLogger.info("- REQUEST:", result)
     if result["OK"]:
         result = result["Value"]
         c.result = []
         jobs = result["Records"]
         if result.has_key("ParameterNames") and result.has_key("Records"):
             if len(result["ParameterNames"]) > 0:
                 if len(result["Records"]) > 0:
                     c.result = []
                     jobs = result["Records"]
                     head = result["ParameterNames"]
                     headLength = len(head)
                     for i in jobs:
                         tmp = {}
                         for j in range(0, headLength):
                             tmp[head[j]] = i[j]
                         c.result.append(tmp)
                     total = result["TotalRecords"]
                     timestamp = Time.dateTime().strftime(
                         "%Y-%m-%d %H:%M [UTC]")
                     #            c.result = {"success":"true", "result":c.result, "total":total,"date":timestamp}
                     c.result = {
                         "success": "true",
                         "result": c.result,
                         "total": total
                     }
                 else:
                     c.result = {
                         "success": "false",
                         "result": "",
                         "error": "There are no data to display"
                     }
             else:
                 c.result = {
                     "success": "false",
                     "result": "",
                     "error": "ParameterNames field is missing"
                 }
         else:
             c.result = {
                 "success": "false",
                 "result": "",
                 "error": "Data structure is corrupted"
             }
     else:
         c.result = {"success": "false", "error": result["Message"]}
     gLogger.info("\033[0;31mRESULT:\033[0m")
     return c.result
コード例 #52
0
 def getInstancesList(self):
     try:
         start = int(request.params['start'])
     except:
         start = 0
     try:
         limit = int(request.params['limit'])
     except:
         limit = 0
     try:
         sortField = str(request.params['sortField']).replace("_", ".")
         sortDir = str(request.params['sortDirection'])
         sort = [(sortField, sortDir)]
     except:
         return S_ERROR("Oops! Couldn't understand the request")
     condDict = {}
     try:
         if 'cond' in request.params:
             dec = simplejson.loads(request.params['cond'])
             for k in dec:
                 v = dec[k]
                 if type(v) in (types.StringType, types.UnicodeType):
                     v = [str(v)]
                 else:
                     v = [str(f) for f in v]
                 condDict[str(k).replace("_", ".")] = v
     except:
         raise
     try:
         if 'statusSelector' in request.params:
             condDict['inst.Status'] = [
                 str(request.params['statusSelector'])
             ]
     except:
         pass
     print condDict
     rpcClient = getRPCClient("WorkloadManagement/VirtualMachineManager")
     result = rpcClient.getInstancesContent(condDict, sort, start, limit)
     if not result['OK']:
         return result
     svcData = result['Value']
     data = {'numRecords': svcData['TotalRecords'], 'instances': []}
     dnMap = {}
     for record in svcData['Records']:
         rD = {}
         for iP in range(len(svcData['ParameterNames'])):
             param = svcData['ParameterNames'][iP].replace(".", "_")
             if param == 'inst_LastUpdate':
                 rD[param] = record[iP].strftime("%Y-%m-%d %H:%M:%S")
             else:
                 rD[param] = record[iP]
         data['instances'].append(rD)
     return data
コード例 #53
0
ファイル: RequestMonitor.py プロジェクト: acasajus/DIRACWeb
    def submit(self):
        RPC = getRPCClient("RequestManagement/centralURL")
        result = self.__request()
        result = RPC.getRequestSummaryWeb(result, globalSort, pageNumber,
                                          numberOfJobs)
        if result["OK"]:
            result = result["Value"]
            gLogger.info("\033[0;31mRESULT:\033[0m %s" %
                         result["ParameterNames"])
            if result.has_key("ParameterNames") and result.has_key("Records"):
                if len(result["ParameterNames"]) > 0:
                    if len(result["Records"]) > 0:
                        c.result = []
                        jobs = result["Records"]
                        head = result["ParameterNames"]
                        headLength = len(head)
                        for i in jobs:
                            tmp = {}
                            for j in range(0, headLength):
                                if j == 2:
                                    if i[j] == "None":
                                        i[j] = "-"
                                tmp[head[j]] = i[j]
                            c.result.append(tmp)
                        total = result["TotalRecords"]
                        gLogger.info(" c.result ", c.result)
                        c.result = {
                            "success": "true",
                            "result": c.result,
                            "total": total
                        }
                    else:
                        c.result = {
                            "success": "false",
                            "result": "",
                            "error": "There are no data to display"
                        }
                else:
                    c.result = {
                        "success": "false",
                        "result": "",
                        "error": "ParameterNames field is missing"
                    }
            else:
                c.result = {
                    "success": "false",
                    "result": "",
                    "error": "Data structure is corrupted"
                }
        else:
            c.result = {"success": "false", "error": result["Message"]}
#    gLogger.info("\033[0;31mRESULT:\033[0m ")
        return c.result
コード例 #54
0
ファイル: JobMonitor.py プロジェクト: nikolalazovski/DIRACWeb
 def __globalStat(self):
   RPC = getRPCClient("WorkloadManagement/JobMonitoring")
   result = RPC.getJobPageSummaryWeb({},globalSort,0,1,False)
   gLogger.info(" - result - :",result)
   if result["OK"]:
     result = result["Value"]
     if result.has_key("Extras"):
       extra = result["Extras"]
       back = []
       for i in sortList(extra.keys()):
         back.append([i,extra[i]])
       return back
コード例 #55
0
 def getSiteMaskLog(self):
     if 'siteName' not in request.params or not request.params["siteName"]:
         return {"success": "false", "result": "Please, define a site!"}
     site = str(request.params["siteName"])
     rpcClient = getRPCClient("WorkloadManagement/WMSAdministrator")
     gLogger.info("- siteName:", site)
     result = rpcClient.getSiteMaskLogging(site)
     gLogger.info("- siteName:", site)
     gLogger.info("- Info result:", result)
     if not result["OK"]:
         return {"success": "false", "result": result["Message"]}
     return result['Value'][site]
コード例 #56
0
 def showFileStatus(self):
   req = {}
   if request.params.has_key("limit") and len(request.params["limit"]) > 0:
     limit = int(request.params["limit"])
     if request.params.has_key("start") and len(request.params["start"]) > 0:
       start = int(request.params["start"])
     else:
       start = 0
   else:
     limit = 25
     start = 0
   if request.params.has_key("prodID"):
     id = int(request.params["prodID"])
   else:
     return {"success":"false","error":"Transformation ID(s) is not defined"}
   if request.params.has_key("getFileStatus"):
     status = str(request.params["getFileStatus"])
   else:
     return {"success":"false","error":"Files status is not defined"}
   RPC = getRPCClient("Transformation/TransformationManager")
   result = RPC.getTransformationFilesSummaryWeb({'TransformationID':id,'Status':status},[["FileID","ASC"]],start,limit)
   if not result['OK']:
     c.result = {"success":"false","error":result["Message"]}
   else:
     result = result["Value"]
     if result.has_key("TotalRecords") and  result["TotalRecords"] > 0:
       if result.has_key("ParameterNames") and result.has_key("Records"):
         if len(result["ParameterNames"]) > 0:
           if len(result["Records"]) > 0:
             c.result = []
             jobs = result["Records"]
             head = result["ParameterNames"]
             headLength = len(head)
             for i in jobs:
               tmp = {}
               for j in range(0,headLength):
                 tmp[head[j]] = i[j]
               c.result.append(tmp)
             total = result["TotalRecords"]
             if result.has_key("Extras"):
               extra = result["Extras"]
               c.result = {"success":"true","result":c.result,"total":total,"extra":extra}
             else:
               c.result = {"success":"true","result":c.result,"total":total}
           else:
             c.result = {"success":"false","result":"","error":"There are no data to display"}
         else:
           c.result = {"success":"false","result":"","error":"ParameterNames field is undefined"}
       else:
         c.result = {"success":"false","result":"","error":"Data structure is corrupted"}
     else:
       c.result = {"success":"false","result":"","error":"There were no data matching your selection"}
   return c.result
コード例 #57
0
ファイル: JobMonitor.py プロジェクト: nikolalazovski/DIRACWeb
 def __getBasicInfo(self,id):
   RPC = getRPCClient("WorkloadManagement/JobMonitoring")
   result = RPC.getJobSummary(id)
   if result["OK"]:
     itemList = result["Value"]
     c.result = []
     for key,value in itemList.items():
       c.result.append([key,value])
     c.result = {"success":"true","result":c.result}
   else:
     c.result = {"success":"false","error":result["Message"]}
   gLogger.info("BasicInfo:",id)
   return c.result