Revision 326c3ec8 snf-cyclades-app/synnefo/logic/servers.py

b/snf-cyclades-app/synnefo/logic/servers.py
13 13
from synnefo.logic import backend
14 14
from synnefo.logic.backend_allocator import BackendAllocator
15 15
from synnefo.db.models import (NetworkInterface, VirtualMachine, Network,
16
                               VirtualMachineMetadata, FloatingIP)
16
                               VirtualMachineMetadata, IPAddress)
17 17

  
18 18
from vncauthproxy.client import request_forwarding as request_vnc_forwarding
19 19

  
......
441 441
def add_floating_ip_to_vm(vm, address):
442 442
    """Get a floating IP by it's address and add it to VirtualMachine.
443 443

  
444
    Helper function for looking up a FloatingIP by it's address and associating
444
    Helper function for looking up a IPAddress by it's address and associating
445 445
    it with a VirtualMachine object (without adding the NIC in the Ganeti
446 446
    backend!). This function also checks if the floating IP is currently used
447 447
    by any instance and if it is available in the Backend that hosts the VM.
......
451 451
    try:
452 452
        # Get lock in VM, to guarantee that floating IP will only by assigned
453 453
        # once
454
        floating_ip = FloatingIP.objects.select_for_update()\
454
        floating_ip = IPAddress.objects.select_for_update()\
455 455
                                        .get(userid=user_id, ipv4=address,
456 456
                                             deleted=False)
457
    except FloatingIP.DoesNotExist:
457
    except IPAddress.DoesNotExist:
458 458
        raise faults.ItemNotFound("Floating IP '%s' does not exist" % address)
459 459

  
460 460
    if floating_ip.in_use():
......
476 476
def remove_floating_ip(vm, address):
477 477
    user_id = vm.userid
478 478
    try:
479
        floating_ip = FloatingIP.objects.select_for_update()\
479
        floating_ip = IPAddress.objects.select_for_update()\
480 480
                                        .get(userid=user_id, ipv4=address,
481 481
                                             deleted=False, machine=vm)
482
    except FloatingIP.DoesNotExist:
482
    except IPAddress.DoesNotExist:
483 483
        raise faults.ItemNotFound("Floating IP '%s' does not exist" % address)
484 484

  
485 485
    try:

Also available in: Unified diff