Revision 8647a52c
b/tools/setup-ssh | ||
---|---|---|
201 | 201 |
else: |
202 | 202 |
stderr_handler.setLevel(logging.ERROR) |
203 | 203 |
|
204 |
# This is the paramiko logger instance |
|
205 |
paramiko_logger = logging.getLogger("paramiko") |
|
206 | 204 |
root_logger = logging.getLogger("") |
207 | 205 |
root_logger.setLevel(logging.NOTSET) |
208 | 206 |
root_logger.addHandler(stderr_handler) |
209 | 207 |
root_logger.addHandler(file_handler) |
208 |
|
|
209 |
# This is the paramiko logger instance |
|
210 |
paramiko_logger = logging.getLogger("paramiko") |
|
210 | 211 |
paramiko_logger.addHandler(file_handler) |
211 | 212 |
|
212 | 213 |
|
... | ... | |
220 | 221 |
|
221 | 222 |
passwd = getpass.getpass(prompt="%s password:" % constants.GANETI_RUNAS) |
222 | 223 |
|
224 |
# Below, we need to join() the transport objects, as otherwise the |
|
225 |
# following happens: |
|
226 |
# - the main thread finishes |
|
227 |
# - the atexit functions run (in the main thread), and cause the |
|
228 |
# logging file to be closed |
|
229 |
# - a tiny bit later, the transport thread is finally ending, and |
|
230 |
# wants to log one more message, which fails as the file is closed |
|
231 |
# now |
|
232 |
|
|
223 | 233 |
for host in args: |
224 | 234 |
transport = paramiko.Transport((host, netutils.GetDaemonPort("ssh"))) |
225 |
transport.connect(username=constants.GANETI_RUNAS, password=passwd) |
|
235 |
try: |
|
236 |
transport.connect(username=constants.GANETI_RUNAS, password=passwd) |
|
237 |
except Exception, err: |
|
238 |
logging.error("Connection or authentication failed to host %s: %s", |
|
239 |
host, err) |
|
240 |
transport.close() |
|
241 |
# this is needed for compatibility with older Paramiko or Python |
|
242 |
# versions |
|
243 |
transport.join() |
|
244 |
continue |
|
226 | 245 |
try: |
227 | 246 |
try: |
228 | 247 |
SetupSSH(transport) |
229 | 248 |
SetupNodeDaemon(transport) |
230 | 249 |
except errors.GenericError, err: |
231 |
logging.fatal("While doing setup on host %s an error occured: %s", host,
|
|
232 |
err) |
|
250 |
logging.error("While doing setup on host %s an error occured: %s",
|
|
251 |
host, err)
|
|
233 | 252 |
finally: |
234 | 253 |
transport.close() |
254 |
# this is needed for compatibility with older Paramiko or Python |
|
255 |
# versions |
|
256 |
transport.join() |
|
235 | 257 |
|
236 | 258 |
|
237 | 259 |
if __name__ == "__main__": |
Also available in: Unified diff