From ebae9e37e512ff0f2b3bd6767ac8c013e3531ce8 Mon Sep 17 00:00:00 2001
From: Michael Hanselmann <hansmi@google.com>
Date: Wed, 24 Oct 2012 01:11:45 +0200
Subject: [PATCH] prepare_node_join: Move daemon SSH files to constants
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This dictionary will also be useful in β€œgnt-node add”.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>
---
 lib/constants.py               | 6 ++++++
 lib/tools/prepare_node_join.py | 9 +--------
 2 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/lib/constants.py b/lib/constants.py
index 5beb6abec..b0745ec92 100644
--- a/lib/constants.py
+++ b/lib/constants.py
@@ -2060,5 +2060,11 @@ SSHS_SSH_HOST_KEY = "ssh_host_key"
 SSHS_SSH_ROOT_KEY = "ssh_root_key"
 SSHS_NODE_DAEMON_CERTIFICATE = "node_daemon_certificate"
 
+#: Key files for SSH daemon
+SSH_DAEMON_KEYFILES = {
+  SSHK_RSA: (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
+  SSHK_DSA: (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
+  }
+
 # Do not re-export imported modules
 del re, _vcsversion, _autoconf, socket, pathutils
diff --git a/lib/tools/prepare_node_join.py b/lib/tools/prepare_node_join.py
index e9e9f77b7..e8f7c8d67 100644
--- a/lib/tools/prepare_node_join.py
+++ b/lib/tools/prepare_node_join.py
@@ -58,13 +58,6 @@ _DATA_CHECK = ht.TStrictDict(False, True, {
   constants.SSHS_SSH_ROOT_KEY: _SSH_KEY_LIST,
   })
 
-_SSH_DAEMON_KEYFILES = {
-  constants.SSHK_RSA:
-    (pathutils.SSH_HOST_RSA_PRIV, pathutils.SSH_HOST_RSA_PUB),
-  constants.SSHK_DSA:
-    (pathutils.SSH_HOST_DSA_PRIV, pathutils.SSH_HOST_DSA_PUB),
-  }
-
 
 class JoinError(errors.GenericError):
   """Local class for reporting errors.
@@ -258,7 +251,7 @@ def UpdateSshDaemon(data, dry_run, _runcmd_fn=utils.RunCmd,
     return
 
   if _keyfiles is None:
-    _keyfiles = _SSH_DAEMON_KEYFILES
+    _keyfiles = constants.SSH_DAEMON_KEYFILES
 
   logging.info("Updating SSH daemon key files")
   _UpdateKeyFiles(keys, dry_run, _keyfiles)
-- 
GitLab