Skip to content

Commit

Permalink
Cleaned up code.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesletts committed Apr 29, 2014
1 parent cc33d38 commit 3c17f13
Showing 1 changed file with 13 additions and 36 deletions.
49 changes: 13 additions & 36 deletions sitedb_functions.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/bash

get_federation_pledges() {
# This function finds the pledges for certain federated Tier-2 sites
# from information in REBUS. Unfortunately the list of federations
# and their membership is not get discoverable.

url="http://wlcg-rebus.cern.ch/apps/pledges/resources/2014/all/csv"
curl -ks $url | awk -F\, '
{
Expand Down Expand Up @@ -41,42 +45,11 @@ get_federation_pledges() {
return 0
}

list_federation_pledges() {
url="http://wlcg-rebus.cern.ch/apps/pledges/resources/2014/all/csv"
curl -ks $url | awk -F\, '
{
federation=$3
cpu=$4
pledge=$8
if ( federation == "INFN T2 Federation" && cpu == "CPU" ) {
printf(" * Federation %s pledge is %i total cores over 4 sites.\n",federation,pledge/10.)
}
if ( federation == "CMS Federation DESY RWTH Aachen" && cpu == "CPU" ) {
printf(" * Federation %s pledge is %i total cores over 2 sites.\n",federation,pledge/10.)
}
if ( federation == "Belgian Tier-2 Federation" && cpu == "CPU" ) {
printf(" * Federation %s pledge is %i total cores over 2 sites.\n",federation,pledge/10.)
}
if ( federation == "Russian Data-Intensive GRID" && cpu == "CPU" ) {
printf(" * Federation %s pledge is %i total cores over 7 sites.\n",federation,pledge/10.)
}
if ( federation == "London Tier 2" && cpu == "CPU" ) {
printf(" * Federation %s pledge is %i total cores over 2 sites.\n",federation,pledge/10.)
}
if ( federation == "SouthGrid" && cpu == "CPU" ) {
printf(" * Federation %s pledge is %i total cores over 1 site.\n",federation,pledge/10.)
}
}'
echo " * The CERN pledge is listed under the Tier-0."
return
}

translate_site_names_from_sidedb_to_cmssite() {

# output: name of a sed file to translate SiteDB site names to CMSSite names, in csv format

# error if X509_USER_PROXY is not defined

if [ -z $X509_USER_PROXY ] ; then
echo "ERROR: X509_USER_PROXY not defined!"
return 1
Expand All @@ -95,7 +68,10 @@ translate_site_names_from_sidedb_to_cmssite() {
}

get_pledges_from_sitedb() {
# output: comma separated list of CMSSite and latest CPU pledges in kHS06 divided by 10 to normalize roughly to cores.
# output: comma separated list of CMSSite and latest CPU pledges
# in kHS06 divided by 10 to normalize roughly to cores.
# Federated pledges come at the end, so you need to take the
# last entry per site. Earlier (zero) entries may be from SitDB.

# error if X509_USER_PROXY is not defined

Expand All @@ -110,16 +86,17 @@ get_pledges_from_sitedb() {
thisyear=`/bin/date +%Y`
TMPFILE=`mktemp -t TMPPLEDGES.txt.XXXXXXXXXX` || return 1

# get pledges from sitedb only for this year and translate to CMSSite name not the generic site name
# get pledges from sitedb only for this year and translate
# to CMSSite name not the generic site name

SEDFILE=`translate_site_names_from_sidedb_to_cmssite`
curl -ks --cert $X509_USER_PROXY --key $X509_USER_PROXY $url \
| awk -F\, -v ty=$thisyear '($4==ty){print $2 "," $3 "," $5}' \
| tr \[ \ | tr \" \ | sed 's/ //g' | sort | sed -f $SEDFILE | sort > $TMPFILE


# Remove multiple pledges for the same site ($1) for this year by taking the most recently entered ($2).
# Approximate kHS06 to physical cpu by dividing by 10.
# Remove multiple pledges for the same site ($1) for this year
# by taking the most recently entered ($2). Approximate kHS06
# to physical cpu by dividing by 10.

PLEDGES=`mktemp -t PLEDGES.txt.XXXXXXXXXX` || return 2
sites=`cat $TMPFILE | awk -F\, '{print $1}' | sort | uniq | grep ^T`
Expand Down

0 comments on commit 3c17f13

Please sign in to comment.