def getSoftwareFolder(platform, appname, appversion):
    """ 
  Discover location of a given folder, either the local or the shared area

  :param string platform: platform
  :param string appname: name of the application
  :param string appversion: version of the application

  """
    res = checkCVMFS(platform, [appname, appversion])
    if res["OK"]:
        return S_OK(res['Value'][0])

    app_tar = Operations().getValue(
        '/AvailableTarBalls/%s/%s/%s/TarBall' %
        (platform, appname, appversion), '')
    if not app_tar:
        return S_ERROR("Could not find %s, %s name from CS" %
                       (appname, appversion))
    if app_tar.count("gz"):
        folder = app_tar.replace(".tgz", "").replace(".tar.gz", "")
    else:
        folder = app_tar

    localArea = getLocalAreaLocation()
    sharedArea = getSharedAreaLocation()
    if os.path.exists(os.path.join(localArea, folder)):
        mySoftwareRoot = localArea
    elif os.path.exists(os.path.join(sharedArea, folder)):
        mySoftwareRoot = sharedArea
    else:
        return S_ERROR('Missing installation of %s!' % folder)
    mySoftDir = os.path.join(mySoftwareRoot, folder)
    return S_OK(mySoftDir)
def getSoftwareFolder(platform, appname, appversion):
  """ 
  Discover location of a given folder, either the local or the shared area

  :param str platform: platform
  :param str appname: name of the application
  :param str appversion: version of the application

  """
  res = checkCVMFS(platform, [appname, appversion])
  if res["OK"]:
    return S_OK(res['Value'][0])
  
  app_tar = Operations().getValue('/AvailableTarBalls/%s/%s/%s/TarBall'%(platform, appname, appversion), '')  
  if not app_tar:
    return S_ERROR("Could not find %s, %s name from CS" % (appname, appversion) )
  if app_tar.count("gz"):
    folder = app_tar.replace(".tgz","").replace(".tar.gz", "")
  else:
    folder = app_tar
    
  localArea = getLocalAreaLocation()
  sharedArea = getSharedAreaLocation()
  if os.path.exists(os.path.join(localArea, folder)):
    mySoftwareRoot = localArea
  elif os.path.exists(os.path.join(sharedArea, folder)):
    mySoftwareRoot = sharedArea
  else:
    return S_ERROR('Missing installation of %s!' % folder)
  mySoftDir = os.path.join(mySoftwareRoot, folder)
  return S_OK(mySoftDir)
Example #3
0
    def getPluginParam(self, name, default=None):
        """ Get plugin parameters using specific settings or settings defined in the CS
        Caution: the type returned is that of the default value
    """
        # get the value of a parameter looking 1st in the CS
        if default is not None:
            valueType = type(default)
        else:
            valueType = None
        # First look at a generic value...
        optionPath = "TransformationPlugins/%s" % (name)
        value = Operations().getValue(optionPath, None)
        self.logVerbose("Default plugin param %s: '%s'" % (optionPath, value))
        # Then look at a plugin-specific value
        optionPath = "TransformationPlugins/%s/%s" % (self.plugin, name)
        value = Operations().getValue(optionPath, value)
        self.logVerbose("Specific plugin param %s: '%s'" % (optionPath, value))
        if value is not None:
            default = value
        # Finally look at a transformation-specific parameter
        value = self.params.get(name, default)
        self.logVerbose("Transformation plugin param %s: '%s'. Convert to %s" %
                        (name, value, str(valueType)))
        if valueType and not isinstance(value, valueType):
            if valueType is list:
                try:
                    value = ast.literal_eval(
                        value) if value and value != 'None' else []
                # literal_eval('SE-DST') -> ValueError
                # literal_eval('SE_MC-DST') -> SyntaxError
                # Don't ask...
                except (ValueError, SyntaxError):
                    value = [
                        val for val in value.replace(' ', '').split(',') if val
                    ]

            elif valueType is int:
                value = int(value)
            elif valueType is float:
                value = float(value)
            elif valueType is bool:
                if value in ('False', 'No', 'None', None, 0):
                    value = False
                else:
                    value = bool(value)
            elif valueType is not str:
                self.logWarn(
                    "Unknown parameter type (%s) for %s, passed as string" %
                    (str(valueType), name))
        self.logVerbose("Final plugin param %s: '%s'" % (name, value))
        return value
Example #4
0
  def getPluginParam(self, name, default=None):
    """ Get plugin parameters using specific settings or settings defined in the CS
        Caution: the type returned is that of the default value
    """
    # get the value of a parameter looking 1st in the CS
    if default is not None:
      valueType = type(default)
    else:
      valueType = None
    # First look at a generic value...
    optionPath = "TransformationPlugins/%s" % (name)
    value = Operations().getValue(optionPath, None)
    self.logVerbose("Default plugin param %s: '%s'" % (optionPath, value))
    # Then look at a plugin-specific value
    optionPath = "TransformationPlugins/%s/%s" % (self.plugin, name)
    value = Operations().getValue(optionPath, value)
    self.logVerbose("Specific plugin param %s: '%s'" % (optionPath, value))
    if value is not None:
      default = value
    # Finally look at a transformation-specific parameter
    value = self.params.get(name, default)
    self.logVerbose(
        "Transformation plugin param %s: '%s'. Convert to %s" %
        (name, value, str(valueType)))
    if valueType and not isinstance(value, valueType):
      if valueType is list:
        try:
          value = ast.literal_eval(value) if value and value != 'None' else []
        # literal_eval('SE-DST') -> ValueError
        # literal_eval('SE_MC-DST') -> SyntaxError
        # Don't ask...
        except (ValueError, SyntaxError):
          value = [val for val in value.replace(' ', '').split(',') if val]

      elif valueType is int:
        value = int(value)
      elif valueType is float:
        value = float(value)
      elif valueType is bool:
        if value in ('False', 'No', 'None', None, 0):
          value = False
        else:
          value = bool(value)
      elif valueType is not str:
        self.logWarn(
            "Unknown parameter type (%s) for %s, passed as string" %
            (str(valueType), name))
    self.logVerbose("Final plugin param %s: '%s'" % (name, value))
    return value
Example #5
0
def checkStatusTypes(statusTypes):
  '''
    To check if values for 'statusType' are valid
  '''

  opsH = Operations().getValue('ResourceStatus/Config/StatusTypes/StorageElement')
  acceptableStatusTypes = opsH.replace(',', '').split()

  for statusType in statusTypes:
    if statusType not in acceptableStatusTypes and statusType != 'all':
      acceptableStatusTypes.append('all')
      error("'%s' is a wrong value for switch 'statusType'.\n\tThe acceptable values are:\n\t%s"
            % (statusType, str(acceptableStatusTypes)))

  if 'all' in statusType:
    return acceptableStatusTypes
  return statusTypes
Example #6
0
def checkStatusTypes(statusTypes):
  '''
    To check if values for 'statusType' are valid
  '''

  opsH = Operations().getValue('ResourceStatus/Config/StatusTypes/StorageElement')
  acceptableStatusTypes = opsH.replace(',', '').split()

  for statusType in statusTypes:
    if statusType not in acceptableStatusTypes and statusType != 'all':
      acceptableStatusTypes.append('all')
      subLogger.error("'%s' is a wrong value for switch 'statusType'.\n\tThe acceptable values are:\n\t%s"
                      % (statusType, str(acceptableStatusTypes)))

  if 'all' in statusType:
    return acceptableStatusTypes
  return statusTypes
Example #7
0
def checkStatusTypes(statusTypes):
    """
    To check if values for 'statusType' are valid
    """

    opsH = Operations().getValue(
        "ResourceStatus/Config/StatusTypes/StorageElement")
    acceptableStatusTypes = opsH.replace(",", "").split()

    for statusType in statusTypes:
        if statusType not in acceptableStatusTypes and statusType != "all":
            acceptableStatusTypes.append("all")
            subLogger.error(
                "'%s' is a wrong value for switch 'statusType'.\n\tThe acceptable values are:\n\t%s"
                % (statusType, str(acceptableStatusTypes)))

    if "all" in statusType:
        return acceptableStatusTypes
    return statusTypes
Example #8
0
def checkStatusTypes(statusTypes):
    """
    To check if values for 'statusType' are valid
  """

    opsH = Operations().getValue("ResourceStatus/Config/StatusTypes/StorageElement")
    acceptableStatusTypes = opsH.replace(",", "").split()

    for statusType in statusTypes:
        if not statusType in acceptableStatusTypes and statusType != "all":
            acceptableStatusTypes.append("all")
            error(
                "'%s' is a wrong value for switch 'statusType'.\n\tThe acceptable values are:\n\t%s"
                % (statusType, str(acceptableStatusTypes))
            )

    if "all" in statusType:
        return acceptableStatusTypes
    else:
        return statusTypes
Example #9
0
 def getPluginParam( self, name, default = None ):
   """ Get plugin parameters using specific settings or settings defined in the CS
       Caution: the type returned is that of the default value
   """
   # get the value of a parameter looking 1st in the CS
   if default != None:
     valueType = type( default )
   else:
     valueType = None
   # First look at a generic value...
   optionPath = "TransformationPlugins/%s" % ( name )
   value = Operations().getValue( optionPath, None )
   self.logDebug( "Default plugin param %s: '%s'" % ( optionPath, value ) )
   # Then look at a plugin-specific value
   optionPath = "TransformationPlugins/%s/%s" % ( self.plugin, name )
   value = Operations().getValue( optionPath, value )
   self.logDebug( "Specific plugin param %s: '%s'" % ( optionPath, value ) )
   if value != None:
     default = value
   # Finally look at a transformation-specific parameter
   value = self.params.get( name, default )
   self.logDebug( "Transformation plugin param %s: '%s'" % ( name, value ) )
   if valueType and type( value ) != valueType:
     if valueType is list:
       try:
         value = ast.literal_eval( value )
       except Exception:
         value = [val for val in value.replace( ' ', '' ).split( ',' ) if val]
     elif valueType is int:
       value = int( value )
     elif valueType is float:
       value = float( value )
     elif valueType is bool:
       if value in ( 'False', 'No' ):
         value = False
       else:
         value = bool( value )
     elif valueType is not str:
       self.logWarn( "Unknown parameter type (%s) for %s, passed as string" % ( str( valueType ), name ) )
   self.logDebug( "Final plugin param %s: '%s'" % ( name, value ) )
   return value
Example #10
0
def sendMail(msg=''):
    """ send a notification mail when no platform is found
  """
    from DIRAC import gConfig
    from DIRAC.FrameworkSystem.Client.NotificationClient import NotificationClient
    from DIRAC.ConfigurationSystem.Client.Helpers.Operations import Operations

    mailAddress = Operations().getValue('EMail/JobFailures',
                                        '*****@*****.**')
    site = gConfig.getValue('LocalSite/Site')
    ce = gConfig.getValue('LocalSite/GridCE')
    queue = gConfig.getValue('LocalSite/CEQueue')
    body = "*** THIS IS AN AUTOMATED MESSAGE ***" + '\n\n' + msg + '\n\n'
    body = body + "At site %s, CE = %s, queue = %s" % (site, ce,
                                                       queue) + '\n\n'

    for mA in mailAddress.replace(' ', '').split(','):
        NotificationClient().sendMail(mailAddress,
                                      "Problem with DIRAC architecture",
                                      body,
                                      '*****@*****.**',
                                      localAttempt=False)