FCR UK

From GridPP Wiki
Jump to: navigation, search
  • Python script to generate UK excluded sites html page.
  • Run : python fcr.py
#!/usr/bin/python

import string
import urllib


def triplecomp(x,y):
	res=cmp(x[0].lower(),y[0].lower())
	return res 

def getfcrtable(url,region):
	fcrserver=urllib.urlopen(url)
	i=fcrserver.readline()
	result=[]
	sites=[]
	while(i):
		if (i.find('GlueVOViewLocalID')!=-1):
			el=i.split(',')
			vo=el[0].split('=')[-1]
			ce=el[1].split('=')[-1]
			site=el[2].split('=')[-1]
			if(ce.find('.uk:')!=-1):
				result.append([site,vo,ce])
				sites.append(site)
		i=fcrserver.readline()
	fcrserver.close()
	result.sort(triplecomp)
	return result

def genhead():
	print '''<html><head><title>FCR Excluded Sites</title>
<style>
body { margin: 0px;
       padding: 0px;
       background-color: white;
       xx-font-size: 75%;
       font-size: 0.8em;
       line-height: 16px;
       text-align: center;
       font-family: Arial, Verdana, Geneva, sans-serif;
     }

td { font-size: 0.8em; }

td.maincell { font-size: 0.8em; }
</style>
</head>'''

def genfoot():
	print '''</body></html>'''

def gentable(res):
	print '''<body>'''
	print '''<p align="left"><b>This Page shows the list of sites that are exluded from the toplevel bdii's by the <a href="https://lcg-fcr.cern.ch:8443/fcr/fcr.cgi">freedom of choice tool</a></b></p>'''
	print '''<div align="left">'''
	print '''<ul>'''
	print '''<li>Don't worry if your site is down</li>'''
	print '''<li><b>WORRY</b> if your site is not down</li>'''
	print '''<ul>'''
	print '''<li>Check the <a href="https://lcg-fcr.cern.ch:8443/fcr/fcr.cgi">FCR Web Page</a></li>'''
	print '''<li>Check the <a href="https://lcg-sam.cern.ch:8443/sam/sam.py">SAM</a> tests for the excluded VO</li>'''
	print '''</ul>'''
	print '''<li>For more information of the FCR please go <a href="https://lcg-fcr.cern.ch:8443/fcr/help.cgi">here</></li>'''
	print '''</ul>'''
	print '''</div>'''
	print '''<table border="0">'''
        print '''<tr>'''
	print '''<td align="center"><b>SITE NAME</b></td>'''
	print '''<td align="center"><b>VO</b></td>'''
	print '''<td align="center"><b>Queue Contact</b></td>'''
	print '''</tr>'''
	for line in res:
		print "<tr>"
		print '''<td bgcolor="#ccccc" align="center">'''+line[0]+"</td>"
		print '''<td bgcolor="#ccccc" align="center">'''+line[1]+"</td>"
		print '''<td bgcolor="#ccccc" align="center">'''+line[2]+"</td>"
		print "</tr>"
	print '''</table>'''


res=getfcrtable("http://lcg-fcr.cern.ch:8083/fcr-data/exclude.ldif",'uk') 
genhead()
gentable(res)
genfoot()