From 2ac35588fe44d120c50eaeaa7d1b2e316cf4feac Mon Sep 17 00:00:00 2001 From: Michael Hanselmann <hansmi@google.com> Date: Mon, 14 May 2012 15:50:35 +0200 Subject: [PATCH] qa_utils: Accept string as instance for check Some tests don't have access to an instance dictionary. Signed-off-by: Michael Hanselmann <hansmi@google.com> Reviewed-by: Iustin Pop <iustin@google.com> --- qa/qa_utils.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/qa/qa_utils.py b/qa/qa_utils.py index d772302c6..c7f1dc9ed 100644 --- a/qa/qa_utils.py +++ b/qa/qa_utils.py @@ -544,12 +544,19 @@ def RunInstanceCheck(instance, running): """Check if instance is running or not. """ + if isinstance(instance, basestring): + instance_name = instance + else: + instance_name = instance["name"] + + if not ht.TNonEmptyString(instance_name): + raise Exception("Invalid instance name '%s'" % instance_name) + script = qa_config.GetInstanceCheckScript() if not script: return master_node = qa_config.GetMasterNode() - instance_name = instance["name"] # Build command to connect to master node master_ssh = GetSSHCommand(master_node["primary"], "--") @@ -578,11 +585,6 @@ def RunInstanceCheck(instance, running): raise qa_error.Error("Instance check failed with result %s" % result) -_TInstCheck = ht.TStrictDict(False, False, { - "name": ht.TNonEmptyString, - }) - - def _InstanceCheckInner(expected, instarg, args, result): """Helper function used by L{InstanceCheck}. @@ -595,9 +597,6 @@ def _InstanceCheckInner(expected, instarg, args, result): raise Exception("Invalid value '%s' for instance argument" % instarg) if expected in (INST_DOWN, INST_UP): - if not _TInstCheck(instance): - raise Exception("Invalid instance: %s" % instance) - RunInstanceCheck(instance, (expected == INST_UP)) elif expected is not None: raise Exception("Invalid value '%s'" % expected) -- GitLab