From 06fcbaf11b9125806310749f2b8e8a3e89710be8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= <rn@google.com>
Date: Mon, 12 Apr 2010 14:48:19 +0200
Subject: [PATCH] QA: Make sure RAPI credentials are setup on cluster init
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This patch makes sure that the Ganeti RAPI credentials are setup,
if any, on cluster init time.

Signed-off-by: RenΓ© Nussbaumer <rn@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 qa/qa-sample.json |  3 +++
 qa/qa_cluster.py  | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/qa/qa-sample.json b/qa/qa-sample.json
index 8f6f4db88..ae09588c0 100644
--- a/qa/qa-sample.json
+++ b/qa/qa-sample.json
@@ -6,6 +6,9 @@
   "os": "debian-etch",
   "mem": "512M",
 
+  "rapi-user": "foobar",
+  "rapi-pass": "barfoo",
+
   "# Lists of disk sizes": null,
   "disk": ["1G", "512M"],
   "disk-growth": ["2G", "768M"],
diff --git a/qa/qa_cluster.py b/qa/qa_cluster.py
index 5c88a04e9..37d1c45a9 100644
--- a/qa/qa_cluster.py
+++ b/qa/qa_cluster.py
@@ -79,6 +79,21 @@ def TestClusterInit():
   AssertEqual(StartSSH(master['primary'],
                        utils.ShellQuoteArgs(cmd)).wait(), 0)
 
+  # Create RAPI credentials
+  rapi_user = qa_config.get("rapi-user", default=None)
+  rapi_pass = qa_config.get("rapi-pass", default=None)
+
+  if rapi_user and rapi_pass:
+    cmds = []
+
+    cred_string = "%s %s write" % (rapi_user, rapi_pass)
+    cmds.append(("echo %s >> %s" %
+                 (utils.ShellQuote(cred_string),
+                  utils.ShellQuote(constants.RAPI_USERS_FILE))))
+    cmds.append("%s stop-master" % constants.DAEMON_UTIL)
+    cmds.append("%s start-master" % constants.DAEMON_UTIL)
+    AssertEqual(StartSSH(master['primary'], ' && '.join(cmds)).wait(), 0)
+
 
 def TestClusterRename():
   """gnt-cluster rename"""
-- 
GitLab