Make Paramiko an optional dependency for listrunner
authorMichael Hanselmann <hansmi@google.com>
Wed, 24 Oct 2012 00:01:42 +0000 (02:01 +0200)
committerMichael Hanselmann <hansmi@google.com>
Fri, 26 Oct 2012 14:33:49 +0000 (16:33 +0200)
With the move away from “setup-ssh”, Paramiko is no longer necessary to
configure SSH on nodes.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Iustin Pop <iustin@google.com>

INSTALL
configure.ac
lib/ssh.py
test/ganeti.ssh_unittest.py
tools/ganeti-listrunner

diff --git a/INSTALL b/INSTALL
index 03e9363..0087e53 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -41,8 +41,8 @@ Before installing, please verify that you have the following programs:
   python 2.4 (optional, used for node daemon memory locking)
 - `socat <http://www.dest-unreach.org/socat/>`_, see :ref:`note
   <socat-note>` below
-- `Paramiko <http://www.lag.net/paramiko/>`_, if you want automated SSH
-  setup; optional otherwise but manual setup of the nodes required
+- `Paramiko <http://www.lag.net/paramiko/>`_, if you want to use
+  ``ganeti-listrunner``
 - `affinity Python module <http://pypi.python.org/pypi/affinity/0.1.0>`_,
   optional python package for supporting CPU pinning under KVM
 - `ElementTree Python module <http://effbot.org/zone/element-index.htm>`_,
index da46415..14554a3 100644 (file)
@@ -663,14 +663,7 @@ AC_PYTHON_MODULE(pyparsing, t)
 AC_PYTHON_MODULE(pyinotify, t)
 AC_PYTHON_MODULE(pycurl, t)
 AC_PYTHON_MODULE(affinity)
-
-# This is optional but then we've limited functionality
 AC_PYTHON_MODULE(paramiko)
-if test "$HAVE_PYMOD_PARAMIKO" = "no"; then
-  AC_MSG_WARN(m4_normalize([You do not have Paramiko installed. While this is
-                            optional you have to configure SSH and the node
-                            daemon on the joining nodes yourself.]))
-fi
 
 AC_CONFIG_FILES([ Makefile ])
 
index 1307148..dba13df 100644 (file)
@@ -26,7 +26,6 @@
 
 import os
 import logging
-import re
 
 from ganeti import utils
 from ganeti import errors
@@ -37,18 +36,6 @@ from ganeti import vcluster
 from ganeti import compat
 
 
-def FormatParamikoFingerprint(fingerprint):
-  """Format paramiko PKey fingerprint.
-
-  @type fingerprint: str
-  @param fingerprint: PKey fingerprint
-  @return: The string hex representation of the fingerprint
-
-  """
-  assert len(fingerprint) % 2 == 0
-  return ":".join(re.findall(r"..", fingerprint.lower()))
-
-
 def GetUserFiles(user, mkdir=False, dircheck=True, kind=constants.SSHK_DSA,
                  _homedir_fn=None):
   """Return the paths of a user's SSH files.
index bb4f015..a2c13cd 100755 (executable)
@@ -49,12 +49,6 @@ class TestKnownHosts(testutils.GanetiTestCase):
         "%s ssh-rsa %s\n" % (cfg.GetClusterName(),
                              mocks.FAKE_CLUSTER_KEY))
 
-  def testFormatParamikoFingerprintCorrect(self):
-    self.assertEqual(ssh.FormatParamikoFingerprint("C0Ffee"), "c0:ff:ee")
-
-  def testFormatParamikoFingerprintNotDividableByTwo(self):
-    self.assertRaises(AssertionError, ssh.FormatParamikoFingerprint, "C0Ffe")
-
 
 class TestGetUserFiles(unittest.TestCase):
   def setUp(self):
index 566d986..061d53b 100755 (executable)
@@ -64,7 +64,14 @@ import sys
 import time
 import traceback
 
-import paramiko
+try:
+  import paramiko
+except ImportError:
+  print >> sys.stderr, \
+    ("The \"paramiko\" module could not be imported. Install it from your"
+     " distribution's repository. The package is usually named"
+     " \"python-paramiko\".")
+  sys.exit(1)
 
 
 REMOTE_PATH_BASE = "/tmp/listrunner"