Revision 2892a4c9 lib/ssh.py
b/lib/ssh.py | ||
---|---|---|
75 | 75 |
self.cluster_name = cluster_name |
76 | 76 |
|
77 | 77 |
def _BuildSshOptions(self, batch, ask_key, use_cluster_key, |
78 |
strict_host_check, private_key=None): |
|
78 |
strict_host_check, private_key=None, quiet=True):
|
|
79 | 79 |
"""Builds a list with needed SSH options. |
80 | 80 |
|
81 | 81 |
@param batch: same as ssh's batch option |
... | ... | |
85 | 85 |
HostKeyAlias name |
86 | 86 |
@param strict_host_check: this makes the host key checking strict |
87 | 87 |
@param private_key: use this private key instead of the default |
88 |
@param quiet: whether to enable -q to ssh |
|
88 | 89 |
|
89 | 90 |
@rtype: list |
90 | 91 |
@return: the list of options ready to use in L{utils.RunCmd} |
... | ... | |
101 | 102 |
if use_cluster_key: |
102 | 103 |
options.append("-oHostKeyAlias=%s" % self.cluster_name) |
103 | 104 |
|
105 |
if quiet: |
|
106 |
options.append("-q") |
|
107 |
|
|
104 | 108 |
if private_key: |
105 | 109 |
options.append("-i%s" % private_key) |
106 | 110 |
|
... | ... | |
133 | 137 |
|
134 | 138 |
def BuildCmd(self, hostname, user, command, batch=True, ask_key=False, |
135 | 139 |
tty=False, use_cluster_key=True, strict_host_check=True, |
136 |
private_key=None): |
|
140 |
private_key=None, quiet=True):
|
|
137 | 141 |
"""Build an ssh command to execute a command on a remote node. |
138 | 142 |
|
139 | 143 |
@param hostname: the target host, string |
... | ... | |
147 | 151 |
cluster-global SSH key |
148 | 152 |
@param strict_host_check: whether to check the host's SSH key at all |
149 | 153 |
@param private_key: use this private key instead of the default |
154 |
@param quiet: whether to enable -q to ssh |
|
150 | 155 |
|
151 | 156 |
@return: the ssh call to run 'command' on the remote host. |
152 | 157 |
|
153 | 158 |
""" |
154 |
argv = [constants.SSH, "-q"]
|
|
159 |
argv = [constants.SSH] |
|
155 | 160 |
argv.extend(self._BuildSshOptions(batch, ask_key, use_cluster_key, |
156 |
strict_host_check, private_key)) |
|
161 |
strict_host_check, private_key, |
|
162 |
quiet=quiet)) |
|
157 | 163 |
if tty: |
158 | 164 |
argv.append("-t") |
159 | 165 |
argv.extend(["%s@%s" % (user, hostname), command]) |
... | ... | |
191 | 197 |
logging.error("File %s does not exist", filename) |
192 | 198 |
return False |
193 | 199 |
|
194 |
command = [constants.SCP, "-q", "-p"]
|
|
200 |
command = [constants.SCP, "-p"] |
|
195 | 201 |
command.extend(self._BuildSshOptions(True, False, True, True)) |
196 | 202 |
command.append(filename) |
197 | 203 |
command.append("%s:%s" % (node, filename)) |
Also available in: Unified diff