Revision 5484cda5 lib/ssh.py
b/lib/ssh.py | ||
---|---|---|
34 | 34 |
from ganeti import netutils |
35 | 35 |
from ganeti import pathutils |
36 | 36 |
from ganeti import vcluster |
37 |
from ganeti import compat |
|
37 | 38 |
|
38 | 39 |
|
39 | 40 |
def FormatParamikoFingerprint(fingerprint): |
... | ... | |
95 | 96 |
"authorized_keys"]] |
96 | 97 |
|
97 | 98 |
|
99 |
def GetAllUserFiles(user, mkdir=False, dircheck=True, _homedir_fn=None): |
|
100 |
"""Wrapper over L{GetUserFiles} to retrieve files for all SSH key types. |
|
101 |
|
|
102 |
See L{GetUserFiles} for details. |
|
103 |
|
|
104 |
@rtype: tuple; (string, dict with string as key, tuple of (string, string) as |
|
105 |
value) |
|
106 |
|
|
107 |
""" |
|
108 |
helper = compat.partial(GetUserFiles, user, mkdir=mkdir, dircheck=dircheck, |
|
109 |
_homedir_fn=_homedir_fn) |
|
110 |
result = [(kind, helper(kind=kind)) for kind in constants.SSHK_ALL] |
|
111 |
|
|
112 |
authorized_keys = [i for (_, (_, _, i)) in result] |
|
113 |
|
|
114 |
assert len(frozenset(authorized_keys)) == 1, \ |
|
115 |
"Different paths for authorized_keys were returned" |
|
116 |
|
|
117 |
return (authorized_keys[0], |
|
118 |
dict((kind, (privkey, pubkey)) |
|
119 |
for (kind, (privkey, pubkey, _)) in result)) |
|
120 |
|
|
121 |
|
|
98 | 122 |
class SshRunner: |
99 | 123 |
"""Wrapper for SSH commands. |
100 | 124 |
|
Also available in: Unified diff