Exemple #1
0
def getStorageElementEndpoint(seName):
    """Get endpoints of a StorageElement

    :param str seName: name of the storage element

    :returns: S_OK() or S_ERROR
              for historical reasons, if the protocol is SRM, you get  'httpg://host:port/WSUrl'
              For other protocols, you get :py:meth:`~DIRAC.Resources.Storage.StorageBase.StorageBase.getEndpoint`

    """
    seParameters = getSEParameters(seName)
    if not seParameters["OK"]:
        gLogger.warn("Could not get SE parameters", "for SE %s" % seName)
        return seParameters

    seEndpoints = []

    for parameters in seParameters["Value"]:
        if parameters["Protocol"].lower() == "srm":
            # we need to construct the URL with httpg://
            host = parameters["Host"]
            port = parameters["Port"]
            wsurl = parameters["WSUrl"]
            # MAYBE wusrl is not defined
            if host and port:
                url = "httpg://%s:%s%s" % (host, port, wsurl)
                url = url.replace("?SFN=", "")
                seEndpoints.append(url)
        else:
            seEndpoints.append(parameters["Endpoint"])

    return S_OK(seEndpoints)
Exemple #2
0
def getSEToken(seName):
  """ Get StorageElement token
  """

  seParameters = getSEParameters(seName)
  if not seParameters['OK']:
    gLogger.warn("Could not get SE parameters", "SE: %s" % seName)
    return seParameters

  return S_OK(seParameters['Value']['SpaceToken'])