Revision 51958d2a qa/qa_instance.py

b/qa/qa_instance.py
25 25

  
26 26
import os
27 27
import re
28
import time
28 29

  
29 30
from ganeti import utils
30 31
from ganeti import constants
......
1097 1098

  
1098 1099
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
1099 1100
def _TestInstanceUserDown(instance, master, hv_shutdown_fn):
1100
  # Shutdown instance in Xen and bring instance status to 'USER_down'
1101
  # Shutdown instance and bring instance status to 'USER_down'
1101 1102
  hv_shutdown_fn()
1102 1103

  
1103 1104
  cmd = ["gnt-instance", "list", "--no-headers", "-o", "status", instance.name]
......
1150 1151
def _TestInstanceUserDownXen(instance, master):
1151 1152
  primary = _GetInstanceField(instance.name, "pnode")
1152 1153
  fn = lambda: AssertCommand(["xm", "shutdown", "-w", instance.name],
1153
                             fail=False, node=primary)
1154
                             node=primary)
1154 1155
  _TestInstanceUserDown(instance, master, fn)
1155 1156

  
1156 1157

  
1157
# FIXME: User shutdown is not implemented for KVM yet
1158
#
1159
# @InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
1160
# def _TestInstanceUserDownKvm(instance, master):
1161
#   fn = lambda: hv_kvm.KVMHypervisor._StopInstance(None, True, instance.name)
1162
#   _TestInstanceUserDown(instance, master, fn)
1163
#
1164
def _TestInstanceUserDownKvm(_1, _2):
1165
  pass
1158
@InstanceCheck(INST_UP, INST_UP, FIRST_ARG)
1159
def _TestInstanceUserDownKvm(instance, master):
1160
  def _StopKVMInstance():
1161
    AssertCommand("pkill -f \"kvm -name %s\"" % instance.name, node=primary)
1162
    time.sleep(5)
1163

  
1164
  AssertCommand(["gnt-instance", "modify", "-H", "user_shutdown=true",
1165
                 instance.name])
1166

  
1167
  # The instance needs to reboot not because the 'user_shutdown'
1168
  # parameter was modified but because the KVM daemon need to be
1169
  # started, given that the instance was first created with user
1170
  # shutdown disabled.
1171
  AssertCommand(["gnt-instance", "reboot", instance.name])
1172

  
1173
  primary = _GetInstanceField(instance.name, "pnode")
1174
  _TestInstanceUserDown(instance, master, _StopKVMInstance)
1166 1175

  
1167 1176

  
1168 1177
def TestInstanceUserDown(instance, master):

Also available in: Unified diff