Beispiel #1
0
    def doNew(self, masterParams=None):
        """
    Gets the parameters to run, either from the master method or from its
    own arguments.

    Gets the total and the free disk space of a storage element
    and inserts the results in the SpaceTokenOccupancyCache table
    of ResourceManagementDB database.

    The result is also returned to the caller, not only inserted.
    What is inserted in the DB will normally be in MB,
    what is returned will be in the specified unit.
    """

        if masterParams is not None:
            elementName, unit = masterParams
        else:
            params = self._prepareCommand()
            if not params['OK']:
                return params
            elementName, unit = params['Value']

        endpointResult = CSHelpers.getStorageElementEndpoint(elementName)
        if not endpointResult['OK']:
            return endpointResult

        se = StorageElement(elementName)
        occupancyResult = se.getOccupancy(unit=unit)
        if not occupancyResult['OK']:
            return occupancyResult
        occupancy = occupancyResult['Value']
        free = occupancy['Free']
        total = occupancy['Total']
        spaceReservation = occupancy.get('SpaceReservation', '')
        # We only take the first one, in case there are severals.
        # Most probably not ideal, because it would be nice to stay
        # consistent, but well...
        endpoint = endpointResult['Value'][0]

        results = {
            'Endpoint': endpoint,
            'Free': free,
            'Total': total,
            'SpaceReservation': spaceReservation,
            'ElementName': elementName
        }
        result = self._storeCommand(results)
        if not result['OK']:
            return result

        return S_OK({'Free': free, 'Total': total})
Beispiel #2
0
    def doNew(self, masterParams=None):
        """
        Gets the parameters to run, either from the master method or from its
        own arguments.

        Gets the total and the free disk space of a storage element
        and inserts the results in the SpaceTokenOccupancyCache table
        of ResourceManagementDB database.

        The result is also returned to the caller, not only inserted.
        What is inserted in the DB will normally be in MB,
        what is returned will be in the specified unit.
        """

        if masterParams is not None:
            elementName, unit = masterParams
        else:
            params = self._prepareCommand()
            if not params["OK"]:
                return params
            elementName, unit = params["Value"]

        se = StorageElement(elementName)
        occupancyResult = se.getOccupancy(unit=unit)
        if not occupancyResult["OK"]:
            return occupancyResult
        occupancy = occupancyResult["Value"]
        free = occupancy["Free"]
        total = occupancy["Total"]

        endpointResult = CSHelpers.getStorageElementEndpoint(elementName)
        if not endpointResult["OK"]:
            return endpointResult
        # We only take the first endpoint, in case there are severals of them (which is normal).
        # Most probably not ideal, because it would be nice to stay consistent, but well...
        endpoint = endpointResult["Value"][0]

        results = {
            "Endpoint": endpoint,
            "Free": free,
            "Total": total,
            "ElementName": elementName
        }
        result = self._storeCommand(results)
        if not result["OK"]:
            return result

        return S_OK({"Free": free, "Total": total})
Beispiel #3
0
    def doNew(self, masterParams=None):
        """
    Gets the parameters to run, either from the master method or from its
    own arguments.

    Gets the total and the free disk space of a storage element
    and inserts the results in the SpaceTokenOccupancyCache table
    of ResourceManagementDB database.

    The result is also returned to the caller, not only inserted.
    What is inserted in the DB will normally be in MB,
    what is returned will be in the specified unit.
    """

        if masterParams is not None:
            elementName, unit = masterParams
        else:
            params = self._prepareCommand()
            if not params['OK']:
                return params
            elementName, unit = params['Value']

        endpointResult = CSHelpers.getStorageElementEndpoint(elementName)
        if not endpointResult['OK']:
            return endpointResult

        se = StorageElement(elementName)
        occupancyResult = se.getOccupancy(unit=unit)
        if not occupancyResult['OK']:
            return occupancyResult
        occupancy = occupancyResult['Value']
        free = occupancy['Free']
        total = occupancy['Total']

        results = {
            'Endpoint': endpointResult['Value'],
            'Free': free,
            'Total': total,
            'ElementName': elementName
        }
        result = self._storeCommand(results)
        if not result['OK']:
            return result

        return S_OK({'Free': free, 'Total': total})
  def doNew(self, masterParams=None):
    """
    Gets the parameters to run, either from the master method or from its
    own arguments.

    Gets the total and the free disk space of a storage element
    and inserts the results in the SpaceTokenOccupancyCache table
    of ResourceManagementDB database.

    The result is also returned to the caller, not only inserted.
    What is inserted in the DB will normally be in MB,
    what is returned will be in the specified unit.
    """

    if masterParams is not None:
      elementName, unit = masterParams
    else:
      params = self._prepareCommand()
      if not params['OK']:
        return params
      elementName, unit = params['Value']

    endpointResult = CSHelpers.getStorageElementEndpoint(elementName)
    if not endpointResult['OK']:
      return endpointResult

    se = StorageElement(elementName)
    occupancyResult = se.getOccupancy(unit=unit)
    if not occupancyResult['OK']:
      return occupancyResult
    occupancy = occupancyResult['Value']
    free = occupancy['Free']
    total = occupancy['Total']

    results = {'Endpoint': endpointResult['Value'],
               'Free': free,
               'Total': total,
               'ElementName': elementName}
    result = self._storeCommand(results)
    if not result['OK']:
      return result

    return S_OK({'Free': free, 'Total': total})