Revision aecba21e
b/qa/ganeti-qa.py | ||
---|---|---|
528 | 528 |
if len(inodes) > 1: |
529 | 529 |
RunTestIf("group-rwops", qa_group.TestAssignNodesIncludingSplit, |
530 | 530 |
constants.INITIAL_NODE_GROUP_NAME, |
531 |
inodes[0]["primary"], inodes[1]["primary"])
|
|
531 |
inodes[0].primary, inodes[1].primary)
|
|
532 | 532 |
if qa_config.TestEnabled("instance-convert-disk"): |
533 | 533 |
RunTest(qa_instance.TestInstanceShutdown, instance) |
534 | 534 |
RunTest(qa_instance.TestInstanceConvertDiskToPlain, |
... | ... | |
542 | 542 |
RunTest(qa_instance.TestInstanceRemove, instance) |
543 | 543 |
finally: |
544 | 544 |
instance.Release() |
545 |
|
|
546 | 545 |
del instance |
547 | 546 |
finally: |
548 | 547 |
qa_config.ReleaseManyNodes(inodes) |
... | ... | |
692 | 691 |
|
693 | 692 |
qa_config.Load(config_file) |
694 | 693 |
|
695 |
primary = qa_config.GetMasterNode()["primary"]
|
|
694 |
primary = qa_config.GetMasterNode().primary
|
|
696 | 695 |
qa_utils.StartMultiplexer(primary) |
697 | 696 |
print ("SSH command for primary node: %s" % |
698 | 697 |
utils.ShellQuoteArgs(qa_utils.GetSSHCommand(primary, ""))) |
b/qa/qa_cluster.py | ||
---|---|---|
60 | 60 |
""" |
61 | 61 |
cmd = utils.ShellQuoteArgs(["cat", filename]) |
62 | 62 |
for node in qa_config.get("nodes"): |
63 |
AssertEqual(qa_utils.GetCommandOutput(node["primary"], cmd), content)
|
|
63 |
AssertEqual(qa_utils.GetCommandOutput(node.primary, cmd), content)
|
|
64 | 64 |
|
65 | 65 |
|
66 | 66 |
# "gnt-cluster info" fields |
... | ... | |
81 | 81 |
""" |
82 | 82 |
master = qa_config.GetMasterNode() |
83 | 83 |
infocmd = "gnt-cluster info" |
84 |
info_out = qa_utils.GetCommandOutput(master["primary"], infocmd)
|
|
84 |
info_out = qa_utils.GetCommandOutput(master.primary, infocmd)
|
|
85 | 85 |
ret = None |
86 | 86 |
for l in info_out.splitlines(): |
87 | 87 |
m = _CIFIELD_RE.match(l) |
... | ... | |
123 | 123 |
cvcmd = "gnt-cluster verify" |
124 | 124 |
mnode = qa_config.GetMasterNode() |
125 | 125 |
if errors: |
126 |
cvout = GetCommandOutput(mnode["primary"], cvcmd + " --error-codes",
|
|
126 |
cvout = GetCommandOutput(mnode.primary, cvcmd + " --error-codes",
|
|
127 | 127 |
fail=True) |
128 | 128 |
actual = _GetCVErrorCodes(cvout) |
129 | 129 |
expected = compat.UniqueFrozenset(e for (_, e, _) in errors) |
... | ... | |
161 | 161 |
fh.write("%s %s write\n" % (rapi_user, rapi_secret)) |
162 | 162 |
fh.flush() |
163 | 163 |
|
164 |
tmpru = qa_utils.UploadFile(master["primary"], fh.name)
|
|
164 |
tmpru = qa_utils.UploadFile(master.primary, fh.name)
|
|
165 | 165 |
try: |
166 | 166 |
AssertCommand(["mkdir", "-p", rapi_dir]) |
167 | 167 |
AssertCommand(["mv", tmpru, pathutils.RAPI_USERS_FILE]) |
... | ... | |
185 | 185 |
if spec: |
186 | 186 |
cmd.append("--specs-%s=%s=%d" % (spec_type, spec_val, spec)) |
187 | 187 |
|
188 |
if master.get("secondary", None):
|
|
189 |
cmd.append("--secondary-ip=%s" % master["secondary"])
|
|
188 |
if master.secondary:
|
|
189 |
cmd.append("--secondary-ip=%s" % master.secondary)
|
|
190 | 190 |
|
191 | 191 |
vgname = qa_config.get("vg-name", None) |
192 | 192 |
if vgname: |
... | ... | |
294 | 294 |
master = qa_config.GetMasterNode() |
295 | 295 |
|
296 | 296 |
# Assert that OOB is unavailable for all nodes |
297 |
result_output = GetCommandOutput(master["primary"],
|
|
297 |
result_output = GetCommandOutput(master.primary,
|
|
298 | 298 |
"gnt-node list --verbose --no-headers -o" |
299 | 299 |
" powered") |
300 | 300 |
AssertEqual(compat.all(powered == "(unavail)" |
... | ... | |
306 | 306 |
AssertCommand(["gnt-cluster", "epo", "--all", "some_arg"], fail=True) |
307 | 307 |
|
308 | 308 |
# Unless --all is given master is not allowed to be in the list |
309 |
AssertCommand(["gnt-cluster", "epo", "-f", master["primary"]], fail=True)
|
|
309 |
AssertCommand(["gnt-cluster", "epo", "-f", master.primary], fail=True)
|
|
310 | 310 |
|
311 | 311 |
# This shouldn't fail |
312 | 312 |
AssertCommand(["gnt-cluster", "epo", "-f", "--all"]) |
313 | 313 |
|
314 | 314 |
# All instances should have been stopped now |
315 |
result_output = GetCommandOutput(master["primary"],
|
|
315 |
result_output = GetCommandOutput(master.primary,
|
|
316 | 316 |
"gnt-instance list --no-headers -o status") |
317 | 317 |
# ERROR_down because the instance is stopped but not recorded as such |
318 | 318 |
AssertEqual(compat.all(status == "ERROR_down" |
... | ... | |
322 | 322 |
AssertCommand(["gnt-cluster", "epo", "--on", "-f", "--all"]) |
323 | 323 |
|
324 | 324 |
# All instances should have been started now |
325 |
result_output = GetCommandOutput(master["primary"],
|
|
325 |
result_output = GetCommandOutput(master.primary,
|
|
326 | 326 |
"gnt-instance list --no-headers -o status") |
327 | 327 |
AssertEqual(compat.all(status == "running" |
328 | 328 |
for status in result_output.splitlines()), True) |
... | ... | |
344 | 344 |
AssertCommand(["gnt-debug", "delay", "1"]) |
345 | 345 |
AssertCommand(["gnt-debug", "delay", "--no-master", "1"]) |
346 | 346 |
AssertCommand(["gnt-debug", "delay", "--no-master", |
347 |
"-n", node["primary"], "1"])
|
|
347 |
"-n", node.primary, "1"])
|
|
348 | 348 |
|
349 | 349 |
|
350 | 350 |
def TestClusterReservedLvs(): |
... | ... | |
457 | 457 |
"--rapi-certificate=/dev/null"] |
458 | 458 |
AssertCommand(cmd, fail=True) |
459 | 459 |
|
460 |
rapi_cert_backup = qa_utils.BackupFile(master["primary"],
|
|
460 |
rapi_cert_backup = qa_utils.BackupFile(master.primary,
|
|
461 | 461 |
pathutils.RAPI_CERT_FILE) |
462 | 462 |
try: |
463 | 463 |
# Custom RAPI certificate |
... | ... | |
468 | 468 |
|
469 | 469 |
utils.GenerateSelfSignedSslCert(fh.name, validity=validity) |
470 | 470 |
|
471 |
tmpcert = qa_utils.UploadFile(master["primary"], fh.name)
|
|
471 |
tmpcert = qa_utils.UploadFile(master.primary, fh.name)
|
|
472 | 472 |
try: |
473 | 473 |
AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
474 | 474 |
"--rapi-certificate=%s" % tmpcert]) |
... | ... | |
481 | 481 |
cds_fh.write("\n") |
482 | 482 |
cds_fh.flush() |
483 | 483 |
|
484 |
tmpcds = qa_utils.UploadFile(master["primary"], cds_fh.name)
|
|
484 |
tmpcds = qa_utils.UploadFile(master.primary, cds_fh.name)
|
|
485 | 485 |
try: |
486 | 486 |
AssertCommand(["gnt-cluster", "renew-crypto", "--force", |
487 | 487 |
"--cluster-domain-secret=%s" % tmpcds]) |
... | ... | |
525 | 525 |
if len(instances) < 1: |
526 | 526 |
raise qa_error.Error("Burnin needs at least one instance") |
527 | 527 |
|
528 |
script = qa_utils.UploadFile(master["primary"], "../tools/burnin")
|
|
528 |
script = qa_utils.UploadFile(master.primary, "../tools/burnin")
|
|
529 | 529 |
try: |
530 | 530 |
# Run burnin |
531 | 531 |
cmd = [script, |
... | ... | |
613 | 613 |
f.seek(0) |
614 | 614 |
|
615 | 615 |
# Upload file to master node |
616 |
testname = qa_utils.UploadFile(master["primary"], f.name)
|
|
616 |
testname = qa_utils.UploadFile(master.primary, f.name)
|
|
617 | 617 |
try: |
618 | 618 |
# Copy file to all nodes |
619 | 619 |
AssertCommand(["gnt-cluster", "copyfile", testname]) |
... | ... | |
676 | 676 |
"""cluster-verify reports exclusive_storage set only on one node. |
677 | 677 |
|
678 | 678 |
""" |
679 |
node_name = node["primary"]
|
|
679 |
node_name = node.primary
|
|
680 | 680 |
es_val = _GetBoolClusterField("exclusive_storage") |
681 | 681 |
assert not es_val |
682 | 682 |
AssertCommand(_BuildSetESCmd(True, node_name)) |
... | ... | |
692 | 692 |
vgname = qa_config.get("vg-name", constants.DEFAULT_VG) |
693 | 693 |
lvname1 = _QA_LV_PREFIX + "vol1" |
694 | 694 |
lvname2 = _QA_LV_PREFIX + "vol2" |
695 |
node_name = node["primary"]
|
|
695 |
node_name = node.primary
|
|
696 | 696 |
AssertCommand(["lvcreate", "-L1G", "-n", lvname1, vgname], node=node_name) |
697 | 697 |
AssertClusterVerify(fail=True, errors=[constants.CV_ENODEORPHANLV]) |
698 | 698 |
AssertCommand(["lvcreate", "-L1G", "-n", lvname2, vgname], node=node_name) |
b/qa/qa_daemon.py | ||
---|---|---|
45 | 45 |
|
46 | 46 |
cmd = (utils.ShellQuoteArgs(["gnt-instance", "list", "-o", "status", name]) + |
47 | 47 |
' | grep running') |
48 |
ret = StartSSH(master["primary"], cmd).wait()
|
|
48 |
ret = StartSSH(master.primary, cmd).wait()
|
|
49 | 49 |
return ret == 0 |
50 | 50 |
|
51 | 51 |
|
... | ... | |
87 | 87 |
AssertCommand(["gnt-cluster", "watcher", "pause", "4h"]) |
88 | 88 |
|
89 | 89 |
cmd = ["gnt-cluster", "watcher", "info"] |
90 |
output = GetCommandOutput(master["primary"],
|
|
90 |
output = GetCommandOutput(master.primary,
|
|
91 | 91 |
utils.ShellQuoteArgs(cmd)) |
92 | 92 |
AssertMatch(output, r"^.*\bis paused\b.*") |
93 | 93 |
|
... | ... | |
101 | 101 |
AssertCommand(["gnt-cluster", "watcher", "continue"]) |
102 | 102 |
|
103 | 103 |
cmd = ["gnt-cluster", "watcher", "info"] |
104 |
output = GetCommandOutput(master["primary"],
|
|
104 |
output = GetCommandOutput(master.primary,
|
|
105 | 105 |
utils.ShellQuoteArgs(cmd)) |
106 | 106 |
AssertMatch(output, r"^.*\bis not paused\b.*") |
107 | 107 |
|
b/qa/qa_env.py | ||
---|---|---|
75 | 75 |
pricmd = [pingprimary, "-e"] |
76 | 76 |
seccmd = [pingsecondary, "-e"] |
77 | 77 |
for i in nodes: |
78 |
pricmd.append(i["primary"])
|
|
79 |
if i.get("secondary"):
|
|
80 |
seccmd.append(i["secondary"])
|
|
78 |
pricmd.append(i.primary)
|
|
79 |
if i.secondary:
|
|
80 |
seccmd.append(i.secondary)
|
|
81 | 81 |
|
82 | 82 |
pristr = utils.ShellQuoteArgs(pricmd) |
83 | 83 |
if seccmd: |
b/qa/qa_group.py | ||
---|---|---|
128 | 128 |
|
129 | 129 |
(other_group, ) = qa_utils.GetNonexistentGroups(1) |
130 | 130 |
|
131 |
master_node = qa_config.GetMasterNode()["primary"]
|
|
131 |
master_node = qa_config.GetMasterNode().primary
|
|
132 | 132 |
|
133 | 133 |
def AssertInGroup(group, nodes): |
134 | 134 |
real_output = GetCommandOutput(master_node, |
b/qa/qa_instance.py | ||
---|---|---|
99 | 99 |
""" |
100 | 100 |
master = qa_config.GetMasterNode() |
101 | 101 |
infocmd = utils.ShellQuoteArgs(["gnt-instance", "info", instance]) |
102 |
info_out = qa_utils.GetCommandOutput(master["primary"], infocmd)
|
|
102 |
info_out = qa_utils.GetCommandOutput(master.primary, infocmd)
|
|
103 | 103 |
re_node = re.compile(r"^\s+-\s+(?:primary|secondaries):\s+(\S.+)$") |
104 | 104 |
node_elem = r"([^,()]+)(?:\s+\([^)]+\))?" |
105 | 105 |
# re_nodelist matches a list of nodes returned by gnt-instance info, e.g.: |
... | ... | |
165 | 165 |
master = qa_config.GetMasterNode() |
166 | 166 |
infocmd = utils.ShellQuoteArgs(["gnt-instance", "list", "--no-headers", |
167 | 167 |
"-o", field, instance]) |
168 |
info_out = qa_utils.GetCommandOutput(master["primary"], infocmd).strip()
|
|
168 |
info_out = qa_utils.GetCommandOutput(master.primary, infocmd).strip()
|
|
169 | 169 |
if info_out == "Y": |
170 | 170 |
return True |
171 | 171 |
elif info_out == "N": |
... | ... | |
194 | 194 |
def TestInstanceAddWithPlainDisk(nodes): |
195 | 195 |
"""gnt-instance add -t plain""" |
196 | 196 |
assert len(nodes) == 1 |
197 |
return _DiskTest(nodes[0]["primary"], "plain")
|
|
197 |
return _DiskTest(nodes[0].primary, "plain")
|
|
198 | 198 |
|
199 | 199 |
|
200 | 200 |
@InstanceCheck(None, INST_UP, RETURN_VALUE) |
201 | 201 |
def TestInstanceAddWithDrbdDisk(nodes): |
202 | 202 |
"""gnt-instance add -t drbd""" |
203 | 203 |
assert len(nodes) == 2 |
204 |
return _DiskTest(":".join(map(operator.itemgetter("primary"), nodes)),
|
|
204 |
return _DiskTest(":".join(map(operator.attrgetter("primary"), nodes)),
|
|
205 | 205 |
"drbd") |
206 | 206 |
|
207 | 207 |
|
... | ... | |
238 | 238 |
|
239 | 239 |
master = qa_config.GetMasterNode() |
240 | 240 |
cmd = ["gnt-instance", "list", "--no-headers", "-o", "status", name] |
241 |
result_output = qa_utils.GetCommandOutput(master["primary"],
|
|
241 |
result_output = qa_utils.GetCommandOutput(master.primary,
|
|
242 | 242 |
utils.ShellQuoteArgs(cmd)) |
243 | 243 |
AssertEqual(result_output.strip(), constants.INSTST_RUNNING) |
244 | 244 |
|
... | ... | |
264 | 264 |
cmd = ["cat", utils.PathJoin(pathutils.DATA_DIR, |
265 | 265 |
"ssconf_%s" % constants.SS_INSTANCE_LIST)] |
266 | 266 |
|
267 |
return qa_utils.GetCommandOutput(master["primary"],
|
|
267 |
return qa_utils.GetCommandOutput(master.primary,
|
|
268 | 268 |
utils.ShellQuoteArgs(cmd)).splitlines() |
269 | 269 |
|
270 | 270 |
|
... | ... | |
506 | 506 |
assert len(inodes) == 2 |
507 | 507 |
AssertCommand(["gnt-instance", "modify", "-t", "plain", name]) |
508 | 508 |
AssertCommand(["gnt-instance", "modify", "-t", "drbd", |
509 |
"-n", inodes[1]["primary"], name])
|
|
509 |
"-n", inodes[1].primary, name])
|
|
510 | 510 |
|
511 | 511 |
|
512 | 512 |
@InstanceCheck(INST_DOWN, INST_DOWN, FIRST_ARG) |
... | ... | |
579 | 579 |
# A placeholder; the actual command choice depends on use_ialloc |
580 | 580 |
None, |
581 | 581 |
# Restore the original secondary |
582 |
["--new-secondary=%s" % snode["primary"]],
|
|
582 |
["--new-secondary=%s" % snode.primary],
|
|
583 | 583 |
]: |
584 | 584 |
if data is None: |
585 | 585 |
if use_ialloc: |
586 | 586 |
data = ["-I", constants.DEFAULT_IALLOCATOR_SHORTCUT] |
587 | 587 |
else: |
588 |
data = ["--new-secondary=%s" % othernode["primary"]]
|
|
588 |
data = ["--new-secondary=%s" % othernode.primary]
|
|
589 | 589 |
AssertCommand(buildcmd(data)) |
590 | 590 |
|
591 | 591 |
AssertCommand(buildcmd(["-a"])) |
... | ... | |
632 | 632 |
""" |
633 | 633 |
options = qa_config.get("options", {}) |
634 | 634 |
use_ialloc = options.get("use-iallocators", True) |
635 |
other_seq = ":".join([n["primary"] for n in othernodes])
|
|
636 |
orig_seq = ":".join([n["primary"] for n in inodes])
|
|
635 |
other_seq = ":".join([n.primary for n in othernodes])
|
|
636 |
orig_seq = ":".join([n.primary for n in inodes])
|
|
637 | 637 |
# These fail because the instance is running |
638 | 638 |
_AssertRecreateDisks(["-n", other_seq], instance, fail=True, destroy=False) |
639 | 639 |
if use_ialloc: |
... | ... | |
664 | 664 |
def TestInstanceExport(instance, node): |
665 | 665 |
"""gnt-backup export -n ...""" |
666 | 666 |
name = instance["name"] |
667 |
AssertCommand(["gnt-backup", "export", "-n", node["primary"], name])
|
|
667 |
AssertCommand(["gnt-backup", "export", "-n", node.primary, name])
|
|
668 | 668 |
return qa_utils.ResolveInstanceName(name) |
669 | 669 |
|
670 | 670 |
|
671 | 671 |
@InstanceCheck(None, INST_DOWN, FIRST_ARG) |
672 | 672 |
def TestInstanceExportWithRemove(instance, node): |
673 | 673 |
"""gnt-backup export --remove-instance""" |
674 |
AssertCommand(["gnt-backup", "export", "-n", node["primary"],
|
|
674 |
AssertCommand(["gnt-backup", "export", "-n", node.primary,
|
|
675 | 675 |
"--remove-instance", instance["name"]]) |
676 | 676 |
|
677 | 677 |
|
... | ... | |
688 | 688 |
cmd = (["gnt-backup", "import", |
689 | 689 |
"--disk-template=%s" % templ, |
690 | 690 |
"--no-ip-check", |
691 |
"--src-node=%s" % expnode["primary"],
|
|
691 |
"--src-node=%s" % expnode.primary,
|
|
692 | 692 |
"--src-dir=%s/%s" % (pathutils.EXPORT_DIR, name), |
693 |
"--node=%s" % node["primary"]] +
|
|
693 |
"--node=%s" % node.primary] +
|
|
694 | 694 |
_GetGenericAddParameters(newinst, force_mac=constants.VALUE_GENERATE)) |
695 | 695 |
cmd.append(newinst["name"]) |
696 | 696 |
AssertCommand(cmd) |
... | ... | |
699 | 699 |
|
700 | 700 |
def TestBackupList(expnode): |
701 | 701 |
"""gnt-backup list""" |
702 |
AssertCommand(["gnt-backup", "list", "--node=%s" % expnode["primary"]])
|
|
702 |
AssertCommand(["gnt-backup", "list", "--node=%s" % expnode.primary])
|
|
703 | 703 |
|
704 | 704 |
qa_utils.GenericQueryTest("gnt-backup", query.EXPORT_FIELDS.keys(), |
705 | 705 |
namefield=None, test_unknown=False) |
... | ... | |
726 | 726 |
finally: |
727 | 727 |
set_online(snode) |
728 | 728 |
# Clean up the disks on the offline node |
729 |
for minor in info["drbd-minors"][snode["primary"]]:
|
|
729 |
for minor in info["drbd-minors"][snode.primary]:
|
|
730 | 730 |
AssertCommand(["drbdsetup", str(minor), "down"], node=snode) |
731 | 731 |
AssertCommand(["lvremove", "-f"] + info["volumes"], node=snode) |
b/qa/qa_node.py | ||
---|---|---|
37 | 37 |
|
38 | 38 |
def _NodeAdd(node, readd=False): |
39 | 39 |
if not readd and node.added: |
40 |
raise qa_error.Error("Node %s already in cluster" % node["primary"])
|
|
40 |
raise qa_error.Error("Node %s already in cluster" % node.primary)
|
|
41 | 41 |
elif readd and not node.added: |
42 |
raise qa_error.Error("Node %s not yet in cluster" % node["primary"])
|
|
42 |
raise qa_error.Error("Node %s not yet in cluster" % node.primary)
|
|
43 | 43 |
|
44 | 44 |
cmd = ["gnt-node", "add", "--no-ssh-key-check"] |
45 |
if node.get("secondary", None):
|
|
46 |
cmd.append("--secondary-ip=%s" % node["secondary"])
|
|
45 |
if node.secondary:
|
|
46 |
cmd.append("--secondary-ip=%s" % node.secondary)
|
|
47 | 47 |
if readd: |
48 | 48 |
cmd.append("--readd") |
49 |
cmd.append(node["primary"])
|
|
49 |
cmd.append(node.primary)
|
|
50 | 50 |
|
51 | 51 |
AssertCommand(cmd) |
52 | 52 |
|
... | ... | |
57 | 57 |
|
58 | 58 |
|
59 | 59 |
def _NodeRemove(node): |
60 |
AssertCommand(["gnt-node", "remove", node["primary"]])
|
|
60 |
AssertCommand(["gnt-node", "remove", node.primary])
|
|
61 | 61 |
node.MarkRemoved() |
62 | 62 |
|
63 | 63 |
|
64 | 64 |
def MakeNodeOffline(node, value): |
65 | 65 |
"""gnt-node modify --offline=value""" |
66 | 66 |
# value in ["yes", "no"] |
67 |
AssertCommand(["gnt-node", "modify", "--offline", value, node["primary"]])
|
|
67 |
AssertCommand(["gnt-node", "modify", "--offline", value, node.primary])
|
|
68 | 68 |
|
69 | 69 |
|
70 | 70 |
def TestNodeAddAll(): |
... | ... | |
128 | 128 |
cmd = ["gnt-node", "list-storage", "--storage-type", storage_type, |
129 | 129 |
"--output=node,name,allocatable", "--separator=|", |
130 | 130 |
"--no-headers"] |
131 |
output = qa_utils.GetCommandOutput(master["primary"],
|
|
131 |
output = qa_utils.GetCommandOutput(master.primary,
|
|
132 | 132 |
utils.ShellQuoteArgs(cmd)) |
133 | 133 |
|
134 | 134 |
# Test with up to two devices |
... | ... | |
158 | 158 |
cmd = ["gnt-node", "list-storage", "--storage-type", storage_type, |
159 | 159 |
"--output=name,allocatable", "--separator=|", |
160 | 160 |
"--no-headers", node_name] |
161 |
listout = qa_utils.GetCommandOutput(master["primary"],
|
|
161 |
listout = qa_utils.GetCommandOutput(master.primary,
|
|
162 | 162 |
utils.ShellQuoteArgs(cmd)) |
163 | 163 |
for line in listout.splitlines(): |
164 | 164 |
(vfy_name, vfy_allocatable) = line.split("|") |
... | ... | |
182 | 182 |
" it to have no primary instances.") |
183 | 183 |
|
184 | 184 |
# Fail over to secondary node |
185 |
AssertCommand(["gnt-node", "failover", "-f", node["primary"]])
|
|
185 |
AssertCommand(["gnt-node", "failover", "-f", node.primary])
|
|
186 | 186 |
|
187 | 187 |
# ... and back again. |
188 |
AssertCommand(["gnt-node", "failover", "-f", node2["primary"]])
|
|
188 |
AssertCommand(["gnt-node", "failover", "-f", node2.primary])
|
|
189 | 189 |
|
190 | 190 |
|
191 | 191 |
def TestNodeEvacuate(node, node2): |
... | ... | |
199 | 199 |
|
200 | 200 |
# Evacuate all secondary instances |
201 | 201 |
AssertCommand(["gnt-node", "evacuate", "-f", |
202 |
"--new-secondary=%s" % node3["primary"], node2["primary"]])
|
|
202 |
"--new-secondary=%s" % node3.primary, node2.primary])
|
|
203 | 203 |
|
204 | 204 |
# ... and back again. |
205 | 205 |
AssertCommand(["gnt-node", "evacuate", "-f", |
206 |
"--new-secondary=%s" % node2["primary"], node3["primary"]])
|
|
206 |
"--new-secondary=%s" % node2.primary, node3.primary])
|
|
207 | 207 |
finally: |
208 | 208 |
node3.Release() |
209 | 209 |
|
... | ... | |
213 | 213 |
for flag in ["master-candidate", "drained", "offline"]: |
214 | 214 |
for value in ["yes", "no"]: |
215 | 215 |
AssertCommand(["gnt-node", "modify", "--force", |
216 |
"--%s=%s" % (flag, value), node["primary"]])
|
|
216 |
"--%s=%s" % (flag, value), node.primary])
|
|
217 | 217 |
|
218 | 218 |
AssertCommand(["gnt-node", "modify", "--master-candidate=yes", |
219 |
"--auto-promote", node["primary"]])
|
|
219 |
"--auto-promote", node.primary])
|
|
220 | 220 |
|
221 | 221 |
# Test setting secondary IP address |
222 |
AssertCommand(["gnt-node", "modify", "--secondary-ip=%s" % node["secondary"],
|
|
223 |
node["primary"]])
|
|
222 |
AssertCommand(["gnt-node", "modify", "--secondary-ip=%s" % node.secondary,
|
|
223 |
node.primary])
|
|
224 | 224 |
|
225 | 225 |
|
226 | 226 |
def _CreateOobScriptStructure(): |
227 | 227 |
"""Create a simple OOB handling script and its structure.""" |
228 | 228 |
master = qa_config.GetMasterNode() |
229 | 229 |
|
230 |
data_path = qa_utils.UploadData(master["primary"], "")
|
|
231 |
verify_path = qa_utils.UploadData(master["primary"], "")
|
|
232 |
exit_code_path = qa_utils.UploadData(master["primary"], "")
|
|
230 |
data_path = qa_utils.UploadData(master.primary, "")
|
|
231 |
verify_path = qa_utils.UploadData(master.primary, "")
|
|
232 |
exit_code_path = qa_utils.UploadData(master.primary, "")
|
|
233 | 233 |
|
234 | 234 |
oob_script = (("#!/bin/bash\n" |
235 | 235 |
"echo \"$@\" > %s\n" |
... | ... | |
237 | 237 |
"exit $(< %s)\n") % |
238 | 238 |
(utils.ShellQuote(verify_path), utils.ShellQuote(data_path), |
239 | 239 |
utils.ShellQuote(exit_code_path))) |
240 |
oob_path = qa_utils.UploadData(master["primary"], oob_script, mode=0700)
|
|
240 |
oob_path = qa_utils.UploadData(master.primary, oob_script, mode=0700)
|
|
241 | 241 |
|
242 | 242 |
return [oob_path, verify_path, data_path, exit_code_path] |
243 | 243 |
|
... | ... | |
245 | 245 |
def _UpdateOobFile(path, data): |
246 | 246 |
"""Updates the data file with data.""" |
247 | 247 |
master = qa_config.GetMasterNode() |
248 |
qa_utils.UploadData(master["primary"], data, filename=path)
|
|
248 |
qa_utils.UploadData(master.primary, data, filename=path)
|
|
249 | 249 |
|
250 | 250 |
|
251 | 251 |
def _AssertOobCall(verify_path, expected_args): |
... | ... | |
253 | 253 |
master = qa_config.GetMasterNode() |
254 | 254 |
|
255 | 255 |
verify_output_cmd = utils.ShellQuoteArgs(["cat", verify_path]) |
256 |
output = qa_utils.GetCommandOutput(master["primary"], verify_output_cmd,
|
|
256 |
output = qa_utils.GetCommandOutput(master.primary, verify_output_cmd,
|
|
257 | 257 |
tty=False) |
258 | 258 |
|
259 | 259 |
AssertEqual(expected_args, output.strip()) |
... | ... | |
265 | 265 |
|
266 | 266 |
node = qa_config.AcquireNode(exclude=master) |
267 | 267 |
|
268 |
master_name = master["primary"]
|
|
269 |
node_name = node["primary"]
|
|
268 |
master_name = master.primary
|
|
269 |
node_name = node.primary
|
|
270 | 270 |
full_node_name = qa_utils.ResolveNodeName(node) |
271 | 271 |
|
272 | 272 |
(oob_path, verify_path, |
... | ... | |
391 | 391 |
AssertCommand(["gnt-node", "health"], fail=True) |
392 | 392 |
|
393 | 393 |
# Different OOB script for node |
394 |
verify_path2 = qa_utils.UploadData(master["primary"], "")
|
|
394 |
verify_path2 = qa_utils.UploadData(master.primary, "")
|
|
395 | 395 |
oob_script = ("#!/bin/sh\n" |
396 | 396 |
"echo \"$@\" > %s\n") % verify_path2 |
397 |
oob_path2 = qa_utils.UploadData(master["primary"], oob_script, mode=0700)
|
|
397 |
oob_path2 = qa_utils.UploadData(master.primary, oob_script, mode=0700)
|
|
398 | 398 |
|
399 | 399 |
try: |
400 | 400 |
AssertCommand(["gnt-node", "modify", "--node-parameters", |
... | ... | |
424 | 424 |
|
425 | 425 |
def TestNodeListDrbd(node): |
426 | 426 |
"""gnt-node list-drbd""" |
427 |
AssertCommand(["gnt-node", "list-drbd", node["primary"]]) |
|
427 |
AssertCommand(["gnt-node", "list-drbd", node.primary]) |
b/qa/qa_os.py | ||
---|---|---|
109 | 109 |
cmd = " && ".join(parts) |
110 | 110 |
|
111 | 111 |
print qa_utils.FormatInfo("Setting up %s with %s OS definition" % |
112 |
(node["primary"],
|
|
112 |
(node.primary,
|
|
113 | 113 |
["an invalid", "a valid"][int(valid)])) |
114 | 114 |
|
115 | 115 |
AssertCommand(cmd, node=node) |
... | ... | |
163 | 163 |
AssertCommand(["gnt-os", "diagnose"], fail=(mode != _ALL_VALID)) |
164 | 164 |
|
165 | 165 |
# Diagnose again, ignoring exit status |
166 |
output = qa_utils.GetCommandOutput(master["primary"],
|
|
166 |
output = qa_utils.GetCommandOutput(master.primary,
|
|
167 | 167 |
"gnt-os diagnose || :") |
168 | 168 |
for line in output.splitlines(): |
169 | 169 |
if line.startswith("OS: %s [global status:" % name): |
... | ... | |
173 | 173 |
|
174 | 174 |
# Check info for all |
175 | 175 |
cmd = ["gnt-os", "info"] |
176 |
output = qa_utils.GetCommandOutput(master["primary"],
|
|
176 |
output = qa_utils.GetCommandOutput(master.primary,
|
|
177 | 177 |
utils.ShellQuoteArgs(cmd)) |
178 | 178 |
AssertIn("%s:" % name, output.splitlines()) |
179 | 179 |
|
180 | 180 |
# Check info for OS |
181 | 181 |
cmd = ["gnt-os", "info", name] |
182 |
output = qa_utils.GetCommandOutput(master["primary"],
|
|
182 |
output = qa_utils.GetCommandOutput(master.primary,
|
|
183 | 183 |
utils.ShellQuoteArgs(cmd)).splitlines() |
184 | 184 |
AssertIn("%s:" % name, output) |
185 | 185 |
for (field, value) in [("valid", mode == _ALL_VALID), |
... | ... | |
189 | 189 |
|
190 | 190 |
# Only valid OSes should be listed |
191 | 191 |
cmd = ["gnt-os", "list", "--no-headers"] |
192 |
output = qa_utils.GetCommandOutput(master["primary"],
|
|
192 |
output = qa_utils.GetCommandOutput(master.primary,
|
|
193 | 193 |
utils.ShellQuoteArgs(cmd)) |
194 | 194 |
if mode == _ALL_VALID and not (hidden or blacklisted): |
195 | 195 |
assert_fn = AssertIn |
b/qa/qa_rapi.py | ||
---|---|---|
80 | 80 |
|
81 | 81 |
# Write to temporary file |
82 | 82 |
_rapi_ca = tempfile.NamedTemporaryFile() |
83 |
_rapi_ca.write(qa_utils.GetCommandOutput(master["primary"],
|
|
83 |
_rapi_ca.write(qa_utils.GetCommandOutput(master.primary,
|
|
84 | 84 |
utils.ShellQuoteArgs(cmd))) |
85 | 85 |
_rapi_ca.flush() |
86 | 86 |
|
... | ... | |
88 | 88 |
cfg_curl = rapi.client.GenericCurlConfig(cafile=_rapi_ca.name, |
89 | 89 |
proxy="") |
90 | 90 |
|
91 |
_rapi_client = rapi.client.GanetiRapiClient(master["primary"], port=port,
|
|
91 |
_rapi_client = rapi.client.GanetiRapiClient(master.primary, port=port,
|
|
92 | 92 |
username=username, |
93 | 93 |
password=password, |
94 | 94 |
curl_config_fn=cfg_curl) |
... | ... | |
418 | 418 |
_VerifyNode(node_data) |
419 | 419 |
|
420 | 420 |
_DoTests([ |
421 |
("/2/nodes/%s" % node["primary"], _VerifyNode, "GET", None),
|
|
421 |
("/2/nodes/%s" % node.primary, _VerifyNode, "GET", None),
|
|
422 | 422 |
("/2/nodes", _VerifyNodesList, "GET", None), |
423 | 423 |
("/2/nodes?bulk=1", _VerifyNodesBulk, "GET", None), |
424 | 424 |
]) |
... | ... | |
575 | 575 |
constants.DT_PLAIN, |
576 | 576 |
disks, nics, |
577 | 577 |
os=qa_config.get("os"), |
578 |
pnode=node["primary"],
|
|
578 |
pnode=node.primary,
|
|
579 | 579 |
beparams=beparams) |
580 | 580 |
else: |
581 | 581 |
body = { |
... | ... | |
584 | 584 |
"name": instance["name"], |
585 | 585 |
"os_type": qa_config.get("os"), |
586 | 586 |
"disk_template": constants.DT_PLAIN, |
587 |
"pnode": node["primary"],
|
|
587 |
"pnode": node.primary,
|
|
588 | 588 |
"beparams": beparams, |
589 | 589 |
"disks": disks, |
590 | 590 |
"nics": nics, |
... | ... | |
783 | 783 |
# note: pnode:snode are the *current* nodes, so we move it first to |
784 | 784 |
# tnode:pnode, then back to pnode:snode |
785 | 785 |
for si, di, pn, sn in [(src_instance["name"], dest_instance["name"], |
786 |
tnode["primary"], pnode["primary"]),
|
|
786 |
tnode.primary, pnode.primary),
|
|
787 | 787 |
(dest_instance["name"], src_instance["name"], |
788 |
pnode["primary"], snode["primary"])]:
|
|
788 |
pnode.primary, snode.primary)]:
|
|
789 | 789 |
cmd = [ |
790 | 790 |
"../tools/move-instance", |
791 | 791 |
"--verbose", |
... | ... | |
796 | 796 |
"--dest-primary-node=%s" % pn, |
797 | 797 |
"--dest-secondary-node=%s" % sn, |
798 | 798 |
"--net=0:mac=%s" % constants.VALUE_GENERATE, |
799 |
master["primary"],
|
|
800 |
master["primary"],
|
|
799 |
master.primary,
|
|
800 |
master.primary,
|
|
801 | 801 |
si, |
802 | 802 |
] |
803 | 803 |
|
b/qa/qa_tags.py | ||
---|---|---|
72 | 72 |
|
73 | 73 |
def TestNodeTags(node): |
74 | 74 |
"""gnt-node tags""" |
75 |
_TestTags(constants.TAG_NODE, node["primary"])
|
|
75 |
_TestTags(constants.TAG_NODE, node.primary)
|
|
76 | 76 |
|
77 | 77 |
|
78 | 78 |
def TestGroupTags(group): |
b/qa/qa_utils.py | ||
---|---|---|
404 | 404 |
""" |
405 | 405 |
master = qa_config.GetMasterNode() |
406 | 406 |
|
407 |
output = GetCommandOutput(master["primary"], utils.ShellQuoteArgs(cmd))
|
|
407 |
output = GetCommandOutput(master.primary, utils.ShellQuoteArgs(cmd))
|
|
408 | 408 |
for line in output.splitlines(): |
409 | 409 |
(lkey, lvalue) = line.split(":", 1) |
410 | 410 |
if lkey == key: |
... | ... | |
427 | 427 |
"""Gets the full name of a node. |
428 | 428 |
|
429 | 429 |
""" |
430 |
return _ResolveName(["gnt-node", "info", node["primary"]],
|
|
430 |
return _ResolveName(["gnt-node", "info", node.primary],
|
|
431 | 431 |
"Node name") |
432 | 432 |
|
433 | 433 |
|
... | ... | |
441 | 441 |
# Get list of all instances |
442 | 442 |
cmd = ["gnt-instance", "list", "--separator=:", "--no-headers", |
443 | 443 |
"--output=name,pnode,snodes"] |
444 |
output = GetCommandOutput(master["primary"], utils.ShellQuoteArgs(cmd))
|
|
444 |
output = GetCommandOutput(master.primary, utils.ShellQuoteArgs(cmd))
|
|
445 | 445 |
|
446 | 446 |
instances = [] |
447 | 447 |
for line in output.splitlines(): |
... | ... | |
485 | 485 |
if names: |
486 | 486 |
cmd.extend(names) |
487 | 487 |
|
488 |
return GetCommandOutput(master["primary"],
|
|
488 |
return GetCommandOutput(master.primary,
|
|
489 | 489 |
utils.ShellQuoteArgs(cmd)).splitlines() |
490 | 490 |
|
491 | 491 |
|
... | ... | |
541 | 541 |
|
542 | 542 |
# Check listed fields (all, must be sorted) |
543 | 543 |
realcmd = [cmd, "list-fields", "--separator=|", "--no-headers"] |
544 |
output = GetCommandOutput(master["primary"],
|
|
544 |
output = GetCommandOutput(master.primary,
|
|
545 | 545 |
utils.ShellQuoteArgs(realcmd)).splitlines() |
546 | 546 |
AssertEqual([line.split("|", 1)[0] for line in output], |
547 | 547 |
utils.NiceSort(fields)) |
... | ... | |
570 | 570 |
|
571 | 571 |
""" |
572 | 572 |
master = qa_config.GetMasterNode() |
573 |
tmp_hosts = UploadData(master["primary"], "", mode=0644)
|
|
573 |
tmp_hosts = UploadData(master.primary, "", mode=0644)
|
|
574 | 574 |
|
575 | 575 |
data = [] |
576 | 576 |
for localhost in ("::1", "127.0.0.1"): |
... | ... | |
595 | 595 |
|
596 | 596 |
""" |
597 | 597 |
master = qa_config.GetMasterNode() |
598 |
tmp_hosts = UploadData(master["primary"], "", mode=0644)
|
|
598 |
tmp_hosts = UploadData(master.primary, "", mode=0644)
|
|
599 | 599 |
quoted_tmp_hosts = utils.ShellQuote(tmp_hosts) |
600 | 600 |
|
601 | 601 |
sed_data = " ".join(hostnames) |
... | ... | |
623 | 623 |
master_node = qa_config.GetMasterNode() |
624 | 624 |
|
625 | 625 |
# Build command to connect to master node |
626 |
master_ssh = GetSSHCommand(master_node["primary"], "--")
|
|
626 |
master_ssh = GetSSHCommand(master_node.primary, "--")
|
|
627 | 627 |
|
628 | 628 |
if running: |
629 | 629 |
running_shellval = "1" |
Also available in: Unified diff