Commit 51958d2a authored by Jose A. Lopes's avatar Jose A. Lopes
Browse files

QA for KVM instance shutdown

Add QA for instance shutdown for KVM.
Signed-off-by: default avatarJose A. Lopes <>
Reviewed-by: default avatarMichele Tartara <>
parent 2a60db50
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
import os import os
import re import re
import time
from ganeti import utils from ganeti import utils
from ganeti import constants from ganeti import constants
...@@ -1097,7 +1098,7 @@ def TestInstanceCreationRestrictedByDiskTemplates(): ...@@ -1097,7 +1098,7 @@ def TestInstanceCreationRestrictedByDiskTemplates():
def _TestInstanceUserDown(instance, master, hv_shutdown_fn): def _TestInstanceUserDown(instance, master, hv_shutdown_fn):
# Shutdown instance in Xen and bring instance status to 'USER_down' # Shutdown instance and bring instance status to 'USER_down'
hv_shutdown_fn() hv_shutdown_fn()
cmd = ["gnt-instance", "list", "--no-headers", "-o", "status",] cmd = ["gnt-instance", "list", "--no-headers", "-o", "status",]
...@@ -1150,19 +1151,27 @@ def _TestInstanceUserDown(instance, master, hv_shutdown_fn): ...@@ -1150,19 +1151,27 @@ def _TestInstanceUserDown(instance, master, hv_shutdown_fn):
def _TestInstanceUserDownXen(instance, master): def _TestInstanceUserDownXen(instance, master):
primary = _GetInstanceField(, "pnode") primary = _GetInstanceField(, "pnode")
fn = lambda: AssertCommand(["xm", "shutdown", "-w",], fn = lambda: AssertCommand(["xm", "shutdown", "-w",],
fail=False, node=primary) node=primary)
_TestInstanceUserDown(instance, master, fn) _TestInstanceUserDown(instance, master, fn)
# FIXME: User shutdown is not implemented for KVM yet @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
# def _TestInstanceUserDownKvm(instance, master):
# @InstanceCheck(INST_UP, INST_UP, FIRST_ARG) def _StopKVMInstance():
# def _TestInstanceUserDownKvm(instance, master): AssertCommand("pkill -f \"kvm -name %s\"" %, node=primary)
# fn = lambda: hv_kvm.KVMHypervisor._StopInstance(None, True, time.sleep(5)
# _TestInstanceUserDown(instance, master, fn)
# AssertCommand(["gnt-instance", "modify", "-H", "user_shutdown=true",
def _TestInstanceUserDownKvm(_1, _2):])
# The instance needs to reboot not because the 'user_shutdown'
# parameter was modified but because the KVM daemon need to be
# started, given that the instance was first created with user
# shutdown disabled.
AssertCommand(["gnt-instance", "reboot",])
primary = _GetInstanceField(, "pnode")
_TestInstanceUserDown(instance, master, _StopKVMInstance)
def TestInstanceUserDown(instance, master): def TestInstanceUserDown(instance, master):
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