def __addUserDataToConfiguration(self): if not self.isParsed: self.__parseCommandLine() errorsList = self.__loadCFGFiles() if gConfigurationData.getServers(): retVal = self.syncRemoteConfiguration() if not retVal['OK']: return retVal else: gLogger.warn("Running without remote configuration") try: if self.componentType == "service": self.__setDefaultSection(getServiceSection(self.componentName)) elif self.componentType == "agent": self.__setDefaultSection(getAgentSection(self.componentName)) elif self.componentType == "executor": self.__setDefaultSection(getExecutorSection( self.componentName)) elif self.componentType == "web": self.__setDefaultSection("/%s" % self.componentName) elif self.componentType == "script": if self.componentName and self.componentName[0] == "/": self.__setDefaultSection(self.componentName) self.componentName = self.componentName[1:] else: self.__setDefaultSection("/Scripts/%s" % self.componentName) else: self.__setDefaultSection("/") except Exception, e: errorsList.append(str(e))
def __addUserDataToConfiguration( self ): if not self.isParsed: self.__parseCommandLine() errorsList = self.__loadCFGFiles() if gConfigurationData.getServers(): retVal = self.syncRemoteConfiguration() if not retVal[ 'OK' ]: return retVal else: gLogger.warn( "Running without remote configuration" ) try: if self.componentType == "service": self.__setDefaultSection( getServiceSection( self.componentName ) ) elif self.componentType == "agent": self.__setDefaultSection( getAgentSection( self.componentName ) ) elif self.componentType == "executor": self.__setDefaultSection( getExecutorSection( self.componentName ) ) elif self.componentType == "web": self.__setDefaultSection( "/%s" % self.componentName ) elif self.componentType == "script": if self.componentName and self.componentName[0] == "/": self.__setDefaultSection( self.componentName ) self.componentName = self.componentName[1:] else: self.__setDefaultSection( "/Scripts/%s" % self.componentName ) else: self.__setDefaultSection( "/" ) except Exception, e: errorsList.append( str( e ) )
def checkDescription( self ): """ Check that the description is OK """ for k in [ 'OwnerName', 'OwnerDN', 'OwnerGroup', 'DIRACSetup' ]: if k not in self.__description: return S_ERROR( "Missing var %s in description" % k ) # Check CPUTime result = self.__checkNumericalVarInDescription( "CPUTime", 86400, 0, 500000 ) if not result[ 'OK' ]: return result result = self.__checkNumericalVarInDescription( "Priority", 1, 0, 10 ) if not result[ 'OK' ]: return result allowedSubmitPools = [] for option in [ "DefaultSubmitPools", "SubmitPools", "AllowedSubmitPools" ]: allowedSubmitPools += gConfig.getValue( "%s/%s" % ( getAgentSection( "WorkloadManagement/TaskQueueDirector" ), option ), [] ) result = self.__checkMultiChoiceInDescription( "SubmitPools", list( set( allowedSubmitPools ) ) ) if not result[ 'OK' ]: return result result = self.__checkMultiChoiceInDescription( "PilotTypes", [ 'private' ] ) if not result[ 'OK' ]: return result maxInputData = Operations().getValue( "JobDescription/MaxInputData", 500 ) result = self.__checkMaxInputData( maxInputData ) if not result[ 'OK' ]: return result transformationTypes = Operations().getValue( "Transformations/DataProcessing", [] ) result = self.__checkMultiChoiceInDescription( "JobType", ['User', 'SAM', 'Hospital'] + transformationTypes ) return S_OK()
def check( self ): """ Check that the manifest is OK """ for k in [ 'OwnerName', 'OwnerDN', 'OwnerGroup', 'DIRACSetup' ]: if k not in self.__manifest: return S_ERROR( "Missing var %s in manifest" % k ) #Check CPUTime result = self.__checkNumericalVar( "CPUTime", 86400, 0, 500000 ) if not result[ 'OK' ]: return result result = self.__checkNumericalVar( "Priority", 1, 0, 10 ) if not result[ 'OK' ]: return result allowedSubmitPools = [] for option in [ "DefaultSubmitPools", "SubmitPools", "AllowedSubmitPools" ]: allowedSubmitPools = gConfig.getValue( "%s/%s" % ( getAgentSection( "WorkloadManagement/TaskQueueDirector" ), option ), allowedSubmitPools ) result = self.__checkMultiChoice( "SubmitPools", allowedSubmitPools ) if not result[ 'OK' ]: return result result = self.__checkMultiChoice( "PilotTypes", [ 'private' ] ) if not result[ 'OK' ]: return result result = self.__checkMaxInputData( 500 ) if not result[ 'OK' ]: return result result = self.__checkMultiChoice( "JobType", Operations().getValue( "JobDescription/AllowedJobTypes", [] ) ) if not result[ 'OK' ]: return result return S_OK()
def checkDescription( self ): """ Check that the description is OK """ for k in [ 'OwnerName', 'OwnerDN', 'OwnerGroup', 'DIRACSetup' ]: if k not in self.__description: return S_ERROR( "Missing var %s in description" % k ) # Check CPUTime result = self.__checkNumericalVarInDescription( "CPUTime", 86400, 0, 500000 ) if not result[ 'OK' ]: return result result = self.__checkNumericalVarInDescription( "Priority", 1, 0, 10 ) if not result[ 'OK' ]: return result allowedSubmitPools = [] for option in [ "DefaultSubmitPools", "SubmitPools", "AllowedSubmitPools" ]: allowedSubmitPools += gConfig.getValue( "%s/%s" % ( getAgentSection( "WorkloadManagement/TaskQueueDirector" ), option ), [] ) result = self.__checkMultiChoiceInDescription( "SubmitPools", list( set( allowedSubmitPools ) ) ) if not result[ 'OK' ]: return result result = self.__checkMultiChoiceInDescription( "PilotTypes", [ 'private' ] ) if not result[ 'OK' ]: return result maxInputData = Operations().getValue( "JobDescription/MaxInputData", 500 ) result = self.__checkMaxInputData( maxInputData ) if not result[ 'OK' ]: return result transformationTypes = Operations().getValue( "Transformations/DataProcessing", [] ) result = self.__checkMultiChoiceInDescription( "JobType", ['User', 'Test', 'Hospital'] + transformationTypes ) return S_OK()
def __addUserDataToConfiguration(self): if not self.isParsed: self.__parseCommandLine() errorsList = self.__loadCFGFiles() if gConfigurationData.getServers(): retVal = self.syncRemoteConfiguration() if not retVal['OK']: return retVal else: gLogger.warn("Running without remote configuration") try: if self.componentType == "service": self.__setDefaultSection(getServiceSection(self.componentName)) elif self.componentType == "agent": self.__setDefaultSection(getAgentSection(self.componentName)) elif self.componentType == "executor": self.__setDefaultSection(getExecutorSection( self.componentName)) elif self.componentType == "web": self.__setDefaultSection("/%s" % self.componentName) elif self.componentType == "script": if self.componentName and self.componentName[0] == "/": self.__setDefaultSection(self.componentName) self.componentName = self.componentName[1:] else: self.__setDefaultSection("/Scripts/%s" % self.componentName) else: self.__setDefaultSection("/") except Exception as e: errorsList.append(str(e)) self.unprocessedSwitches = [] for optionName, optionValue in self.parsedOptionList: optionName = optionName.lstrip("-") for definedOptionTuple in self.commandOptionList: if optionName == definedOptionTuple[0].replace(":", "") or \ optionName == definedOptionTuple[1].replace("=", ""): if definedOptionTuple[3]: retVal = definedOptionTuple[3](optionValue) if not isinstance(retVal, dict): errorsList.append( "Callback for switch '%s' does not return S_OK or S_ERROR" % optionName) elif not retVal['OK']: errorsList.append(retVal['Message']) else: self.unprocessedSwitches.append( (optionName, optionValue)) if len(errorsList) > 0: return S_ERROR("\n%s" % "\n".join(errorsList)) return S_OK()
def __addUserDataToConfiguration( self ): if not self.isParsed: self.__parseCommandLine() errorsList = self.__loadCFGFiles() if gConfigurationData.getServers(): retVal = self.syncRemoteConfiguration() if not retVal[ 'OK' ]: return retVal else: gLogger.warn( "Running without remote configuration" ) try: if self.componentType == "service": self.__setDefaultSection( getServiceSection( self.componentName ) ) elif self.componentType == "agent": self.__setDefaultSection( getAgentSection( self.componentName ) ) elif self.componentType == "executor": self.__setDefaultSection( getExecutorSection( self.componentName ) ) elif self.componentType == "web": self.__setDefaultSection( "/%s" % self.componentName ) elif self.componentType == "script": if self.componentName and self.componentName[0] == "/": self.__setDefaultSection( self.componentName ) self.componentName = self.componentName[1:] else: self.__setDefaultSection( "/Scripts/%s" % self.componentName ) else: self.__setDefaultSection( "/" ) except Exception as e: errorsList.append( str( e ) ) self.unprocessedSwitches = [] for optionName, optionValue in self.parsedOptionList: optionName = optionName.lstrip( "-" ) for definedOptionTuple in self.commandOptionList: if optionName == definedOptionTuple[0].replace( ":", "" ) or \ optionName == definedOptionTuple[1].replace( "=", "" ): if definedOptionTuple[3]: retVal = definedOptionTuple[3]( optionValue ) if type( retVal ) != types.DictType: errorsList.append( "Callback for switch '%s' does not return S_OK or S_ERROR" % optionName ) elif not retVal[ 'OK' ]: errorsList.append( retVal[ 'Message' ] ) else: self.unprocessedSwitches.append( ( optionName, optionValue ) ) if len( errorsList ) > 0: return S_ERROR( "\n%s" % "\n".join( errorsList ) ) return S_OK()
def checkDescription(self): """ Check that the description is OK """ for k in ['OwnerName', 'OwnerDN', 'OwnerGroup', 'DIRACSetup']: if k not in self.__description: return S_ERROR("Missing var %s in description" % k) #Check CPUTime result = self.__checkNumericalVarInDescription("CPUTime", 86400, 0, 500000) if not result['OK']: return result result = self.__checkNumericalVarInDescription("Priority", 1, 0, 10) if not result['OK']: return result allowedSubmitPools = [] for option in [ "DefaultSubmitPools", "SubmitPools", "AllowedSubmitPools" ]: allowedSubmitPools = gConfig.getValue( "%s/%s" % (getAgentSection("WorkloadManagement/TaskQueueDirector"), option), allowedSubmitPools) result = self.__checkMultiChoiceInDescription("SubmitPools", allowedSubmitPools) if not result['OK']: return result result = self.__checkMultiChoiceInDescription("PilotTypes", ['private']) if not result['OK']: return result result = self.__checkMaxInputData(500) if not result['OK']: return result result = self.__checkMultiChoiceInDescription( "JobType", Operations().getValue("JobDescription/AllowedJobTypes", [])) if not result['OK']: #HACK to maintain backwards compatibility #If invalid set to "User" #HACKEXPIRATION 05/2009 self.setVar("JobType", "User") #Uncomment after deletion of hack #return result return S_OK()
def checkDescription(self): """ Check that the description is OK """ for k in ["OwnerName", "OwnerDN", "OwnerGroup", "DIRACSetup"]: if k not in self.__description: return S_ERROR("Missing var %s in description" % k) # Check CPUTime result = self.__checkNumericalVarInDescription("CPUTime", 86400, 0, 500000) if not result["OK"]: return result result = self.__checkNumericalVarInDescription("Priority", 1, 0, 10) if not result["OK"]: return result allowedSubmitPools = [] for option in ["DefaultSubmitPools", "SubmitPools", "AllowedSubmitPools"]: allowedSubmitPools = gConfig.getValue( "%s/%s" % (getAgentSection("WorkloadManagement/TaskQueueDirector"), option), allowedSubmitPools ) result = self.__checkMultiChoiceInDescription("SubmitPools", allowedSubmitPools) if not result["OK"]: return result result = self.__checkMultiChoiceInDescription("PilotTypes", ["private"]) if not result["OK"]: return result result = self.__checkMaxInputData(500) if not result["OK"]: return result result = self.__checkMultiChoiceInDescription( "JobType", Operations().getValue("JobDescription/AllowedJobTypes", []) ) if not result["OK"]: # HACK to maintain backwards compatibility # If invalid set to "User" # HACKEXPIRATION 05/2009 self.setVar("JobType", "User") # Uncomment after deletion of hack # return result return S_OK()