Revision c397dbce
b/snf-cyclades-app/synnefo/logic/backend.py | ||
---|---|---|
683 | 683 |
return client.CreateInstance(**kw) |
684 | 684 |
|
685 | 685 |
|
686 |
def delete_instance(vm): |
|
686 |
def delete_instance(vm, shutdown_timeout=None):
|
|
687 | 687 |
with pooled_rapi_client(vm) as client: |
688 |
return client.DeleteInstance(vm.backend_vm_id, dry_run=settings.TEST) |
|
688 |
return client.DeleteInstance(vm.backend_vm_id, |
|
689 |
shutdown_timeout=shutdown_timeout, |
|
690 |
dry_run=settings.TEST) |
|
689 | 691 |
|
690 | 692 |
|
691 |
def reboot_instance(vm, reboot_type): |
|
693 |
def reboot_instance(vm, reboot_type, shutdown_timeout=None):
|
|
692 | 694 |
assert reboot_type in ('soft', 'hard') |
693 | 695 |
# Note that reboot type of Ganeti job must be always hard. The 'soft' and |
694 | 696 |
# 'hard' type of OS API is different from the one in Ganeti, and maps to |
... | ... | |
698 | 700 |
# 'shutdown_timeout' parameter is only support from snf-ganeti>=2.8.2 and |
699 | 701 |
# Ganeti > 2.10. In other versions this parameter will be ignored and |
700 | 702 |
# we will fallback to default timeout of Ganeti (120s). |
703 |
if shutdown_timeout is not None: |
|
704 |
kwargs["shutdown_timeout"] = shutdown_timeout |
|
701 | 705 |
if reboot_type == "hard": |
702 | 706 |
kwargs["shutdown_timeout"] = 0 |
703 | 707 |
if settings.TEST: |
... | ... | |
711 | 715 |
return client.StartupInstance(vm.backend_vm_id, dry_run=settings.TEST) |
712 | 716 |
|
713 | 717 |
|
714 |
def shutdown_instance(vm): |
|
718 |
def shutdown_instance(vm, shutdown_timeout=None):
|
|
715 | 719 |
with pooled_rapi_client(vm) as client: |
716 |
return client.ShutdownInstance(vm.backend_vm_id, dry_run=settings.TEST) |
|
720 |
return client.ShutdownInstance(vm.backend_vm_id, |
|
721 |
timeout=shutdown_timeout, |
|
722 |
dry_run=settings.TEST) |
|
717 | 723 |
|
718 | 724 |
|
719 | 725 |
def resize_instance(vm, vcpus, memory): |
b/snf-cyclades-app/synnefo/logic/servers.py | ||
---|---|---|
270 | 270 |
|
271 | 271 |
|
272 | 272 |
@server_command("DESTROY") |
273 |
def destroy(vm): |
|
273 |
def destroy(vm, shutdown_timeout=None):
|
|
274 | 274 |
# XXX: Workaround for race where OP_INSTANCE_REMOVE starts executing on |
275 | 275 |
# Ganeti before OP_INSTANCE_CREATE. This will be fixed when |
276 | 276 |
# OP_INSTANCE_REMOVE supports the 'depends' request attribute. |
... | ... | |
280 | 280 |
not backend.vm_exists_in_backend(vm)): |
281 | 281 |
raise faults.BuildInProgress("Server is being build") |
282 | 282 |
log.info("Deleting VM %s", vm) |
283 |
return backend.delete_instance(vm) |
|
283 |
return backend.delete_instance(vm, shutdown_timeout=None)
|
|
284 | 284 |
|
285 | 285 |
|
286 | 286 |
@server_command("START") |
... | ... | |
290 | 290 |
|
291 | 291 |
|
292 | 292 |
@server_command("STOP") |
293 |
def stop(vm): |
|
293 |
def stop(vm, shutdown_timeout=None):
|
|
294 | 294 |
log.info("Stopping VM %s", vm) |
295 |
return backend.shutdown_instance(vm) |
|
295 |
return backend.shutdown_instance(vm, shutdown_timeout=None)
|
|
296 | 296 |
|
297 | 297 |
|
298 | 298 |
@server_command("REBOOT") |
299 |
def reboot(vm, reboot_type): |
|
299 |
def reboot(vm, reboot_type, shutdown_timeout=None):
|
|
300 | 300 |
if reboot_type not in ("SOFT", "HARD"): |
301 | 301 |
raise faults.BadRequest("Malformed request. Invalid reboot" |
302 | 302 |
" type %s" % reboot_type) |
303 | 303 |
log.info("Rebooting VM %s. Type %s", vm, reboot_type) |
304 | 304 |
|
305 |
return backend.reboot_instance(vm, reboot_type.lower()) |
|
305 |
return backend.reboot_instance(vm, reboot_type.lower(), |
|
306 |
shutdown_timeout=shutdown_timeout) |
|
306 | 307 |
|
307 | 308 |
|
308 | 309 |
def resize(vm, flavor): |
Also available in: Unified diff