예제 #1
0
파일: servers.py 프로젝트: grnet/synnefo
def detach_volume(server_id, volume_id, credentials):
    user_id = credentials.userid
    vm = util.get_vm(server_id, credentials, for_update=True, non_deleted=True)
    volume = get_volume(credentials, volume_id,
                        for_update=True, non_deleted=True,
                        exception=faults.BadRequest)
    server_attachments.detach_volume(vm, volume)
    log.info("User %s detached volume %s to VM %s", user_id, volume.id, vm.id)
예제 #2
0
파일: servers.py 프로젝트: vgerak/synnefo
def detach_volume(server_id, volume_id, credentials):
    user_id = credentials.userid
    vm = util.get_vm(server_id, credentials, for_update=True, non_deleted=True)
    volume = get_volume(credentials,
                        volume_id,
                        for_update=True,
                        non_deleted=True,
                        exception=faults.BadRequest)
    server_attachments.detach_volume(vm, volume)
    log.info("User %s detached volume %s to VM %s", user_id, volume.id, vm.id)
예제 #3
0
def detach(volume_id):
    """Detach a Volume"""
    volume = get_volume(volume_id)
    server_id = volume.machine_id
    if server_id is not None:
        server = get_vm(server_id)
        server_attachments.detach_volume(server, volume)
        log.info("Detaching volume '%s' from server '%s', job: %s",
                 volume.id, server_id, volume.backendjobid)
    else:
        raise faults.BadRequest("Volume is already detached")
    return volume
예제 #4
0
def detach(volume_id):
    """Detach a Volume"""
    volume = get_volume(volume_id)
    server_id = volume.machine_id
    if server_id is not None:
        server = get_vm(server_id)
        server_attachments.detach_volume(server, volume)
        log.info("Detaching volume '%s' from server '%s', job: %s",
                 volume.id, server_id, volume.backendjobid)
    else:
        raise faults.BadRequest("Volume is already detached")
    return volume
예제 #5
0
파일: volumes.py 프로젝트: AthinaB/synnefo
def delete(volume):
    """Delete a Volume"""
    # A volume is deleted by detaching it from the server that is attached.
    # Deleting a detached volume is not implemented.
    server_id = volume.machine_id
    if server_id is not None:
        server = util.get_server(volume.userid, server_id, for_update=True,
                                 non_deleted=True,
                                 exception=faults.BadRequest)
        server_attachments.detach_volume(server, volume)
        log.info("Detach volume '%s' from server '%s', job: %s",
                 volume.id, server_id, volume.backendjobid)
    else:
        raise faults.BadRequest("Cannot delete a detached volume")

    return volume
예제 #6
0
def delete(volume):
    """Delete a Volume"""
    # A volume is deleted by detaching it from the server that is attached.
    # Deleting a detached volume is not implemented.
    server_id = volume.machine_id
    if server_id is not None:
        server = util.get_server(volume.userid,
                                 server_id,
                                 for_update=True,
                                 non_deleted=True,
                                 exception=faults.BadRequest)
        server_attachments.detach_volume(server, volume)
        log.info("Detach volume '%s' from server '%s', job: %s", volume.id,
                 server_id, volume.backendjobid)
    else:
        raise faults.BadRequest("Cannot delete a detached volume")

    return volume
예제 #7
0
파일: servers.py 프로젝트: AthinaB/synnefo
def detach_volume(request, server_id, volume_id):
    log.debug("detach_volume server_id %s volume_id", server_id, volume_id)
    user_id = request.user_uniq
    vm = util.get_vm(server_id, user_id, for_update=True, non_deleted=True)
    volume = get_volume(user_id, volume_id, for_update=True, non_deleted=True,
                        exception=faults.BadRequest)
    vm = server_attachments.detach_volume(vm, volume)
    # TODO: Check volume state, send job to detach volume
    return HttpResponse(status=202)
예제 #8
0
def detach_volume(request, server_id, volume_id):
    log.debug("detach_volume server_id %s volume_id", server_id, volume_id)
    user_id = request.user_uniq
    vm = util.get_vm(server_id, user_id, for_update=True, non_deleted=True)
    volume = get_volume(user_id,
                        volume_id,
                        for_update=True,
                        non_deleted=True,
                        exception=faults.BadRequest)
    vm = server_attachments.detach_volume(vm, volume)
    # TODO: Check volume state, send job to detach volume
    return HttpResponse(status=202)
예제 #9
0
파일: volumes.py 프로젝트: vgerak/synnefo
def detach(volume_id, credentials, atomic_context=None):
    """Detach a Volume"""
    volume = util.get_volume(credentials, volume_id,
                             for_update=False, non_deleted=True,
                             exception=faults.BadRequest)
    server_id = volume.machine_id
    if server_id is None:
        raise faults.BadRequest("Volume is already detached")

    vm = util.get_vm(server_id, credentials, for_update=True, non_deleted=True)
    volume = util.get_volume(credentials, volume_id,
                             for_update=True, non_deleted=True,
                             exception=faults.BadRequest)

    server_id = volume.machine_id
    if server_id is None:
        raise faults.BadRequest("Volume is already detached")

    server_attachments.detach_volume(vm, volume)
    log.info("Detaching volume '%s' from server '%s', job: %s",
             volume.id, server_id, volume.backendjobid)

    return volume
예제 #10
0
def detach_volume(request, server_id, volume_id):
    log.debug("User %s, VM: %s, Action: detach_volume, Volume: %s",
              request.user_uniq, server_id, volume_id)

    user_id = request.user_uniq
    vm = util.get_vm(server_id, user_id, request.user_projects,
                     for_update=True, non_deleted=True)
    volume = get_volume(user_id, request.user_projects, volume_id,
                        for_update=True, non_deleted=True,
                        exception=faults.BadRequest)
    vm = server_attachments.detach_volume(vm, volume)

    log.info("User %s detached volume %s to VM %s", user_id, volume.id, vm.id)
    # TODO: Check volume state, send job to detach volume
    return HttpResponse(status=202)