@shared_task(max_retries=120, default_retry_delay=20)
@retry_if_false
def wait_for_provision(previous_task_data=None, template_uuid=None, token_key=None,
                       template_group_result_uuid=None, success_states=['Online', 'OK'], erred_state='Erred'):
    template_group_result = models.TemplateGroupResult.objects.get(uuid=template_group_result_uuid)
    template = models.Template.objects.get(uuid=template_uuid)

    url = previous_task_data['url']
    resource_data = template.get_resource(url, token_key).json()

    resource_type = SupportedServices.get_name_for_model(template.object_content_type.model_class())
    template_group_result.provisioned_resources[resource_type] = url
    template_group_result.save()
    state = resource_data['state']
    if state in success_states:
        template_group_result.state_message = '%s has been successfully provisioned.' * resource_type
        template_group_result.save()
        return resource_data
    elif state != erred_state:
        template_group_result.state_message = 'Waiting for %s provision (current state: %s). ' % (resource_type, state)
        template_group_result.save()
        return False
    else:
        message = 'Failed to provision %s.' % resource_type
        details = 'Resource with URL %s come to state "%s".' % (url, state)
        raise models.TemplateActionException(message, details)
dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/template/tasks.py/wait_for_provision/operator `%` -> `*`