Revision aecba21e qa/qa_instance.py
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) |
Also available in: Unified diff