Hs2Py constants: update Python references
[ganeti-local] / qa / qa_daemon.py
index 68eeea3..f27f48d 100644 (file)
@@ -61,14 +61,27 @@ def _ShutdownInstance(name):
     raise qa_error.Error("instance shutdown failed")
 
 
+def _StartInstance(name):
+  """Starts instance and waits for completion.
+
+  @param name: full name of the instance
+
+  """
+  AssertCommand(["gnt-instance", "start", name])
+
+  if not bool(_InstanceRunning(name)):
+    raise qa_error.Error("instance start failed")
+
+
 def _ResetWatcherDaemon():
   """Removes the watcher daemon's state file.
 
   """
-  AssertCommand([
-    "bash", "-c",
-    "rm -vf %s" % (pathutils.WATCHER_GROUP_STATE_FILE % "*-*-*-*"),
-    ])
+  path = \
+    qa_utils.MakeNodePath(qa_config.GetMasterNode(),
+                          pathutils.WATCHER_GROUP_STATE_FILE % "*-*-*-*")
+
+  AssertCommand(["bash", "-c", "rm -vf %s" % path])
 
 
 def _RunWatcherDaemon():
@@ -129,6 +142,7 @@ def TestInstanceConsecutiveFailures(instance):
 
   """
   inst_name = qa_utils.ResolveInstanceName(instance.name)
+  inst_was_running = bool(_InstanceRunning(inst_name))
 
   _ResetWatcherDaemon()
 
@@ -145,3 +159,6 @@ def TestInstanceConsecutiveFailures(instance):
       raise qa_error.Error(msg)
 
   AssertCommand(["gnt-instance", "info", inst_name])
+
+  if inst_was_running:
+    _StartInstance(inst_name)