autotest: Deprecate create_hosts(connectivity_class) argument
BUG=chromium:878497
TEST=None
Change-Id: I833a02c4c5596e9bdfe82986ac2b6a22d6b2e9cb
Reviewed-on: https://chromium-review.googlesource.com/1194435
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Allen Li <ayatane@chromium.org>
diff --git a/server/hosts/factory.py b/server/hosts/factory.py
index f31fc2c..3c610d9 100644
--- a/server/hosts/factory.py
+++ b/server/hosts/factory.py
@@ -7,6 +7,7 @@
from autotest_lib.client.bin import local_host
from autotest_lib.client.bin import utils
+from autotest_lib.client.common_lib import deprecation
from autotest_lib.client.common_lib import error
from autotest_lib.client.common_lib import global_config
from autotest_lib.server import utils as server_utils
@@ -152,14 +153,19 @@
from the autoserv runtime or the AFE.
@param host_class: Host class to use, if None, will attempt to detect
the correct class.
- @param connectivity_class: Connectivity class to use, if None will decide
- based off of hostname and config settings.
+ @param connectivity_class: DEPRECATED. Connectivity class is determined
+ internally.
@param args: Args that will be passed to the constructor of
the new host class.
@returns: A host object which is an instance of the newly created
host class.
"""
+ # Argument deprecated
+ if connectivity_class is not None:
+ deprecation.warn('server.create_hosts:connectivity_class')
+ connectivity_class = None
+
detected_args = _get_host_arguments(machine)
hostname = detected_args.pop('hostname')
afe_host = detected_args['afe_host']
@@ -173,8 +179,7 @@
host_os = label[len(full_os_prefix):]
break
- if not connectivity_class:
- connectivity_class = _choose_connectivity_class(hostname, args['port'])
+ connectivity_class = _choose_connectivity_class(hostname, args['port'])
# TODO(kevcheng): get rid of the host detection using host attributes.
host_class = (host_class
or OS_HOST_DICT.get(afe_host.attributes.get('os_type'))
diff --git a/server/hosts/factory_unittest.py b/server/hosts/factory_unittest.py
index 38bbcc4..983f93e 100755
--- a/server/hosts/factory_unittest.py
+++ b/server/hosts/factory_unittest.py
@@ -97,15 +97,13 @@
def test_use_specified(self):
- """Confirm that the specified host and connectivity classes are used."""
+ """Confirm that the specified host class is used."""
machine = _gen_machine_dict()
host_obj = factory.create_host(
machine,
_gen_mock_host('specified'),
- _gen_mock_conn('specified')
)
self.assertEqual(host_obj._host_cls_name, 'specified')
- self.assertEqual(host_obj._conn_cls_name, 'specified')
def test_detect_host_by_os_label(self):