Add an option to disable/enable the use of ssh-agent with paramiko. On servers running large numbers of jobs it's possible for autoserv to DoS the ssh-agent with too many requests, so it's useful to be able to restrict the usage to keyfiles only in certain situations.

Signed-off-by: John Admanski <jadmanski@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@4311 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/global_config.ini b/global_config.ini
index 53057c9..db578ed 100644
--- a/global_config.ini
+++ b/global_config.ini
@@ -91,6 +91,9 @@
 # Autotest server operators *really should* set this to True, specially if
 # using ssh_engine 'paramiko'.
 require_atfork_module: False
+# Set to False to disable ssh-agent usage with paramiko
+use_sshagent_with_paramiko: True
+
 
 [PACKAGES]
 serve_packages_from_autoserv: True
diff --git a/server/hosts/paramiko_host.py b/server/hosts/paramiko_host.py
index 87568a0..0b5a228 100644
--- a/server/hosts/paramiko_host.py
+++ b/server/hosts/paramiko_host.py
@@ -1,7 +1,7 @@
 import os, sys, time, signal, socket, re, fnmatch, logging, threading
 import paramiko
 
-from autotest_lib.client.common_lib import utils, error
+from autotest_lib.client.common_lib import utils, error, global_config
 from autotest_lib.server import subcommand
 from autotest_lib.server.hosts import abstract_ssh
 
@@ -87,9 +87,12 @@
                 user_keys[path] = key
 
         # load up all the ssh agent keys
-        ssh_agent = paramiko.Agent()
-        for i, key in enumerate(ssh_agent.get_keys()):
-            user_keys['agent-key-%d' % i] = key
+        use_sshagent = global_config.global_config.get_config_value(
+            'AUTOSERV', 'use_sshagent_with_paramiko', type=bool)
+        if use_sshagent:
+            ssh_agent = paramiko.Agent()
+            for i, key in enumerate(ssh_agent.get_keys()):
+                user_keys['agent-key-%d' % i] = key
 
         return user_keys