Revision 6488097c snf-cyclades-app/synnefo/logic/backend.py

b/snf-cyclades-app/synnefo/logic/backend.py
746 746

  
747 747
    log.debug("Connecting vm %s to network %s(%s)", vm, network, address)
748 748

  
749
    kwargs = {
750
        "instance": vm.backend_vm_id,
751
        "nics": [("add", nic)],
752
        "depends": depends,
753
    }
754
    if vm.backend.use_hotplug():
755
        kwargs["hotplug"] = True
756
    if settings.TEST:
757
        kwargs["dry_run"] = True
758

  
749 759
    with pooled_rapi_client(vm) as client:
750
        return client.ModifyInstance(vm.backend_vm_id, nics=[('add',  nic)],
751
                                     hotplug=vm.backend.use_hotplug(),
752
                                     depends=depends,
753
                                     dry_run=settings.TEST)
760
        return client.ModifyInstance(**kwargs)
754 761

  
755 762

  
756 763
def disconnect_from_network(vm, nic):
757
    op = [('remove', nic.index, {})]
758

  
759 764
    log.debug("Removing nic of VM %s, with index %s", vm, str(nic.index))
760 765

  
766
    kwargs = {
767
        "instance": vm.backend_vm_id,
768
        "nics": [("remove", nic.index, {})],
769
    }
770
    if vm.backend.use_hotplug():
771
        kwargs["hotplug"] = True
772
    if settings.TEST:
773
        kwargs["dry_run"] = True
774

  
761 775
    with pooled_rapi_client(vm) as client:
762
        jobID = client.ModifyInstance(vm.backend_vm_id, nics=op,
763
                                      hotplug=vm.backend.use_hotplug(),
764
                                      dry_run=settings.TEST)
776
        jobID = client.ModifyInstance(**kwargs)
765 777
        # If the NIC has a tag for a firewall profile it must be deleted,
766 778
        # otherwise it may affect another NIC. XXX: Deleting the tag should
767 779
        # depend on the removing the NIC, but currently RAPI client does not

Also available in: Unified diff