diff --git a/Core/scripts/dirac-configure.py b/Core/scripts/dirac-configure.py index 43f9f00c2b4..d5a900ba055 100644 --- a/Core/scripts/dirac-configure.py +++ b/Core/scripts/dirac-configure.py @@ -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 @@ -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 )