예제 #1
0
    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))
예제 #2
0
  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 ) )
예제 #3
0
    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()
예제 #4
0
  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()