Commit 33993ab8 authored by René Nussbaumer's avatar René Nussbaumer
Browse files

Adding a paramiko fingerprint format helper

And provide unittests for them
Signed-off-by: default avatarRené Nussbaumer <>
Reviewed-by: default avatarIustin Pop <>
parent e4d89284
......@@ -26,12 +26,25 @@
import os
import logging
import re
from ganeti import utils
from ganeti import errors
from ganeti import constants
def FormatParamikoFingerprint(fingerprint):
"""Formats the fingerprint of L{paramiko.PKey.get_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):
"""Return the paths of a user's ssh files.
......@@ -47,6 +47,12 @@ class TestKnownHosts(testutils.GanetiTestCase):
"%s ssh-rsa %s\n" % (cfg.GetClusterName(),
def testFormatParamikoFingerprintCorrect(self):
self.assertEqual(ssh.FormatParamikoFingerprint("C0Ffee"), "c0:ff:ee")
def testFormatParamikoFingerprintNotDividableByTwo(self):
self.assertRaises(AssertionError, ssh.FormatParamikoFingerprint, "C0Ffe")
if __name__ == '__main__':
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment