Beispiel #1
0
    def __get_site_name_map(self):

        url = 'https://cmsweb.cern.ch/sitedb/data/prod/site-names'
        site_map_data = get_json_data_https(url)

        siteIdx = site_map_data['desc']['columns'].index('site_name')
        typeIdx = site_map_data['desc']['columns'].index('type')
        nameIdx = site_map_data['desc']['columns'].index('alias')

        site_name_map = {}

        for item in site_map_data['result']:
            try:
                (site_name_map[item[siteIdx]][item[typeIdx]]).append(
                    item[nameIdx])
            except KeyError:
                try:
                    site_name_map[item[siteIdx]][item[typeIdx]] = [
                        item[nameIdx]
                    ]
                except KeyError:
                    site_name_map[item[siteIdx]] = {
                        item[typeIdx]: [item[nameIdx]]
                    }
        self.__logger.debug(site_name_map)

        return site_name_map
Beispiel #2
0
    def __get_sitedb_pledges(self):

	url='https://cmsweb.cern.ch/sitedb/data/prod/resource-pledges'
	resource_pledge_data = get_json_data_https(url)

	siteIdx=resource_pledge_data['desc']['columns'].index('site_name')
	updateTimeIdx=resource_pledge_data['desc']['columns'].index('pledge_date')
	yearIdx=resource_pledge_data['desc']['columns'].index('quarter')
	diskIdx=resource_pledge_data['desc']['columns'].index('disk_store')
	localDiskIdx=resource_pledge_data['desc']['columns'].index('local_store')
	
	resource_pledges = {}

	current_year=time.gmtime().tm_year

	for item in resource_pledge_data['result']:
		if item[yearIdx]==current_year:
			try:
				if item[updateTimeIdx] >= resource_pledges[item[siteIdx]]['pledge_date']:
					resource_pledges[item[siteIdx]]['disk_store']=item[diskIdx]
	                                resource_pledges[item[siteIdx]]['local_store']=item[localDiskIdx]
	                                resource_pledges[item[siteIdx]]['pledge_date']=item[updateTimeIdx]
			except KeyError:
				resource_pledges[item[siteIdx]]={'disk_store':item[diskIdx], 'local_store':item[localDiskIdx], 'pledge_date':item[updateTimeIdx]}
	
	self.__logger.debug(resource_pledges)

	return resource_pledges
Beispiel #3
0
    def __getBlocks(self, site):

        if os.path.isfile("%s/blocks_%s" % (self.__tmpdirectory, site)):
            unpopularBlocks = get_json_data_from_file("%s/blocks_%s" % (self.__tmpdirectory, site))
            return unpopularBlocks

        else:
            url = "https://cmsweb.cern.ch/popdb/victorinterface/popdbcombine/?sitename=%s" % (site)
            unpopularBlocks = get_json_data_https(url)

            dumpTemporaryInfo(unpopularBlocks, self.__tmpdirectory, "blocks_%s" % (site))
            return unpopularBlocks
Beispiel #4
0
    def __getBlocks(self, site):

        if os.path.isfile('%s/blocks_%s' % (self.__tmpdirectory, site)):
            unpopularBlocks = get_json_data_from_file(
                '%s/blocks_%s' % (self.__tmpdirectory, site))
            return unpopularBlocks

        else:
            url = 'https://cmsweb.cern.ch/popdb/victorinterface/popdbcombine/?sitename=%s' % (
                site)
            unpopularBlocks = get_json_data_https(url)

            dumpTemporaryInfo(unpopularBlocks, self.__tmpdirectory,
                              'blocks_%s' % (site))
            return unpopularBlocks
Beispiel #5
0
    def __get_site_name_map(self):

	url='https://cmsweb.cern.ch/sitedb/data/prod/site-names'
        site_map_data = get_json_data_https(url)

	siteIdx=site_map_data['desc']['columns'].index('site_name')
	typeIdx=site_map_data['desc']['columns'].index('type')
	nameIdx=site_map_data['desc']['columns'].index('alias')

	site_name_map = {}

	for item in site_map_data['result']:
		try:
			(site_name_map[item[siteIdx]][item[typeIdx]]).append(item[nameIdx])
     		except KeyError:
			try:
				site_name_map[item[siteIdx]][item[typeIdx]]=[item[nameIdx]]
			except KeyError:
				site_name_map[item[siteIdx]]={item[typeIdx]:[item[nameIdx]]}
	self.__logger.debug(site_name_map)

	return site_name_map
Beispiel #6
0
    def __get_sitedb_pledges(self):

        url = 'https://cmsweb.cern.ch/sitedb/data/prod/resource-pledges'
        resource_pledge_data = get_json_data_https(url)

        siteIdx = resource_pledge_data['desc']['columns'].index('site_name')
        updateTimeIdx = resource_pledge_data['desc']['columns'].index(
            'pledge_date')
        yearIdx = resource_pledge_data['desc']['columns'].index('quarter')
        diskIdx = resource_pledge_data['desc']['columns'].index('disk_store')
        localDiskIdx = resource_pledge_data['desc']['columns'].index(
            'local_store')

        resource_pledges = {}

        current_year = time.gmtime().tm_year

        for item in resource_pledge_data['result']:
            if item[yearIdx] == current_year:
                try:
                    if item[updateTimeIdx] >= resource_pledges[
                            item[siteIdx]]['pledge_date']:
                        resource_pledges[
                            item[siteIdx]]['disk_store'] = item[diskIdx]
                        resource_pledges[
                            item[siteIdx]]['local_store'] = item[localDiskIdx]
                        resource_pledges[
                            item[siteIdx]]['pledge_date'] = item[updateTimeIdx]
                except KeyError:
                    resource_pledges[item[siteIdx]] = {
                        'disk_store': item[diskIdx],
                        'local_store': item[localDiskIdx],
                        'pledge_date': item[updateTimeIdx]
                    }

        self.__logger.debug(resource_pledges)

        return resource_pledges