From 416f9cf177801cecfe39f5249d73e3a4a85f0bbd Mon Sep 17 00:00:00 2001 From: Niko Hermanns Date: Wed, 30 Nov 2016 11:59:44 +0100 Subject: adding odl-pipeline Change-Id: I1c08883f0d68a61ce9e10c5596aec1a259eed71f Signed-off-by: Nikolas Hermanns --- odl-pipeline/lib/utils/ssh_util.py | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 odl-pipeline/lib/utils/ssh_util.py (limited to 'odl-pipeline/lib/utils/ssh_util.py') diff --git a/odl-pipeline/lib/utils/ssh_util.py b/odl-pipeline/lib/utils/ssh_util.py new file mode 100755 index 0000000..e70aed3 --- /dev/null +++ b/odl-pipeline/lib/utils/ssh_util.py @@ -0,0 +1,36 @@ +# +# Copyright (c) 2015 All rights reserved +# This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# +import os +home = os.getenv("HOME") +SSH_CONFIG = {'TMP_SSH_CONFIG': "./tmp/ssh_config", + 'ID_RSA_PATH': "%s/.ssh/id_rsa" % home} + + +class SshUtil(object): + + @staticmethod + def gen_ssh_config(node_list): + config = ["UserKnownHostsFile=/dev/null", + "StrictHostKeyChecking=no", + "ForwardAgent yes", + "GSSAPIAuthentication=no", + "LogLevel ERROR"] + for node in node_list: + config.append(node.to_ssh_config()) + with open(SSH_CONFIG['TMP_SSH_CONFIG'], 'w') as f: + f.write('\n'.join(config)) + + @staticmethod + def get_config_file_path(): + return SSH_CONFIG['TMP_SSH_CONFIG'] + + @staticmethod + def get_id_rsa(): + return (SSH_CONFIG['ID_RSA_PATH']) -- cgit 1.2.3-korg