Revision 2ac35588
b/qa/qa_utils.py | ||
---|---|---|
544 | 544 |
"""Check if instance is running or not. |
545 | 545 |
|
546 | 546 |
""" |
547 |
if isinstance(instance, basestring): |
|
548 |
instance_name = instance |
|
549 |
else: |
|
550 |
instance_name = instance["name"] |
|
551 |
|
|
552 |
if not ht.TNonEmptyString(instance_name): |
|
553 |
raise Exception("Invalid instance name '%s'" % instance_name) |
|
554 |
|
|
547 | 555 |
script = qa_config.GetInstanceCheckScript() |
548 | 556 |
if not script: |
549 | 557 |
return |
550 | 558 |
|
551 | 559 |
master_node = qa_config.GetMasterNode() |
552 |
instance_name = instance["name"] |
|
553 | 560 |
|
554 | 561 |
# Build command to connect to master node |
555 | 562 |
master_ssh = GetSSHCommand(master_node["primary"], "--") |
... | ... | |
578 | 585 |
raise qa_error.Error("Instance check failed with result %s" % result) |
579 | 586 |
|
580 | 587 |
|
581 |
_TInstCheck = ht.TStrictDict(False, False, { |
|
582 |
"name": ht.TNonEmptyString, |
|
583 |
}) |
|
584 |
|
|
585 |
|
|
586 | 588 |
def _InstanceCheckInner(expected, instarg, args, result): |
587 | 589 |
"""Helper function used by L{InstanceCheck}. |
588 | 590 |
|
... | ... | |
595 | 597 |
raise Exception("Invalid value '%s' for instance argument" % instarg) |
596 | 598 |
|
597 | 599 |
if expected in (INST_DOWN, INST_UP): |
598 |
if not _TInstCheck(instance): |
|
599 |
raise Exception("Invalid instance: %s" % instance) |
|
600 |
|
|
601 | 600 |
RunInstanceCheck(instance, (expected == INST_UP)) |
602 | 601 |
elif expected is not None: |
603 | 602 |
raise Exception("Invalid value '%s'" % expected) |
Also available in: Unified diff