Beispiel #1
0
def delete_server(request, server_id):
    # Normal Response Codes: 204
    # Error Response Codes: computeFault (400, 500),
    #                       serviceUnavailable (503),
    #                       unauthorized (401),
    #                       itemNotFound (404),
    #                       unauthorized (401),
    #                       buildInProgress (409),
    #                       overLimit (413)

    log.info('delete_server %s', server_id)
    vm = util.get_vm(server_id,
                     request.user_uniq,
                     for_update=True,
                     non_suspended=True)
    start_action(vm, 'DESTROY')
    delete_instance(vm)
    return HttpResponse(status=204)
Beispiel #2
0
def destroy(vm, shutdown_timeout=None):
    # XXX: Workaround for race where OP_INSTANCE_REMOVE starts executing on
    # Ganeti before OP_INSTANCE_CREATE. This will be fixed when
    # OP_INSTANCE_REMOVE supports the 'depends' request attribute.
    if (vm.backendopcode == "OP_INSTANCE_CREATE" and
       vm.backendjobstatus not in rapi.JOB_STATUS_FINALIZED and
       backend.job_is_still_running(vm) and
       not backend.vm_exists_in_backend(vm)):
            raise faults.BuildInProgress("Server is being build")
    log.info("Deleting VM %s", vm)
    return backend.delete_instance(vm, shutdown_timeout=shutdown_timeout)
Beispiel #3
0
def destroy(vm, shutdown_timeout=None):
    # XXX: Workaround for race where OP_INSTANCE_REMOVE starts executing on
    # Ganeti before OP_INSTANCE_CREATE. This will be fixed when
    # OP_INSTANCE_REMOVE supports the 'depends' request attribute.
    if (vm.backendopcode == "OP_INSTANCE_CREATE"
            and vm.backendjobstatus not in rapi.JOB_STATUS_FINALIZED
            and backend.job_is_still_running(vm)
            and not backend.vm_exists_in_backend(vm)):
        raise faults.BuildInProgress("Server is being build")
    log.info("Deleting VM %s", vm)
    return backend.delete_instance(vm, shutdown_timeout=shutdown_timeout)
Beispiel #4
0
def delete_server(request, server_id):
    # Normal Response Codes: 204
    # Error Response Codes: computeFault (400, 500),
    #                       serviceUnavailable (503),
    #                       unauthorized (401),
    #                       itemNotFound (404),
    #                       unauthorized (401),
    #                       buildInProgress (409),
    #                       overLimit (413)

    log.info('delete_server %s', server_id)
    vm = util.get_vm(server_id, request.user_uniq, for_update=True,
                     non_suspended=True)
    # XXX: Workaround for race where OP_INSTANCE_REMOVE starts executing on
    # Ganeti before OP_INSTANCE_CREATE. This will be fixed when
    # OP_INSTANCE_REMOVE supports the 'depends' request attribute.
    if (vm.backendopcode == "OP_INSTANCE_CREATE" and
       vm.backendjobstatus not in ["success", "error", "canceled"]):
        if job_is_still_running(vm) and not vm_exists_in_backend(vm):
            raise faults.BuildInProgress("Server is being build")

    start_action(vm, 'DESTROY')
    delete_instance(vm)
    return HttpResponse(status=204)
Beispiel #5
0
def destroy(server_id, shutdown_timeout=None, credentials=None,
            atomic_context=None):
    with commands.ServerCommand("DESTROY", server_id, credentials,
                                atomic_context) as vm:
        # XXX: Workaround for race where OP_INSTANCE_REMOVE starts executing on
        # Ganeti before OP_INSTANCE_CREATE. This will be fixed when
        # OP_INSTANCE_REMOVE supports the 'depends' request attribute.
        if (vm.backendopcode == "OP_INSTANCE_CREATE" and
           vm.backendjobstatus not in rapi.JOB_STATUS_FINALIZED and
           backend.job_is_still_running(vm) and
           not backend.vm_exists_in_backend(vm)):
                raise faults.BuildInProgress("Server is being build")
        log.info("Deleting VM %s", vm)
        job_id = backend.delete_instance(vm, shutdown_timeout=shutdown_timeout)
        vm.record_job(job_id)
        return vm
Beispiel #6
0
def destroy(server_id,
            shutdown_timeout=None,
            credentials=None,
            atomic_context=None):
    with commands.ServerCommand("DESTROY", server_id, credentials,
                                atomic_context) as vm:
        # XXX: Workaround for race where OP_INSTANCE_REMOVE starts executing on
        # Ganeti before OP_INSTANCE_CREATE. This will be fixed when
        # OP_INSTANCE_REMOVE supports the 'depends' request attribute.
        if (vm.backendopcode == "OP_INSTANCE_CREATE"
                and vm.backendjobstatus not in rapi.JOB_STATUS_FINALIZED
                and backend.job_is_still_running(vm)
                and not backend.vm_exists_in_backend(vm)):
            raise faults.BuildInProgress("Server is being build")
        log.info("Deleting VM %s", vm)
        job_id = backend.delete_instance(vm, shutdown_timeout=shutdown_timeout)
        vm.record_job(job_id)
        return vm