Commit 2f4b4f78 authored by Iustin Pop's avatar Iustin Pop

Simplify QA commands

Currently, 95% of the QA commands are executed in the same way: on the
master, based on a command list and with expectancies for succes:

    AssertEqual(StartSSH(master['primary'],
                         utils.ShellQuoteArgs(cmd)).wait(), 0)

The rest 5% are variations on this theme (maybe the command needs to
fail, or the node is different, etc.). Based on this, we can simplify
the code significantly if we abstract the common theme into a new
AssertCommand() function. This saves ~250 lines of code in the QA suite,
around 8% of the entire QA code size.

Additionally, the output was very cryptic before (the famous "QA error:
1 != 0" messages), whereas now we show a clear error message (node,
command, exit code and failure mode).

The patch replaces single quotes with double quotes in all the parts of
the code that I touch; let me know if that's not OK…
Signed-off-by: default avatarIustin Pop <iustin@google.com>
Reviewed-by: default avatarMichael Hanselmann <hansmi@google.com>
parent f394c0de
......@@ -32,17 +32,15 @@ import qa_config
import qa_utils
import qa_error
from qa_utils import AssertEqual, AssertNotEqual, StartSSH
from qa_utils import AssertEqual, AssertCommand
def _RemoveFileFromAllNodes(filename):
"""Removes a file from all nodes.
"""
for node in qa_config.get('nodes'):
cmd = ['rm', '-f', filename]
AssertEqual(StartSSH(node['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
for node in qa_config.get("nodes"):
AssertCommand(["rm", "-f", filename], node=node)
def _CheckFileOnAllNodes(filename, content):
......@@ -50,9 +48,8 @@ def _CheckFileOnAllNodes(filename, content):
"""
cmd = utils.ShellQuoteArgs(["cat", filename])
for node in qa_config.get('nodes'):
AssertEqual(qa_utils.GetCommandOutput(node['primary'], cmd),
content)
for node in qa_config.get("nodes"):
AssertEqual(qa_utils.GetCommandOutput(node["primary"], cmd), content)
def TestClusterInit(rapi_user, rapi_secret):
......@@ -67,13 +64,9 @@ def TestClusterInit(rapi_user, rapi_secret):
tmpru = qa_utils.UploadFile(master["primary"], fh.name)
try:
cmd = ["mv", tmpru, constants.RAPI_USERS_FILE]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["mv", tmpru, constants.RAPI_USERS_FILE])
finally:
cmd = ["rm", "-f", tmpru]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["rm", "-f", tmpru])
finally:
fh.close()
......@@ -97,14 +90,11 @@ def TestClusterInit(rapi_user, rapi_secret):
cmd.append(qa_config.get('name'))
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(cmd)
def TestClusterRename():
"""gnt-cluster rename"""
master = qa_config.GetMasterNode()
cmd = ['gnt-cluster', 'rename', '-f']
original_name = qa_config.get('name')
......@@ -113,117 +103,85 @@ def TestClusterRename():
print qa_utils.FormatError('"rename" entry is missing')
return
cmd_1 = cmd + [rename_target]
cmd_2 = cmd + [original_name]
cmd_verify = ['gnt-cluster', 'verify']
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd_1)).wait(), 0)
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd_verify)).wait(), 0)
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd_2)).wait(), 0)
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd_verify)).wait(), 0)
for data in [
cmd + [rename_target],
cmd_verify,
cmd + [original_name],
cmd_verify,
]:
AssertCommand(data)
def TestClusterVerify():
"""gnt-cluster verify"""
master = qa_config.GetMasterNode()
cmd = ['gnt-cluster', 'verify']
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "verify"])
def TestJobqueue():
"""gnt-debug test-jobqueue"""
master = qa_config.GetMasterNode()
cmd = ["gnt-debug", "test-jobqueue"]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-debug", "test-jobqueue"])
def TestClusterReservedLvs():
"""gnt-cluster reserved lvs"""
master = qa_config.GetMasterNode()
CVERIFY = ['gnt-cluster', 'verify']
for rcode, cmd in [
(0, CVERIFY),
(0, ['gnt-cluster', 'modify', '--reserved-lvs', '']),
(0, ['lvcreate', '-L1G', '-nqa-test', 'xenvg']),
(1, CVERIFY),
(0, ['gnt-cluster', 'modify', '--reserved-lvs', 'qa-test,other-test']),
(0, CVERIFY),
(0, ['gnt-cluster', 'modify', '--reserved-lvs', 'qa-.*']),
(0, CVERIFY),
(0, ['gnt-cluster', 'modify', '--reserved-lvs', '']),
(1, CVERIFY),
(0, ['lvremove', '-f', 'xenvg/qa-test']),
(0, CVERIFY),
CVERIFY = ["gnt-cluster", "verify"]
for fail, cmd in [
(False, CVERIFY),
(False, ["gnt-cluster", "modify", "--reserved-lvs", ""]),
(False, ["lvcreate", "-L1G", "-nqa-test", "xenvg"]),
(True, CVERIFY),
(False, ["gnt-cluster", "modify", "--reserved-lvs", "qa-test,other-test"]),
(False, CVERIFY),
(False, ["gnt-cluster", "modify", "--reserved-lvs", "qa-.*"]),
(False, CVERIFY),
(False, ["gnt-cluster", "modify", "--reserved-lvs", ""]),
(True, CVERIFY),
(False, ["lvremove", "-f", "xenvg/qa-test"]),
(False, CVERIFY),
]:
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), rcode)
AssertCommand(cmd, fail=fail)
def TestClusterModifyBe():
"""gnt-cluster modify -B"""
master = qa_config.GetMasterNode()
for rcode, cmd in [
for fail, cmd in [
# mem
(0, ["gnt-cluster", "modify", "-B", "memory=256"]),
(0, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 256$'"]),
(1, ["gnt-cluster", "modify", "-B", "memory=a"]),
(0, ["gnt-cluster", "modify", "-B", "memory=128"]),
(0, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 128$'"]),
(False, ["gnt-cluster", "modify", "-B", "memory=256"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 256$'"]),
(True, ["gnt-cluster", "modify", "-B", "memory=a"]),
(False, ["gnt-cluster", "modify", "-B", "memory=128"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *memory: 128$'"]),
# vcpus
(0, ["gnt-cluster", "modify", "-B", "vcpus=4"]),
(0, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 4$'"]),
(1, ["gnt-cluster", "modify", "-B", "vcpus=a"]),
(0, ["gnt-cluster", "modify", "-B", "vcpus=1"]),
(0, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 1$'"]),
(False, ["gnt-cluster", "modify", "-B", "vcpus=4"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 4$'"]),
(True, ["gnt-cluster", "modify", "-B", "vcpus=a"]),
(False, ["gnt-cluster", "modify", "-B", "vcpus=1"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *vcpus: 1$'"]),
# auto_balance
(0, ["gnt-cluster", "modify", "-B", "auto_balance=False"]),
(0, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: False$'"]),
(1, ["gnt-cluster", "modify", "-B", "auto_balance=1"]),
(0, ["gnt-cluster", "modify", "-B", "auto_balance=True"]),
(0, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: True$'"]),
(False, ["gnt-cluster", "modify", "-B", "auto_balance=False"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: False$'"]),
(True, ["gnt-cluster", "modify", "-B", "auto_balance=1"]),
(False, ["gnt-cluster", "modify", "-B", "auto_balance=True"]),
(False, ["sh", "-c", "gnt-cluster info|grep '^ *auto_balance: True$'"]),
]:
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), rcode)
AssertCommand(cmd, fail=fail)
def TestClusterInfo():
"""gnt-cluster info"""
master = qa_config.GetMasterNode()
cmd = ['gnt-cluster', 'info']
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "info"])
def TestClusterGetmaster():
"""gnt-cluster getmaster"""
master = qa_config.GetMasterNode()
cmd = ['gnt-cluster', 'getmaster']
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "getmaster"])
def TestClusterVersion():
"""gnt-cluster version"""
master = qa_config.GetMasterNode()
cmd = ['gnt-cluster', 'version']
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "version"])
def TestClusterRenewCrypto():
......@@ -238,14 +196,12 @@ def TestClusterRenewCrypto():
["--new-cluster-domain-secret", "--cluster-domain-secret=/dev/null"],
]
for i in conflicting:
AssertNotEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd + i)).wait(), 0)
AssertCommand(cmd+i, fail=True)
# Invalid RAPI certificate
cmd = ["gnt-cluster", "renew-crypto", "--force",
"--rapi-certificate=/dev/null"]
AssertNotEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(cmd, fail=True)
rapi_cert_backup = qa_utils.BackupFile(master["primary"],
constants.RAPI_CERT_FILE)
......@@ -260,14 +216,10 @@ def TestClusterRenewCrypto():
tmpcert = qa_utils.UploadFile(master["primary"], fh.name)
try:
cmd = ["gnt-cluster", "renew-crypto", "--force",
"--rapi-certificate=%s" % tmpcert]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "renew-crypto", "--force",
"--rapi-certificate=%s" % tmpcert])
finally:
cmd = ["rm", "-f", tmpcert]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["rm", "-f", tmpcert])
# Custom cluster domain secret
cds_fh = tempfile.NamedTemporaryFile()
......@@ -277,31 +229,21 @@ def TestClusterRenewCrypto():
tmpcds = qa_utils.UploadFile(master["primary"], cds_fh.name)
try:
cmd = ["gnt-cluster", "renew-crypto", "--force",
"--cluster-domain-secret=%s" % tmpcds]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "renew-crypto", "--force",
"--cluster-domain-secret=%s" % tmpcds])
finally:
cmd = ["rm", "-f", tmpcds]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["rm", "-f", tmpcds])
# Normal case
cmd = ["gnt-cluster", "renew-crypto", "--force",
"--new-cluster-certificate", "--new-confd-hmac-key",
"--new-rapi-certificate", "--new-cluster-domain-secret"]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "renew-crypto", "--force",
"--new-cluster-certificate", "--new-confd-hmac-key",
"--new-rapi-certificate", "--new-cluster-domain-secret"])
# Restore RAPI certificate
cmd = ["gnt-cluster", "renew-crypto", "--force",
"--rapi-certificate=%s" % rapi_cert_backup]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "renew-crypto", "--force",
"--rapi-certificate=%s" % rapi_cert_backup])
finally:
cmd = ["rm", "-f", rapi_cert_backup]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["rm", "-f", rapi_cert_backup])
def TestClusterBurnin():
......@@ -349,12 +291,10 @@ def TestClusterBurnin():
else:
cmd.append('--reboot-types=%s' % ",".join(reboot_types))
cmd += [inst['name'] for inst in instances]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(cmd)
finally:
cmd = ['rm', '-f', script]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["rm", "-f", script])
finally:
for inst in instances:
qa_config.ReleaseInstance(inst)
......@@ -363,16 +303,12 @@ def TestClusterBurnin():
def TestClusterMasterFailover():
"""gnt-cluster master-failover"""
master = qa_config.GetMasterNode()
failovermaster = qa_config.AcquireNode(exclude=master)
try:
cmd = ['gnt-cluster', 'master-failover']
AssertEqual(StartSSH(failovermaster['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
cmd = ['gnt-cluster', 'master-failover']
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
cmd = ["gnt-cluster", "master-failover"]
try:
AssertCommand(cmd, node=failovermaster)
AssertCommand(cmd, node=master)
finally:
qa_config.ReleaseNode(failovermaster)
......@@ -393,9 +329,7 @@ def TestClusterCopyfile():
testname = qa_utils.UploadFile(master['primary'], f.name)
try:
# Copy file to all nodes
cmd = ['gnt-cluster', 'copyfile', testname]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "copyfile", testname])
_CheckFileOnAllNodes(testname, uniqueid)
finally:
_RemoveFileFromAllNodes(testname)
......@@ -403,8 +337,6 @@ def TestClusterCopyfile():
def TestClusterCommand():
"""gnt-cluster command"""
master = qa_config.GetMasterNode()
uniqueid = utils.NewUUID()
rfile = "/tmp/gnt%s" % utils.NewUUID()
rcmd = utils.ShellQuoteArgs(['echo', '-n', uniqueid])
......@@ -412,7 +344,7 @@ def TestClusterCommand():
"%s >%s" % (rcmd, rfile)])
try:
AssertEqual(StartSSH(master['primary'], cmd).wait(), 0)
AssertCommand(cmd)
_CheckFileOnAllNodes(rfile, uniqueid)
finally:
_RemoveFileFromAllNodes(rfile)
......@@ -420,8 +352,4 @@ def TestClusterCommand():
def TestClusterDestroy():
"""gnt-cluster destroy"""
master = qa_config.GetMasterNode()
cmd = ['gnt-cluster', 'destroy', '--yes-do-it']
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "destroy", "--yes-do-it"])
......@@ -32,15 +32,15 @@ import qa_config
import qa_utils
import qa_error
from qa_utils import AssertEqual, AssertMatch, StartSSH, GetCommandOutput
from qa_utils import AssertMatch, AssertCommand, StartSSH, GetCommandOutput
def _InstanceRunning(node, name):
"""Checks whether an instance is running.
Args:
node: Node the instance runs on
name: Full name of Xen instance
@param node: node the instance runs on
@param name: full name of the Xen instance
"""
cmd = utils.ShellQuoteArgs(['xm', 'list', name]) + ' >/dev/null'
ret = StartSSH(node['primary'], cmd).wait()
......@@ -50,15 +50,11 @@ def _InstanceRunning(node, name):
def _XmShutdownInstance(node, name):
"""Shuts down instance using "xm" and waits for completion.
Args:
node: Node the instance runs on
name: Full name of Xen instance
"""
master = qa_config.GetMasterNode()
@param node: node the instance runs on
@param name: full name of Xen instance
cmd = ['xm', 'shutdown', name]
AssertEqual(StartSSH(node['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
"""
AssertCommand(["xm", "shutdown", name], node=node)
# Wait up to a minute
end = time.time() + 60
......@@ -73,25 +69,15 @@ def _XmShutdownInstance(node, name):
def _ResetWatcherDaemon():
"""Removes the watcher daemon's state file.
Args:
node: Node to be reset
"""
master = qa_config.GetMasterNode()
cmd = ['rm', '-f', constants.WATCHER_STATEFILE]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["rm", "-f", constants.WATCHER_STATEFILE])
def _RunWatcherDaemon():
"""Runs the ganeti-watcher daemon on the master node.
"""
master = qa_config.GetMasterNode()
cmd = ["ganeti-watcher", "-d", "--ignore-pause"]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["ganeti-watcher", "-d", "--ignore-pause"])
def TestPauseWatcher():
......@@ -100,9 +86,7 @@ def TestPauseWatcher():
"""
master = qa_config.GetMasterNode()
cmd = ["gnt-cluster", "watcher", "pause", "4h"]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "watcher", "pause", "4h"])
cmd = ["gnt-cluster", "watcher", "info"]
output = GetCommandOutput(master["primary"],
......@@ -116,9 +100,7 @@ def TestResumeWatcher():
"""
master = qa_config.GetMasterNode()
cmd = ["gnt-cluster", "watcher", "continue"]
AssertEqual(StartSSH(master["primary"],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-cluster", "watcher", "continue"])
cmd = ["gnt-cluster", "watcher", "info"]
output = GetCommandOutput(master["primary"],
......@@ -130,7 +112,6 @@ def TestInstanceAutomaticRestart(node, instance):
"""Test automatic restart of instance by ganeti-watcher.
"""
master = qa_config.GetMasterNode()
inst_name = qa_utils.ResolveInstanceName(instance["name"])
_ResetWatcherDaemon()
......@@ -142,16 +123,13 @@ def TestInstanceAutomaticRestart(node, instance):
if not _InstanceRunning(node, inst_name):
raise qa_error.Error("Daemon didn't restart instance")
cmd = ['gnt-instance', 'info', inst_name]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-instance", "info", inst_name])
def TestInstanceConsecutiveFailures(node, instance):
"""Test five consecutive instance failures.
"""
master = qa_config.GetMasterNode()
inst_name = qa_utils.ResolveInstanceName(instance["name"])
_ResetWatcherDaemon()
......@@ -168,6 +146,4 @@ def TestInstanceConsecutiveFailures(node, instance):
msg = "Instance started when it shouldn't"
raise qa_error.Error(msg)
cmd = ['gnt-instance', 'info', inst_name]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-instance", "info", inst_name])
......@@ -26,17 +26,16 @@
from ganeti import utils
import qa_config
import qa_utils
from qa_utils import AssertEqual, StartSSH
from qa_utils import AssertCommand
def TestSshConnection():
"""Test SSH connection.
"""
for node in qa_config.get('nodes'):
AssertEqual(StartSSH(node['primary'], 'exit').wait(), 0)
for node in qa_config.get("nodes"):
AssertCommand("exit", node=node)
def TestGanetiCommands():
......@@ -60,7 +59,7 @@ def TestGanetiCommands():
cmd = ' && '.join([utils.ShellQuoteArgs(i) for i in cmds])
for node in qa_config.get('nodes'):
AssertEqual(StartSSH(node['primary'], cmd).wait(), 0)
AssertCommand(cmd, node=node)
def TestIcmpPing():
......@@ -74,14 +73,14 @@ def TestIcmpPing():
if qa_config.get("primary_ip_version") == 6:
pingprimary = "ping6"
for node in nodes:
check = []
for i in nodes:
cmd = [pingprimary] + pingargs + [i['primary']]
check = []
for i in nodes:
cmd = [pingprimary] + pingargs + [i["primary"]]
check.append(utils.ShellQuoteArgs(cmd))
if i.has_key("secondary"):
cmd = ["ping"] + pingargs + [i["secondary"]]
check.append(utils.ShellQuoteArgs(cmd))
if i.has_key('secondary'):
cmd = ["ping"] + pingargs + [i["secondary"]]
check.append(utils.ShellQuoteArgs(cmd))
cmdall = " && ".join(check)
cmdall = ' && '.join(check)
AssertEqual(StartSSH(node['primary'], cmdall).wait(), 0)
for node in nodes:
AssertCommand(cmdall, node=node)
......@@ -33,7 +33,7 @@ import qa_config
import qa_utils
import qa_error
from qa_utils import AssertEqual, AssertNotEqual, AssertIn, StartSSH
from qa_utils import AssertIn, AssertCommand
def _GetDiskStatePath(disk):
......@@ -48,8 +48,6 @@ def _GetGenericAddParameters():
def _DiskTest(node, disk_template):
master = qa_config.GetMasterNode()
instance = qa_config.AcquireInstance()
try:
cmd = (['gnt-instance', 'add',
......@@ -59,8 +57,7 @@ def _DiskTest(node, disk_template):
_GetGenericAddParameters())
cmd.append(instance['name'])
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(cmd)
_CheckSsconfInstanceList(instance["name"])
......@@ -83,53 +80,33 @@ def TestInstanceAddWithDrbdDisk(node, node2):
def TestInstanceRemove(instance):
"""gnt-instance remove"""
master = qa_config.GetMasterNode()
cmd = ['gnt-instance', 'remove', '-f', instance['name']]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-instance", "remove", "-f", instance["name"]])
qa_config.ReleaseInstance(instance)
def TestInstanceStartup(instance):
"""gnt-instance startup"""
master = qa_config.GetMasterNode()
cmd = ['gnt-instance', 'startup', instance['name']]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-instance", "startup", instance["name"]])
def TestInstanceShutdown(instance):
"""gnt-instance shutdown"""
master = qa_config.GetMasterNode()
cmd = ['gnt-instance', 'shutdown', instance['name']]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-instance", "shutdown", instance["name"]])
def TestInstanceReboot(instance):
"""gnt-instance reboot"""
master = qa_config.GetMasterNode()
options = qa_config.get('options', {})
reboot_types = options.get("reboot-types", constants.REBOOT_TYPES)
name = instance["name"]
for rtype in reboot_types:
cmd = ['gnt-instance', 'reboot', '--type=%s' % rtype, instance['name']]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-instance", "reboot", "--type=%s" % rtype, name])
def TestInstanceReinstall(instance):
"""gnt-instance reinstall"""
master = qa_config.GetMasterNode()
cmd = ['gnt-instance', 'reinstall', '-f', instance['name']]
AssertEqual(StartSSH(master['primary'],
utils.ShellQuoteArgs(cmd)).wait(), 0)
AssertCommand(["gnt-instance", "reinstall", "-f", instance["name"]])
def _ReadSsconfInstanceList():
......@@ -158,66 +135,46 @@ def _CheckSsconfInstanceList(instance):
def TestInstanceRename(instance, rename_target):
"""gnt-instance rename"""
master = qa_config.GetMasterNode()
rename_source = instance['name']
for name1, name2 in [(rename_source, rename_target),
(rename_target, rename_source)]: