def scheduled_call_to_report_dict(scheduled_call): """ Build a report dict from a scheduled call. @param scheduled_call: scheduled call to build report for @type scheduled_call: BSON @return: report dict @rtype: dict """ report = subdict(scheduled_call, SCHEDULE_REPORT_FIELDS) call_request = call.CallRequest.deserialize(scheduled_call['serialized_call_request']) report['call_request'] = call_request report['_id'] = str(scheduled_call['_id']) return report
def scheduled_call_to_report_dict(scheduled_call): """ Translate a scheduled call to a scheduled call report dictionary. :param scheduled_call: scheduled call to translate :type scheduled_call: bson.BSON :return: scheduled call report dictionary :rtype: dict """ report = subdict(scheduled_call, SCHEDULE_REPORT_FIELDS) report['_id'] = str(scheduled_call['_id']) report['call_request'] = call.CallRequest.deserialize(scheduled_call['serialized_call_request']) return report
def scheduled_call_to_report_dict(scheduled_call): """ Build a report dict from a scheduled call. @param scheduled_call: scheduled call to build report for @type scheduled_call: BSON @return: report dict @rtype: dict """ call_request = call.CallRequest.deserialize(scheduled_call['serialized_call_request']) report = subdict(scheduled_call, SCHEDULE_REPORT_FIELDS) report['call_request'] = call_request report['_id'] = str(scheduled_call['_id']) return report
def filter_dicts(dicts, fields): """ Filter an iterable a dicts, returning dicts that only have the keys and corresponding values for the passed in fields. @param dicts: iterable of dicts to filter @type dicts: iterable of dicts @param fields: iterable of keys to retain @type fields: iterable @return: list of dicts with keys only found in the passed in fields @rtype: list of dicts """ filtered_dicts = [] for d in dicts: s = subdict(d, fields) filtered_dicts.append(s) return filtered_dicts
def _validate_call_request_dependencies(self, task): """ Validate a task's call request dependencies. NOTE: A task cannot be blocked by a task that is not currently (already) in the task queue @param task: task to have its call request dependencies validated @type task: pulp.server.dispatch.task.Task """ self.__lock.acquire() try: valid_call_request_dependency_ids = [] for potential_blocking_task in itertools.chain(self.__running_tasks, self.__waiting_tasks): if potential_blocking_task.call_request.id not in task.call_request.dependencies: continue valid_call_request_dependency_ids.append(potential_blocking_task.call_request.id) # DANGER this ignores valid call complete states of dependencies!! task.call_request.dependencies = subdict(task.call_request.dependencies, valid_call_request_dependency_ids) finally: self.__lock.release()
def _validate_call_request_dependencies(self, task): """ Validate a task's call request dependencies. NOTE: A task cannot be blocked by a task that is not currently (already) in the task queue @param task: task to have its call request dependencies validated @type task: pulp.server.dispatch.task.Task """ self.__lock.acquire() try: valid_call_request_dependency_ids = [] for potential_blocking_task in itertools.chain( self.__running_tasks, self.__waiting_tasks): if potential_blocking_task.call_request.id not in task.call_request.dependencies: continue valid_call_request_dependency_ids.append( potential_blocking_task.call_request.id) # DANGER this ignores valid call complete states of dependencies!! task.call_request.dependencies = subdict( task.call_request.dependencies, valid_call_request_dependency_ids) finally: self.__lock.release()