[autotest] Move get_global_afe_hostname to server/site_utils
Move get_global_afe_hostname to server/site_utils so that
other code can import it without django env setup hassle.
TEST=Run unittest, run shard_client
BUG=chromium:568873
Change-Id: I574d3dc00e2f79af0283487ec9cac6fb8bfd9fd4
Reviewed-on: https://chromium-review.googlesource.com/317276
Commit-Ready: Fang Deng <fdeng@chromium.org>
Tested-by: Fang Deng <fdeng@chromium.org>
Reviewed-by: Dan Shi <dshi@chromium.org>
diff --git a/frontend/afe/rpc_interface_unittest.py b/frontend/afe/rpc_interface_unittest.py
index eec4b41..222f162 100755
--- a/frontend/afe/rpc_interface_unittest.py
+++ b/frontend/afe/rpc_interface_unittest.py
@@ -8,7 +8,6 @@
from autotest_lib.frontend.afe import frontend_test_utils
from autotest_lib.frontend.afe import models, rpc_interface, frontend_test_utils
from autotest_lib.frontend.afe import model_logic, model_attributes
-from autotest_lib.frontend.afe import rpc_utils
from autotest_lib.client.common_lib import global_config
from autotest_lib.client.common_lib import control_data
from autotest_lib.client.common_lib import error
@@ -16,6 +15,7 @@
from autotest_lib.client.common_lib.test_utils import mock
from autotest_lib.client.common_lib.test_utils import unittest
from autotest_lib.server import frontend
+from autotest_lib.server import utils as server_utils
from autotest_lib.server.cros.dynamic_suite import frontend_wrappers
CLIENT = control_data.CONTROL_TYPE_NAMES.CLIENT
@@ -467,7 +467,7 @@
self.god.stub_with(frontend_wrappers, 'RetryingAFE', mock_afe)
mock_afe2 = frontend_wrappers.RetryingAFE.expect_new(
- server=rpc_utils.get_global_afe_hostname(), user=None)
+ server=server_utils.get_global_afe_hostname(), user=None)
mock_afe2.run.expect_call('modify_host', id=host.id,
locked=True, lock_reason='_modify_host_helper lock')
diff --git a/frontend/afe/rpc_utils.py b/frontend/afe/rpc_utils.py
index b9a5106..f7f079a 100644
--- a/frontend/afe/rpc_utils.py
+++ b/frontend/afe/rpc_utils.py
@@ -1284,12 +1284,6 @@
return label
-def get_global_afe_hostname():
- """Read the hostname of the global AFE from the global configuration."""
- return global_config.global_config.get_config_value(
- 'SERVER', 'global_afe_hostname')
-
-
def route_rpc_to_master(func):
"""Route RPC to master AFE.
@@ -1343,7 +1337,7 @@
if server_utils.is_shard():
afe = frontend_wrappers.RetryingAFE(
- server=get_global_afe_hostname(),
+ server=server_utils.get_global_afe_hostname(),
user=thread_local.get_user())
return afe.run(func.func_name, **kwargs)
return func(**kwargs)