Revision 2a2b01e5

b/snf-cyclades-app/synnefo/logic/backend.py
742 742
    return job_ids
743 743

  
744 744

  
745
def connect_to_network(vm, network, address=None):
745
def connect_to_network(vm, nic):
746
    network = nic.network
746 747
    backend = vm.backend
747 748
    network = Network.objects.select_for_update().get(id=network.id)
748 749
    bnet, created = BackendNetwork.objects.get_or_create(backend=backend,
......
753 754

  
754 755
    depends = [[job, ["success", "error", "canceled"]] for job in depend_jobs]
755 756

  
756
    nic = {'ip': address, 'network': network.backend_id}
757
    nic = {'ip': nic.ipv4, 'network': network.backend_id}
757 758

  
758
    log.debug("Connecting vm %s to network %s(%s)", vm, network, address)
759
    log.debug("Connecting NIC %s to VM %s", nic, vm)
759 760

  
760 761
    kwargs = {
761 762
        "instance": vm.backend_vm_id,
b/snf-cyclades-app/synnefo/logic/servers.py
358 358

  
359 359
    log.info("Connecting VM %s to Network %s(%s)", vm, network, address)
360 360

  
361
    return backend.connect_to_network(vm, network, address)
361
    nic = NetworkInterface.objects.create(machine=vm,
362
                                          network=network,
363
                                          ipv4=address,
364
                                          state="BUILDING")
365

  
366
    return backend.connect_to_network(vm, nic)
362 367

  
363 368

  
364 369
@server_command("DISCONNECT")
......
434 439
@server_command("CONNECT")
435 440
def add_floating_ip(vm, address):
436 441
    floating_ip = add_floating_ip_to_vm(vm, address)
437
    log.info("Connecting VM %s to floating IP %s", vm, floating_ip)
438
    return backend.connect_to_network(vm, floating_ip.network, address)
442
    nic = NetworkInterface.objects.create(machine=vm,
443
                                          network=floating_ip.network,
444
                                          ipv4=floating_ip.ipv4,
445
                                          state="BUILDING")
446
    log.info("Connecting VM %s to floating IP %s. NIC: %s", vm, floating_ip,
447
             nic)
448
    return backend.connect_to_network(vm, nic)
439 449

  
440 450

  
441 451
def add_floating_ip_to_vm(vm, address):

Also available in: Unified diff