import qa_instance
import qa_job_utils
import qa_logging
+ import qa_rapi
import qa_utils
-from qa_utils import AssertEqual, AssertCommand, GetCommandOutput, \
- CheckFileUnmodified
+from qa_utils import AssertEqual, AssertCommand, AssertRedirectedCommand, \
+ GetCommandOutput, CheckFileUnmodified
# Prefix for LVM volumes created by QA code during tests
AssertCommand(["gnt-cluster", "init", "-D", param, name], fail=True)
- def TestClusterInit(rapi_user, rapi_secret):
+ def TestClusterInit():
"""gnt-cluster init"""
- master = qa_config.GetMasterNode()
-
- rapi_users_path = qa_utils.MakeNodePath(master, pathutils.RAPI_USERS_FILE)
- rapi_dir = os.path.dirname(rapi_users_path)
-
- # First create the RAPI credentials
- fh = tempfile.NamedTemporaryFile()
- try:
- fh.write("%s %s write\n" % (rapi_user, rapi_secret))
- fh.flush()
-
- tmpru = qa_utils.UploadFile(master.primary, fh.name)
- try:
- AssertCommand(["mkdir", "-p", rapi_dir])
- AssertCommand(["mv", tmpru, rapi_users_path])
- finally:
- AssertCommand(["rm", "-f", tmpru])
- finally:
- fh.close()
-
+ # If we don't modify the SSH setup by Ganeti, we have to ensure connectivity
+ # before
++ master = qa_config.GetMasterNode()
+ if not qa_config.GetModifySshSetup():
+ (key_type, _, priv_key_file, pub_key_file, auth_key_path) = \
+ qa_config.GetSshConfig()
+ AssertCommand("echo -e 'y\n' | ssh-keygen -t %s -f %s -q -N ''"
+ % (key_type, priv_key_file))
+ AssertCommand("cat %s >> %s" % (pub_key_file, auth_key_path))
+ for node in qa_config.get("nodes"):
+ if node != master:
+ for key_file in [priv_key_file, pub_key_file]:
+ AssertCommand("scp -oStrictHostKeyChecking=no %s %s:%s" %
+ (key_file, node.primary, key_file))
+ AssertCommand("ssh %s \'cat %s >> %s\'"
+ % (node.primary, pub_key_file, auth_key_path))
+
# Initialize cluster
enabled_disk_templates = qa_config.GetEnabledDiskTemplates()
cmd = [