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