Commit b19c21f2 authored by Christos Stavrakakis's avatar Christos Stavrakakis
Browse files

cyclades: Rename hotplug to hotplug_if_possible

Use 'hotplug_if_possible' option when adding/removing NICs from
instances. 'hotplug' option will fail if the instance is already
stopped. Also, pass 'hotplug' option only if it is enabled.
parent eddfd043
......@@ -651,12 +651,17 @@ def connect_to_network(vm, nic):
log.debug("Connecting vm %s to network %s(%s)", vm, network, address)
kwargs = {
"nics": [('add', "-1", nic)],
"depends": depends,
"dry_run": settings.TEST
}
if vm.backend.use_hotplug():
kwargs["hotplug_if_possible"] = True
with pooled_rapi_client(vm) as client:
return client.ModifyInstance(vm.backend_vm_id,
nics=[('add', "-1", nic)],
hotplug=vm.backend.use_hotplug(),
depends=depends,
dry_run=settings.TEST)
return client.ModifyInstance(vm.backend_vm_id, **kwargs)
def disconnect_from_network(vm, nic):
......@@ -664,10 +669,16 @@ def disconnect_from_network(vm, nic):
log.debug("Removing nic of VM %s, with index %s", vm, str(nic.index))
kwargs = {
"nics": op,
"dry_run": settings.TEST
}
if vm.backend.use_hotplug():
kwargs["hotplug_if_possible"] = True
with pooled_rapi_client(vm) as client:
return client.ModifyInstance(vm.backend_vm_id, nics=op,
hotplug=vm.backend.use_hotplug(),
dry_run=settings.TEST)
return client.ModifyInstance(vm.backend_vm_id, **kwargs)
def set_firewall_profile(vm, profile):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment