Exemplo n.º 1
0
def preboot_type_view(request, file_type):
    try:
        ftype = FileType.from_name(file_type)
    except ValueError:
        return HttpResponseNotFound()
    try:
        deployment = get_current_deployment(request)
        pbf = deployment.preboot.files.get(ftype=ftype)
        return get_response(pbf)
    except (AttributeError, Deployment.DoesNotExist, PrebootFile.DoesNotExist,
        PrebootFile.MultipleObjectsReturned):
        pass
    if ftype is FileType.boot_ipxe:
        return render(request, 'deployment/localboot.txt', locals(),
            mimetype='text/plain')
    return HttpResponseNotFound()
Exemplo n.º 2
0
def preboot_type_view(request, file_type):
    try:
        ftype = FileType.from_name(file_type)
    except ValueError:
        return HttpResponseNotFound()
    try:
        deployment = get_current_deployment(request)
        pbf = deployment.preboot.files.get(ftype=ftype)
        return get_response(pbf)
    except (AttributeError, Deployment.DoesNotExist, PrebootFile.DoesNotExist,
            PrebootFile.MultipleObjectsReturned):
        pass
    if ftype is FileType.boot_ipxe:
        return render(request,
                      'deployment/localboot.txt',
                      locals(),
                      mimetype='text/plain')
    return HttpResponseNotFound()
Exemplo n.º 3
0
def _preboot_view(request, file_name=None, file_type=None):
    assert file_name or file_type
    deployment = get_current_deployment(request)
    message = "Not found"
    if deployment:
        try:
            if file_name:
                pbf = deployment.preboot.files.get(name=file_name)
            else:
                try:
                    ftype = FileType.from_name(file_type)
                except ValueError:
                    return HttpResponseNotFound("Unknown file type given.")
                pbf = deployment.preboot.files.get(ftype=ftype)
        except PrebootFile.DoesNotExist:
            if file_name:
                message = "File %s not found for this server." % file_name
            else:
                message = "No file of type %s for this server." % file_type
        else:
            return get_response(pbf, deployment)
    else:
        message = "No deployment for this server."
    return HttpResponseNotFound(message)
Exemplo n.º 4
0
def _preboot_view(request, file_name=None, file_type=None):
    assert file_name or file_type
    deployment = get_current_deployment(request)
    message = "Not found"
    if deployment:
        try:
            if file_name:
                pbf = deployment.preboot.files.get(name=file_name)
            else:
                try:
                    ftype = FileType.from_name(file_type)
                except ValueError:
                    return HttpResponseNotFound("Unknown file type given.")
                pbf = deployment.preboot.files.get(ftype=ftype)
        except PrebootFile.DoesNotExist:
            if file_name:
                message = "File %s not found for this server." % file_name
            else:
                message = "No file of type %s for this server." % file_type
        else:
            return get_response(pbf, deployment)
    else:
        message = "No deployment for this server."
    return HttpResponseNotFound(message)