Esempio n. 1
0
 def get_identity_object(self, consumer_uuid):
     _LOG.info("Found ID from identity certificate is '%s' " % (consumer_uuid))
     identity = ConsumerIdentity.objects(uuid=UUID(consumer_uuid)).first()
     if not identity:
         # Lookup if we have a cached response for this uuid
         cached_status_code = identity_lookup.get_cached_status_code(consumer_uuid)
         if cached_status_code:
             _LOG.info("Found cached lookup for '%s' with status_code '%s'" % (consumer_uuid, cached_status_code))
             if cached_status_code == 404:
                 raise NotFoundConsumerIdentity(consumer_uuid)
             else:
                 raise UnexpectedStatusCodeException(consumer_uuid, cached_status_code)
         # If not, create a new lookup and query parent
         _LOG.info("Couldn't find RHIC with ID '%s', will query parent" % (consumer_uuid))
         identity_lookup.create_rhic_lookup_task(consumer_uuid)
         raise UnknownConsumerIdentity(consumer_uuid)
     return identity
def test():
    # Create a task
    uuid = "fb647f68-aa01-4171-b62b-35c2984a5328"
    lookup_task = identity_lookup.create_rhic_lookup_task(uuid)
    print "Lookup Task: %s" % (lookup_task)
    task_id = lookup_task.task_id
    result = AsyncResult(task_id)
    #result = tasks.sync_single_rhic.apply_async((uuid,))
    print "result.state = %s" % (result.state)
    print "Wait 15 seconds"
    time.sleep(15)
    result = AsyncResult(task_id)
    print "Result: result.state = %s" % (result.state)
Esempio n. 3
0
 def handle_rhic_lookup(self, rhic_uuid):
     """
     Will look up if an existing lookup is in progress for this RHIC.
     If a task is found, will return it's status code if completed, or 202 to signal in progress
     If a task is not found, will create a new task and return 202 to signal in progress
     @param rhic_uuid:
     @return: status code to return for request
     @rtype: int
     """
     _LOG.info("Processing rhic_lookup for an unknown RHIC of UUID '%s' " % (rhic_uuid))
     task = get_current_rhic_lookup_tasks(rhic_uuid)
     if task:
         if task.completed:
             ret_code = 404
             if task.status_code:
                 ret_code = task.status_code
             _LOG.info("Using cached value %s" % (task))
             return ret_code
         else:
             _LOG.info("Lookup task in progress: %s" % (task))
             return 202
     task = identity_lookup.create_rhic_lookup_task(rhic_uuid)
     _LOG.info("Initiated new lookup task: %s" % (task))
     return 202