Пример #1
0
 def validateprocesseddataset(self, procdataset):
     if lexicon.processeddataset(procdataset):
         dslist = popCommonDB.getProcessedDataSetList(DBUSER)
         dslist = map(lambda x: x["COLLNAME"], dslist)
         if procdataset in dslist:
             return True
     raise Paramvalidationexception(
         'processeddataset', 'param must be a valid processed dataset name')
Пример #2
0
 def validatedataset(self, dataset):
     if lexicon.dataset(dataset):
         dslist = popCommonDB.getDataSetList(DBUSER)
         dslist = map(lambda x: x["COLLNAME"], dslist)
         if dataset in dslist:
             return True
     raise Paramvalidationexception('dataset',
                                    'param must be a valid dataset name')
Пример #3
0
 def validatedatatier(self, datatier):
     if lexicon.datatier(datatier):
         dtlist = popCommonDB.getDataTierList(DBUSER)
         dtlist = map(lambda x: x["COLLNAME"], dtlist)
         dtlist.append('ALL')
         if datatier in dtlist:
             return True
     raise Paramvalidationexception('datatier',
                                    'param must be a valid datatier name')
Пример #4
0
 def validatesite(self, sitename):
     if lexicon.anstr(sitename) & (sitename == 'summary'):
         return True
     if lexicon.tier(sitename):
         sitelist = popCommonDB.getSitesList(DBUSER)
         if sitename in sitelist:
             return True
     raise Paramvalidationexception('sitename',
                                    'param must be a valid site name')
Пример #5
0
def AccessStatsByDirAtSite(params):
    # Provides access statistics aggregated by directory
    # Requires parameters SiteName and DirName (the top-level dir from which to provide the statistics)
    # Currently only supported for xrootd popularity at T2_CH_CERN (EOS)

    data = {}

    logger.info('Using access data source: %s' % params.source)
    if params.source == 'xrootd':
        DBUSER = '******'
    else:
        raise Paramvalidationexception(
            'source',
            'param source=%s unsupported, please select source=xrootd' %
            params.source)

    logger.info('Using DBUSER: %s' % DBUSER)

    vars = "'T2_CH_CERN' as SITENAME, regexp_replace(PATH,'^/eos/cms','') as PATH, (max_tday - to_date('1970-01-01','YYYY-MM-DD')) * 86400 as LASTDAY, (min_tday - to_date('1970-01-01','YYYY-MM-DD')) * 86400 as FIRSTDAY,  READ_ACC as NACC, READ_BYTES as READMBYTES"
    table = "%s.%s" % (DBUSER, 'V_XRD_STAT2_AGGR1')
    whereCondition = " 'T2_CH_CERN' like %s and regexp_replace(PATH,'^/eos/cms','') like %s" % (
        '%s', '%s')

    query = "select %s from %s where %s" % (vars, table, whereCondition)

    logger.info('AccessStatsByDirAtSite query: %s' % query)

    # -----------------------------------

    try:
        cursor = connections[DBUSER].cursor()

        # For wildcard queries, we need to add the % wildcard in the bind variable...
        cursor.execute(query, [params.SiteName, params.TopDir + '%'])

        data = victorinterfaceUtility.genericTranslateInListDictVict(
            cursor, 'SITENAME', 'PATH')

    except Exception as e:
        raise PopularityDBException(query, e)

    return data
Пример #6
0
 def validateDir(self, dirname):
     if lexicon.dirname(dirname):
         return True
     raise Paramvalidationexception('dirname', 'param must be a valid directory name')
Пример #7
0
 def validateSource(self, source):
     if lexicon.accsource(source):
          return True
     raise Paramvalidationexception('source', 'param must be a valid source name')
Пример #8
0
 def validateSite(self, sitename):
     if (sitename == '') | (lexicon.wildcardtier(sitename)):
         return True
     raise Paramvalidationexception('sitename', 'param must be a valid site name')
Пример #9
0
 def validatedate(self, inputdate):
     if lexicon.datestr(inputdate):
         return True
     raise Paramvalidationexception('inputdate', 'param must be a valid date')
Пример #10
0
 def validaten(self, n):
     if n.isdigit():
         return True
     raise Paramvalidationexception('n', 'param must be a positive int')
Пример #11
0
 def validateorder(self, order):
     if lexicon.anstr(order) & (order in self.ordervalues):
         return True
     raise Paramvalidationexception(
         'order', 'param must be a value in %s' % self.ordervalues)
Пример #12
0
 def validateaggregation(self, aggr):
     if lexicon.anstr(aggr) & (aggr in self.aggregationvalues):
         return True
     raise Paramvalidationexception(
         'aggr', 'param must be value in %s' % self.aggregationvalues)
Пример #13
0
 def setIsCentralUser(self, n):
     if (n == '0' or n == '1'):
         self.isUserCMS = int(n)
     else:
         raise Paramvalidationexception('centraluser',
                                        'param must be 0 or 1')
Пример #14
0
 def validateincludewmagent(self, includewmagent):
     if includewmagent in ['y', 'n']:
         return True
     raise Paramvalidationexception('includewmagent',
                                    'includewmagent must be y or n')