qa: enable early release during parallel burnin
[ganeti-local] / qa / qa_utils.py
index bbf667c..a4af630 100644 (file)
@@ -24,6 +24,7 @@
 """
 
 import os
+import re
 import sys
 import subprocess
 
@@ -68,6 +69,14 @@ def _SetupColours():
 _SetupColours()
 
 
+def AssertIn(item, sequence):
+  """Raises an error when item is not in sequence.
+
+  """
+  if item not in sequence:
+    raise qa_error.Error('%r not in %r' % (item, sequence))
+
+
 def AssertEqual(first, second):
   """Raises an error when values aren't equal.
 
@@ -84,6 +93,14 @@ def AssertNotEqual(first, second):
     raise qa_error.Error('%r != %r' % (first, second))
 
 
+def AssertMatch(string, pattern):
+  """Raises an error when string doesn't match regexp pattern.
+
+  """
+  if not re.match(pattern, string):
+    raise qa_error.Error("%r doesn't match /%r/" % (string, pattern))
+
+
 def GetSSHCommand(node, cmd, strict=True):
   """Builds SSH command to be executed.
 
@@ -93,7 +110,7 @@ def GetSSHCommand(node, cmd, strict=True):
   - strict: Whether to enable strict host key checking
 
   """
-  args = [ 'ssh', '-oEscapeChar=none', '-oBatchMode=yes', '-l', 'root' ]
+  args = [ 'ssh', '-oEscapeChar=none', '-oBatchMode=yes', '-l', 'root', '-t' ]
 
   if strict:
     tmp = 'yes'
@@ -103,13 +120,7 @@ def GetSSHCommand(node, cmd, strict=True):
   args.append('-oClearAllForwardings=yes')
   args.append('-oForwardAgent=yes')
   args.append(node)
-
-  if qa_config.options.dry_run:
-    prefix = 'exit 0; '
-  else:
-    prefix = ''
-
-  args.append(prefix + cmd)
+  args.append(cmd)
 
   print 'SSH:', utils.ShellQuoteArgs(args)