Exemplo n.º 1
0
    def test_delete_rhic_lookup(self):
        self.assertFalse(identity.delete_rhic_lookup(None))

        task = RHICLookupTask(uuid=self.dummy_uuid)
        task.save()
        self.assertTrue(identity.delete_rhic_lookup(task))
        self.assertEquals(len(RHICLookupTask.objects()), 0)
Exemplo n.º 2
0
def complete_rhic_lookup_task(uuid, status_code):
    """
    @param uuid: RHIC uuid
    @param status_code: HTTP status code from RHIC lookup
    @return: None
    """
    _LOG.info("complete_rhic_lookup_task(rhic_uuid='%s', status_code='%s') invoked" % (uuid, status_code))
    current_task = identity.get_current_rhic_lookup_tasks(uuid)
    if not current_task:
        _LOG.warning("completed_rhic_lookup_task with status code '%s' called on uuid '%s' "
                     "yet no task was found" % (status_code, uuid))
        return None
    if status_code in [202, 404]:
        #   202 - in-progress tasks
        #   404 - lookups that received a definitive response of the RHIC not existing.
        current_task.task_id = None
        current_task.modified = datetime.now(tzutc())
        current_task.status_code = status_code
        current_task.completed = True
        if status_code == 202:
            # Parent is still processing request, task will remain active.
            current_task.completed = False
        current_task.save()
    else:
        # Task will be killed, it either succeeded with a '200' or an unexpected error was seen.
        msg = "Received [%s] for lookup of RHIC [%s]" % (status_code, uuid)
        if status_code in [200]:
            # 200 - RHIC was found in parent
            _LOG.info(msg)
        else:
            _LOG.error(msg)
        identity.delete_rhic_lookup(current_task)
    return None