diff --git a/Interfaces/API/Dirac.py b/Interfaces/API/Dirac.py index 1b97fcb0b59..b03388133dc 100755 --- a/Interfaces/API/Dirac.py +++ b/Interfaces/API/Dirac.py @@ -82,7 +82,7 @@ def __init__( self, withRepo = False, repoLocation = '', jobManagerClient = Fals self.client = WMSClient( jobManagerClient, sbRPCClient, sbTransferClient, useCertificates ) self.pPrint = pprint.PrettyPrinter() # Determine the default file catalog - defaultFC = gConfig.getValue( self.section + '/FileCatalog', '' ) + defaultFC = gConfig.getValue( self.section + '/FileCatalog', [] ) if not defaultFC: result = gConfig.getSections( 'Resources/FileCatalogs', listOrdered = True ) if result['OK']: @@ -1018,17 +1018,17 @@ def runLocal( self, jobJDL, jobXML, baseDir, disableCopies = False, disableCallb def __printOutput( self, fd = None, message = '' ): """Internal callback function to return standard output when running locally. """ - if fd: - if type(fd) == types.IntType: + if fd: + if type( fd ) == types.IntType: if fd == 0: print >> sys.stdout, message elif fd == 1: print >> sys.stderr, message else: print message - elif type(fd) == types.FileType: - print >> fd, message - else: + elif type( fd ) == types.FileType: + print >> fd, message + else: print message ############################################################################# @@ -2813,11 +2813,11 @@ def __printInfo( self ): self.log.info( '<=====%s=====>' % ( self.diracInfo ) ) self.log.verbose( self.cvsVersion ) self.log.verbose( 'DIRAC is running at %s in setup %s' % ( DIRAC.siteName(), self.setup ) ) - - def getConfigurationValue(self,option,default): + + def getConfigurationValue( self, option, default ): """ Export the configuration client getValue() function - """ - - return gConfig.getValue(option,default) + """ + + return gConfig.getValue( option, default ) #EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF diff --git a/Interfaces/scripts/dirac-admin-add-host.py b/Interfaces/scripts/dirac-admin-add-host.py index 95968d770e5..87241e1f0fa 100644 --- a/Interfaces/scripts/dirac-admin-add-host.py +++ b/Interfaces/scripts/dirac-admin-add-host.py @@ -70,7 +70,7 @@ def addProperty( arg ): Script.gLogger.info( "Setting property %s to %s" % ( pName, pValue ) ) hostProps[ pName ] = pValue -if not diracAdmin.csModifyHost( hostName, hostProps, createIfNonExistant = True )['Value']: +if not diracAdmin.csModifyHost( hostName, hostProps, createIfNonExistant = True )['OK']: errorList.append( ( "add host", "Cannot register host %s" % hostName ) ) exitCode = 255 else: diff --git a/Resources/Storage/StorageElement.py b/Resources/Storage/StorageElement.py index b7cdc0c5b9f..b72b8e52683 100755 --- a/Resources/Storage/StorageElement.py +++ b/Resources/Storage/StorageElement.py @@ -87,6 +87,9 @@ def dump( self ): Dump to the logger a summary of the StorageElement items """ gLogger.info( "StorageElement.dump: Preparing dump for StorageElement %s." % self.name ) + if not self.valid: + gLogger.error( "StorageElement.dump: Failed to create StorageElement plugins.", self.errorReason ) + return i = 1 outStr = "\n\n============ Options ============\n" for key in sortList( self.options.keys() ): diff --git a/WorkloadManagementSystem/Agent/SiteDirector.py b/WorkloadManagementSystem/Agent/SiteDirector.py index 89ed4c4608d..f4266a3d864 100644 --- a/WorkloadManagementSystem/Agent/SiteDirector.py +++ b/WorkloadManagementSystem/Agent/SiteDirector.py @@ -46,18 +46,18 @@ def initialize( self ): self.am_setOption( "PollingTime", 60.0 ) self.am_setOption( "maxPilotWaitingHours", 6 ) self.queueDict = {} - + return S_OK() - + def beginExecution( self ): - self.gridEnv = self.am_getOption( "GridEnv", getGridEnv() ) + self.gridEnv = self.am_getOption( "GridEnv", getGridEnv() ) self.genericPilotDN = self.am_getOption( 'GenericPilotDN', 'Unknown' ) self.genericPilotGroup = self.am_getOption( 'GenericPilotGroup', 'Unknown' ) self.pilot = DIRAC_PILOT self.install = DIRAC_INSTALL self.workingDirectory = self.am_getOption( 'WorkDirectory' ) - self.maxQueueLength = self.am_getOption( 'MaxQueueLength', 86400*3 ) + self.maxQueueLength = self.am_getOption( 'MaxQueueLength', 86400 * 3 ) # Flags self.updateStatus = self.am_getOption( 'UpdatePilotStatus', True ) @@ -73,7 +73,7 @@ def beginExecution( self ): else: siteNames = [siteName] self.siteNames = siteNames - + if self.updateStatus: self.log.always( 'Pilot status update requested' ) if self.getOutput: @@ -198,7 +198,7 @@ def execute( self ): """ if not self.queueDict: - self.log.warn('No site defined, exiting the cycle') + self.log.warn( 'No site defined, exiting the cycle' ) return S_OK() result = self.submitJobs() @@ -283,7 +283,13 @@ def submitJobs( self ): self.log.info( 'Going to submit %d pilots to %s queue' % ( pilotsToSubmit, queue ) ) bundleProxy = self.queueDict[queue].get( 'BundleProxy', False ) - result = self.__getExecutable( queue, pilotsToSubmit, bundleProxy ) + jobExecDir = '' + if ceType == 'CREAM': + jobExecDir = '.' + jobExecDir = self.queueDict[queue].get( 'JobExecDir', jobExecDir ) + httpProxy = self.queueDict[queue].get( 'BundleProxy', '' ) + + result = self.__getExecutable( queue, pilotsToSubmit, bundleProxy, httpProxy, jobExecDir ) if not result['OK']: return result @@ -338,7 +344,7 @@ def submitJobs( self ): return S_OK() ##################################################################################### - def __getExecutable( self, queue, pilotsToSubmit, bundleProxy = True ): + def __getExecutable( self, queue, pilotsToSubmit, bundleProxy = True, httpProxy = '', jobExecDir = '' ): """ Prepare the full executable for queue """ @@ -348,7 +354,7 @@ def __getExecutable( self, queue, pilotsToSubmit, bundleProxy = True ): pilotOptions = self.__getPilotOptions( queue, pilotsToSubmit ) if pilotOptions is None: return S_ERROR( 'Errors in compiling pilot options' ) - executable = self.__writePilotScript( self.workingDirectory, pilotOptions, proxy ) + executable = self.__writePilotScript( self.workingDirectory, pilotOptions, proxy, httpProxy, jobExecDir ) result = S_OK( executable ) return result @@ -359,8 +365,8 @@ def __getPilotOptions( self, queue, pilotsToSubmit ): queueDict = self.queueDict[queue]['ParametersDict'] - vo = Registry.getVOForGroup(self.genericPilotGroup) - + vo = Registry.getVOForGroup( self.genericPilotGroup ) + if not vo: self.log.error( 'Virtual Organization is not defined in the configuration' ) return None @@ -426,7 +432,7 @@ def __getPilotOptions( self, queue, pilotsToSubmit ): return pilotOptions ##################################################################################### - def __writePilotScript( self, workingDirectory, pilotOptions, proxy = '', httpProxy = '' ): + def __writePilotScript( self, workingDirectory, pilotOptions, proxy = '', httpProxy = '', pilotExecDir = '' ): """ Bundle together and write out the pilot executable script, admixt the proxy if given """ @@ -447,7 +453,11 @@ def __writePilotScript( self, workingDirectory, pilotOptions, proxy = '', httpPr # import os, tempfile, sys, shutil, base64, bz2 try: - pilotWorkingDirectory = tempfile.mkdtemp( suffix = 'pilot', prefix= 'DIRAC_' ) + pilotExecDir = '%(pilotExecDir)s' + if not pilotExecDir: + pilotExecDir = None + pilotWorkingDirectory = tempfile.mkdtemp( suffix = 'pilot', prefix = 'DIRAC_', dir = pilotExecDir ) + pilotWorkingDirectory = os.path.realpath( pilotWorkingDirectory ) os.chdir( pilotWorkingDirectory ) if %(proxyFlag)s: open( 'proxy', "w" ).write(bz2.decompress( base64.decodestring( "%(compressedAndEncodedProxy)s" ) ) ) @@ -479,11 +489,12 @@ def __writePilotScript( self, workingDirectory, pilotOptions, proxy = '', httpPr shutil.rmtree( pilotWorkingDirectory ) EOF -""" % { 'compressedAndEncodedProxy': compressedAndEncodedProxy, \ - 'compressedAndEncodedPilot': compressedAndEncodedPilot, \ - 'compressedAndEncodedInstall': compressedAndEncodedInstall, \ - 'httpProxy': httpProxy, \ - 'pilotScript': os.path.basename( self.pilot ), \ +""" % { 'compressedAndEncodedProxy': compressedAndEncodedProxy, + 'compressedAndEncodedPilot': compressedAndEncodedPilot, + 'compressedAndEncodedInstall': compressedAndEncodedInstall, + 'httpProxy': httpProxy, + 'pilotExecDir': pilotExecDir, + 'pilotScript': os.path.basename( self.pilot ), 'installScript': os.path.basename( self.install ), 'pilotOptions': ' '.join( pilotOptions ), 'proxyFlag': proxyFlag }