Revision 82122173 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
350 | 350 |
pubkey - the public key of the cluster |
351 | 351 |
|
352 | 352 |
""" |
353 |
if os.path.exists('/etc/ssh/ssh_known_hosts'):
|
|
354 |
f = open('/etc/ssh/ssh_known_hosts', 'r+')
|
|
353 |
if os.path.exists(constants.SSH_KNOWN_HOSTS_FILE):
|
|
354 |
f = open(constants.SSH_KNOWN_HOSTS_FILE, 'r+')
|
|
355 | 355 |
else: |
356 |
f = open('/etc/ssh/ssh_known_hosts', 'w+')
|
|
356 |
f = open(constants.SSH_KNOWN_HOSTS_FILE, 'w+')
|
|
357 | 357 |
|
358 | 358 |
inthere = False |
359 | 359 |
|
... | ... | |
405 | 405 |
save_lines = save_lines + add_lines |
406 | 406 |
|
407 | 407 |
# Write a new file and replace old. |
408 |
fd, tmpname = tempfile.mkstemp('tmp', 'ssh_known_hosts_', '/etc/ssh') |
|
408 |
fd, tmpname = tempfile.mkstemp('.tmp', 'known_hosts.', |
|
409 |
constants.DATA_DIR) |
|
409 | 410 |
newfile = os.fdopen(fd, 'w') |
410 |
newfile.write(''.join(save_lines)) |
|
411 |
newfile.close() |
|
411 |
try: |
|
412 |
newfile.write(''.join(save_lines)) |
|
413 |
finally: |
|
414 |
newfile.close() |
|
412 | 415 |
logger.Debug("Wrote new known_hosts.") |
413 |
os.rename(tmpname, '/etc/ssh/ssh_known_hosts')
|
|
416 |
os.rename(tmpname, constants.SSH_KNOWN_HOSTS_FILE)
|
|
414 | 417 |
|
415 | 418 |
elif add_lines: |
416 | 419 |
# Simply appending a new line will do the trick. |
... | ... | |
448 | 451 |
node: the name of this host as a fqdn |
449 | 452 |
|
450 | 453 |
""" |
451 |
utils.RemoveFile('/root/.ssh/known_hosts') |
|
452 |
|
|
453 | 454 |
if os.path.exists('/root/.ssh/id_dsa'): |
454 | 455 |
utils.CreateBackup('/root/.ssh/id_dsa') |
455 | 456 |
if os.path.exists('/root/.ssh/id_dsa.pub'): |
... | ... | |
1365 | 1366 |
raise errors.OpExecError("PEM must end with newline") |
1366 | 1367 |
logger.Info("copy cluster pass to %s and starting the node daemon" % node) |
1367 | 1368 |
|
1368 |
# remove first the root's known_hosts file |
|
1369 |
utils.RemoveFile("/root/.ssh/known_hosts") |
|
1370 | 1369 |
# and then connect with ssh to set password and start ganeti-noded |
1371 | 1370 |
# note that all the below variables are sanitized at this point, |
1372 | 1371 |
# either by being constants or by the checks above |
... | ... | |
1442 | 1441 |
dist_nodes.remove(myself.name) |
1443 | 1442 |
|
1444 | 1443 |
logger.Debug("Copying hosts and known_hosts to all nodes") |
1445 |
for fname in ("/etc/hosts", "/etc/ssh/ssh_known_hosts"):
|
|
1444 |
for fname in ("/etc/hosts", constants.SSH_KNOWN_HOSTS_FILE):
|
|
1446 | 1445 |
result = rpc.call_upload_file(dist_nodes, fname) |
1447 | 1446 |
for to_node in dist_nodes: |
1448 | 1447 |
if not result[to_node]: |
... | ... | |
2798 | 2797 |
|
2799 | 2798 |
hyper = hypervisor.GetHypervisor() |
2800 | 2799 |
console_cmd = hyper.GetShellCommandForConsole(instance.name) |
2801 |
return node, console_cmd |
|
2800 |
# build ssh cmdline |
|
2801 |
argv = ["ssh", "-q", "-t"] |
|
2802 |
argv.extend(ssh.KNOWN_HOSTS_OPTS) |
|
2803 |
argv.extend(ssh.BATCH_MODE_OPTS) |
|
2804 |
argv.append(node) |
|
2805 |
argv.append(console_cmd) |
|
2806 |
return "ssh", argv |
|
2802 | 2807 |
|
2803 | 2808 |
|
2804 | 2809 |
class LUAddMDDRBDComponent(LogicalUnit): |
Also available in: Unified diff