def get_reporting_data(self, resource_id):
        from reporter import ReportingData

        for resource in self.wrapped_state.resource:
            if resource_id != resource.resource_id:
                continue

            # How much capacity does this server have for this resource?
            if resource.HasField('has'):
                has = resource.has.capacity
            else:
                has = 0

            data = ReportingData()
            data.wants = sum_wants(resource)
            data.has = has
            data.leases = sum_leases(resource)
            data.outstanding = sum_outstanding(resource)

            return data

        # Asking for reporting data for a resource that is not (yet)
        # int the configuration. This can happen if we are getting
        # resource data just after this server has become the master
        # and it has not seen any client calls for the resource yet.
        return None
  def get_reporting_data(self, resource_id):
    from reporter import ReportingData

    for resource in self.wrapped_state.resource:
      if resource_id != resource.resource_id:
        continue

      # How much capacity does this server have for this resource?
      if resource.HasField('has'):
        has = resource.has.capacity
      else:
        has = 0

      data = ReportingData()
      data.wants = sum_wants(resource)
      data.has = has
      data.leases = sum_leases(resource)
      data.outstanding = sum_outstanding(resource)

      return data

    # Asking for reporting data for a resource that is not (yet)
    # int the configuration. This can happen if we are getting
    # resource data just after this server has become the master
    # and it has not seen any client calls for the resource yet.
    return None
Beispiel #3
0
  def get_reporting_data(self, resource_id):
    from reporter import ReportingData

    resource = self._find_resource(resource_id)
    data = ReportingData()
    data.wants = resource.wants
    data.has = resource.has.capacity

    return data