Move the cli RPC authorization_headers code into rpc_client_lib.
Make autotest_lib.server.frontend use it for RPC authentication.

Signed-off-by: Gregory Smith <gps@google.com>


git-svn-id: http://test.kernel.org/svn/autotest/trunk@4231 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/cli/rpc.py b/cli/rpc.py
index aea2b20..1b50ea7 100644
--- a/cli/rpc.py
+++ b/cli/rpc.py
@@ -2,7 +2,7 @@
 # Copyright 2008 Google Inc. All Rights Reserved.
 #
 
-import os, getpass
+import os
 from autotest_lib.frontend.afe import rpc_client_lib
 from autotest_lib.frontend.afe.json_rpc import proxy
 from autotest_lib.client.common_lib import global_config, utils
@@ -29,20 +29,6 @@
     return web_server
 
 
-def base_authorization_headers(username, server):
-    if not username:
-        if 'AUTOTEST_USER' in os.environ:
-            username = os.environ['AUTOTEST_USER']
-        else:
-            username = getpass.getuser()
-    return {'AUTHORIZATION' : username}
-
-
-authorization_headers = utils.import_site_function(
-        __file__, 'autotest_lib.cli.site_rpc', 'authorization_headers',
-        base_authorization_headers)
-
-
 class rpc_comm(object):
     """Shared AFE/TKO RPC class stuff"""
     def __init__(self, web_server, rpc_path, username):
@@ -54,7 +40,8 @@
     def _connect(self, rpc_path):
         # This does not fail even if the address is wrong.
         # We need to wait for an actual RPC to fail
-        headers = authorization_headers(self.username, self.web_server)
+        headers = rpc_client_lib.authorization_headers(self.username,
+                                                       self.web_server)
         rpc_server = self.web_server + rpc_path
         return rpc_client_lib.get_proxy(rpc_server, headers=headers)