def infra(request):
	global INFRA
	if INFRA == None:
		infraPath = getInfraPathOfRequest(request)
		INFRA = Infrastructure(infraPath,"./")
		INFRA.init()
	return INFRA
def refreshCertificates(myInfrastructure=None):
    gwhostLocation = "/tmp/gwHosts"
    print("OBTAINING AVAILABLE HOSTS")

    if myInfrastructure == None:
        myInfrastructure = Infrastructure()

    myInfrastructure.load()
    # hostList = myInfrastructure.getGoodHosts()

    print("UPDATING CERTIFICATE IN REMOTE HOSTS")
    renewedHostList = []
    for gwHost in myInfrastructure.hosts:
        print("-----")
        print("Host: " + gwHost.hostname)
        print("	host found in past executions")
        command = "glite-ce-proxy-renew -e " + gwHost.hostname + " gw01.ciemat.es"
        print("	" + command)

        try:
            result = runProcess(command)
            print(result)
            print("	parece que ruló")
            renewedHostList.append(gwHost)
        except:
            print("parece que falló")

    print("")
    print("RENEWED CERTIFICATES")
    for host in renewedHostList:
        print(host.hostname)