Revision cc4b14f0
b/qa/qa_instance.py | ||
---|---|---|
83 | 83 |
raise |
84 | 84 |
|
85 | 85 |
|
86 |
def _DestroyInstanceVolumes(instance):
|
|
87 |
"""Remove all the LVM volumes of an instance.
|
|
86 |
def _GetInstanceInfo(instance):
|
|
87 |
"""Return information about the actual state of an instance.
|
|
88 | 88 |
|
89 |
This is used to simulate HW errors (dead nodes, broken disks...); the |
|
90 |
configuration of the instance is not affected. |
|
89 |
The pieces of information returned are: |
|
90 |
- "nodes": instance nodes, a list of strings |
|
91 |
- "volumes": instance volume IDs, a list of strings |
|
92 |
@type instance: dictionary |
|
93 |
@param instance: the instance |
|
94 |
@return: dictionary |
|
91 | 95 |
|
92 | 96 |
""" |
93 | 97 |
master = qa_config.GetMasterNode() |
... | ... | |
118 | 122 |
vols.append(m.group(1)) |
119 | 123 |
assert vols |
120 | 124 |
assert nodes |
121 |
for node in nodes: |
|
125 |
return {"nodes": nodes, "volumes": vols} |
|
126 |
|
|
127 |
|
|
128 |
def _DestroyInstanceVolumes(instance): |
|
129 |
"""Remove all the LVM volumes of an instance. |
|
130 |
|
|
131 |
This is used to simulate HW errors (dead nodes, broken disks...); the |
|
132 |
configuration of the instance is not affected. |
|
133 |
@type instance: dictionary |
|
134 |
@param instance: the instance |
|
135 |
|
|
136 |
""" |
|
137 |
info = _GetInstanceInfo(instance) |
|
138 |
vols = info["volumes"] |
|
139 |
for node in info["nodes"]: |
|
122 | 140 |
AssertCommand(["lvremove", "-f"] + vols, node=node) |
123 | 141 |
|
124 | 142 |
|
... | ... | |
446 | 464 |
["-p"], |
447 | 465 |
["-s"], |
448 | 466 |
["--new-secondary=%s" % othernode["primary"]], |
449 |
# and restore |
|
450 |
["--new-secondary=%s" % snode["primary"]], |
|
467 |
["-I", constants.DEFAULT_IALLOCATOR_SHORTCUT], |
|
451 | 468 |
]: |
452 | 469 |
AssertCommand(buildcmd(data)) |
453 | 470 |
|
471 |
# Restore the original secondary, if needed |
|
472 |
currsec = _GetInstanceInfo(instance)["nodes"][1] |
|
473 |
if currsec != snode["primary"]: |
|
474 |
["--new-secondary=%s" % snode["primary"]], |
|
475 |
|
|
454 | 476 |
AssertCommand(buildcmd(["-a"])) |
455 | 477 |
AssertCommand(["gnt-instance", "stop", instance["name"]]) |
456 | 478 |
AssertCommand(buildcmd(["-a"]), fail=True) |
... | ... | |
508 | 530 |
_AssertRecreateDisks([], instance) |
509 | 531 |
# Move disks away |
510 | 532 |
_AssertRecreateDisks(["-I", "hail"], instance) |
533 |
# Move disks somewhere else |
|
534 |
_AssertRecreateDisks(["-I", constants.DEFAULT_IALLOCATOR_SHORTCUT], instance) |
|
511 | 535 |
# Move disks back |
512 | 536 |
_AssertRecreateDisks(["-n", orig_seq], instance, check=False) |
513 | 537 |
# This and InstanceCheck decoration check that the disks are working |
Also available in: Unified diff