+def RunHardwareFailureTests(instance, pnode, snode):
+ """Test cluster internal hardware failure recovery.
+
+ """
+ if qa_config.TestEnabled('instance-failover'):
+ RunTest(qa_instance.TestInstanceFailover, instance)
+
+ if qa_config.TestEnabled('instance-replace-disks'):
+ othernode = qa_config.AcquireNode(exclude=[pnode, snode])
+ try:
+ RunTest(qa_instance.TestReplaceDisks,
+ instance, pnode, snode, othernode)
+ finally:
+ qa_config.ReleaseNode(othernode)
+
+ if qa_config.TestEnabled('node-evacuate'):
+ RunTest(qa_node.TestNodeEvacuate, pnode, snode)
+
+ if qa_config.TestEnabled('node-failover'):
+ RunTest(qa_node.TestNodeFailover, pnode, snode)
+
+ if qa_config.TestEnabled('instance-disk-failure'):
+ RunTest(qa_instance.TestInstanceMasterDiskFailure,
+ instance, pnode, snode)
+ RunTest(qa_instance.TestInstanceSecondaryDiskFailure,
+ instance, pnode, snode)
+
+
+def main():
+ """Main program.
+
+ """
+ parser = optparse.OptionParser(usage="%prog [options] <config-file>")
+ parser.add_option('--yes-do-it', dest='yes_do_it',
+ action="store_true",
+ help="Really execute the tests")
+ (qa_config.options, args) = parser.parse_args()
+
+ if len(args) == 1:
+ (config_file, ) = args
+ else:
+ parser.error("Wrong number of arguments.")
+
+ if not qa_config.options.yes_do_it:
+ print ("Executing this script irreversibly destroys any Ganeti\n"
+ "configuration on all nodes involved. If you really want\n"
+ "to start testing, supply the --yes-do-it option.")
+ sys.exit(1)