Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
98 changes: 56 additions & 42 deletions Core/scripts/dirac-configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
import DIRAC
from DIRAC.Core.Base import Script
from DIRAC.Core.Security.ProxyInfo import getProxyInfo
from DIRAC.ConfigurationSystem.Client.Helpers import cfgInstallPath, getVO, cfgPath
from DIRAC.ConfigurationSystem.Client.Helpers import cfgInstallPath, cfgPath
from DIRAC.Core.Utilities.SiteSEMapping import getSEsForSite

import sys, os
Expand Down Expand Up @@ -416,49 +416,63 @@ def forceUpdate( optionValue ):


#Do the vomsdir magic
voName = getVO()
if not voName:
sys.exit( 0 )
result = DIRAC.gConfig.getSections( "/Registry/VOMS/Servers/%s" % voName )
if not result[ 'OK' ]:
# This has to be done for all VOs in the installation

result = DIRAC.gConfig.getSections( "/Registry/VOMS/Servers" )
if not result['OK']:
sys.exit( 0 )
DIRAC.gLogger.notice( "Creating VOMSDIR/VOMSES files" )
vomsDirHosts = result[ 'Value' ]
vomsDirPath = os.path.join( DIRAC.rootPath, 'etc', 'grid-security', 'vomsdir', voName )
vomsesDirPath = os.path.join( DIRAC.rootPath, 'etc', 'grid-security', 'vomses' )
for path in ( vomsDirPath, vomsesDirPath ):
if not os.path.isdir( path ):

voList = result[ 'Value' ]
error = ''
for voName in voList:

result = DIRAC.gConfig.getSections( "/Registry/VOMS/Servers/%s" % voName )
if not result[ 'OK' ]:
error = 'No VOMS server define for %s' % voName
DIRAC.gLogger.error( error )
continue
DIRAC.gLogger.notice( "Creating VOMSDIR/VOMSES files for", voName )
vomsDirHosts = result[ 'Value' ]
vomsDirPath = os.path.join( DIRAC.rootPath, 'etc', 'grid-security', 'vomsdir', voName )
vomsesDirPath = os.path.join( DIRAC.rootPath, 'etc', 'grid-security', 'vomses' )
for path in ( vomsDirPath, vomsesDirPath ):
if not os.path.isdir( path ):
try:
os.makedirs( path )
except Exception, e:
DIRAC.gLogger.error( "Could not create directory", str( e ) )
sys.exit( 1 )
vomsesLines = []
for vomsHost in vomsDirHosts:
hostFilePath = os.path.join( vomsDirPath, "%s.lsc" % vomsHost )
try:
os.makedirs( path )
except Exception, e:
DIRAC.gLogger.error( "Could not create directory", str( e ) )
sys.exit( 1 )
vomsesLines = []
for vomsHost in vomsDirHosts:
hostFilePath = os.path.join( vomsDirPath, "%s.lsc" % vomsHost )
DN = DIRAC.gConfig.getValue( "/Registry/VOMS/Servers/%s/%s/DN" % ( voName, vomsHost ), "" )
CA = DIRAC.gConfig.getValue( "/Registry/VOMS/Servers/%s/%s/CA" % ( voName, vomsHost ), "" )
Port = DIRAC.gConfig.getValue( "/Registry/VOMS/Servers/%s/%s/Port" % ( voName, vomsHost ), 0 )
if not DN or not CA or not Port:
DIRAC.gLogger.error( 'DN = %s' % DN )
DIRAC.gLogger.error( 'CA = %s' % CA )
DIRAC.gLogger.error( 'Port = %s' % Port )
DIRAC.gLogger.error( 'Missing Parameter for %s' % vomsHost )
continue
fd = open( hostFilePath, "wb" )
fd.write( "%s\n%s\n" % ( DN, CA ) )
fd.close()
vomsesLines.append( '"%s" "%s" "%s" "%s" "%s" "24"' % ( voName, vomsHost, Port, DN, voName ) )
DIRAC.gLogger.notice( "Created vomsdir file %s" % hostFilePath )
except:
DIRAC.gLogger.exception( "Could not generate vomsdir file for host", vomsHost )

try:
DN = DIRAC.gConfig.getValue( "/Registry/VOMS/Servers/%s/%s/DN" % ( voName, vomsHost ), "" )
CA = DIRAC.gConfig.getValue( "/Registry/VOMS/Servers/%s/%s/CA" % ( voName, vomsHost ), "" )
Port = DIRAC.gConfig.getValue( "/Registry/VOMS/Servers/%s/%s/Port" % ( voName, vomsHost ), 0 )
if not DN or not CA or not Port:
DIRAC.gLogger.error( 'DN = %s' % DN )
DIRAC.gLogger.error( 'CA = %s' % CA )
DIRAC.gLogger.error( 'Port = %s' % Port )
DIRAC.gLogger.error( 'Missing Parameter for %s' % vomsHost )
continue
fd = open( hostFilePath, "wb" )
fd.write( "%s\n%s\n" % ( DN, CA ) )
vomsesFilePath = os.path.join( vomsesDirPath, voName )
fd = open( vomsesFilePath, "wb" )
fd.write( "%s\n" % "\n".join( vomsesLines ) )
fd.close()
vomsesLines.append( '"%s" "%s" "%s" "%s" "%s" "24"' % ( voName, vomsHost, Port, DN, voName ) )
DIRAC.gLogger.notice( "Created vomsdir file %s" % hostFilePath )
DIRAC.gLogger.notice( "Created vomses file %s" % vomsesFilePath )
except:
DIRAC.gLogger.exception( "Could not generate vomsdir file for host", vomsHost )

try:
vomsesFilePath = os.path.join( vomsesDirPath, voName )
fd = open( vomsesFilePath, "wb" )
fd.write( "%s\n" % "\n".join( vomsesLines ) )
fd.close()
DIRAC.gLogger.notice( "Created vomses file %s" % vomsesFilePath )
except:
DIRAC.gLogger.exception( "Could not generate vomses file" )
DIRAC.gLogger.exception( "Could not generate vomses file" )

if error:
sys.exit( 1 )

sys.exit( 0 )