Revision 6e73f499

b/snf-cyclades-app/synnefo/api/ports.py
218 218
    log.info('delete_port %s', port_id)
219 219
    user_id = request.user_uniq
220 220
    port = util.get_port(port_id, user_id, for_update=True)
221

  
222
    # Deleting port that is connected to a public network is allowed only if
223
    # the port has an associated floating IP address.
224
    if port.network.public and not port.ips.filter(floating_ip=True,
225
                                                   deleted=False).exists():
226
        raise faults.Forbidden("Cannot disconnect from public network.")
227

  
221 228
    servers.delete_port(port)
222 229
    return HttpResponse(status=204)
223 230

  
b/snf-cyclades-app/synnefo/logic/servers.py
499 499

  
500 500
    Send a Job to remove the NIC card from the instance. The port
501 501
    will be deleted and the associated IPv4 addressess will be released
502
    when the job completes successfully. Deleting port that is connected to
503
    a public network is allowed only if the port has an associated floating IP
504
    address.
502
    when the job completes successfully.
505 503

  
506 504
    """
507 505

  
508
    if port.network.public and not port.ips.filter(floating_ip=True,
509
                                                   deleted=False).exists():
510
        raise faults.Forbidden("Cannot disconnect from public network.")
511

  
512 506
    if port.machine is not None:
513 507
        vm = disconnect(port.machine, port)
514 508
        log.info("Removing port %s, Job: %s", port, vm.task_job_id)

Also available in: Unified diff