[autotest] Delete Android provisioning support.

This deletes support for provisioning Android DUTs in the test lab.

BUG=chromium:834335
TEST=sanity suite in local instance

Change-Id: I7e0404cd0efd3f664514b7f24c81cd02f4f6b2b5
Reviewed-on: https://chromium-review.googlesource.com/1036660
Commit-Ready: Richard Barnette <jrbarnette@chromium.org>
Tested-by: Richard Barnette <jrbarnette@chromium.org>
Reviewed-by: Richard Barnette <jrbarnette@google.com>
Reviewed-by: Jacob Kopczynski <jkop@chromium.org>
diff --git a/server/cros/dynamic_suite/dynamic_suite.py b/server/cros/dynamic_suite/dynamic_suite.py
index 8c71bf9..99df668 100644
--- a/server/cros/dynamic_suite/dynamic_suite.py
+++ b/server/cros/dynamic_suite/dynamic_suite.py
@@ -210,7 +210,6 @@
     _VERSION_PREFIXES = frozenset((
             provision.CROS_VERSION_PREFIX,
             provision.CROS_ANDROID_VERSION_PREFIX,
-            provision.ANDROID_BUILD_VERSION_PREFIX,
     ))
 
     def __init__(
@@ -379,10 +378,7 @@
 
     def _init_devserver(self, devserver_url):
         """Initialize devserver attribute."""
-        if provision.ANDROID_BUILD_VERSION_PREFIX in self.builds:
-            self.devserver = dev_server.AndroidBuildServer(devserver_url)
-        else:
-            self.devserver = dev_server.ImageServer(devserver_url)
+        self.devserver = dev_server.ImageServer(devserver_url)
 
     def _init_test_source_build(self, test_source_build):
         """Initialize test_source_build attribute."""
diff --git a/server/cros/provision.py b/server/cros/provision.py
index 71437d7..e17ad3d 100644
--- a/server/cros/provision.py
+++ b/server/cros/provision.py
@@ -16,13 +16,11 @@
 ### Constants for label prefixes
 CROS_VERSION_PREFIX = Key.CROS_VERSION
 CROS_ANDROID_VERSION_PREFIX = Key.CROS_ANDROID_VERSION
-ANDROID_BUILD_VERSION_PREFIX = Key.ANDROID_BUILD_VERSION
 FW_RW_VERSION_PREFIX = Key.FIRMWARE_RW_VERSION
 FW_RO_VERSION_PREFIX = Key.FIRMWARE_RO_VERSION
 
 # So far the word cheets is only way to distinguish between ARC and Android
 # build.
-_ANDROID_BUILD_REGEX = r'.+/(?!cheets).+/P?([0-9]+|LATEST)'
 _CROS_ANDROID_BUILD_REGEX = r'.+/cheets.*/P?([0-9]+|LATEST)'
 
 # Special label to skip provision and run reset instead.
@@ -65,18 +63,13 @@
         These images have names like `cave-release/R57-9030.0.0`.
       * `CROS_ANDROID_VERSION_PREFIX` for Chrome OS Android version strings.
         These images have names like `git_nyc-arc/cheets_x86-user/3512523`.
-      * `ANDROID_BUILD_VERSION_PREFIX` for Android build versions
-        These images have names like
-        `git_mnc-release/shamu-userdebug/2457013`.
 
     @param image: The image name to be parsed.
     @returns: A string that is the prefix of version labels for the type
               of image identified by `image`.
 
     """
-    if re.match(_ANDROID_BUILD_REGEX, image, re.I):
-        return ANDROID_BUILD_VERSION_PREFIX
-    elif re.match(_CROS_ANDROID_BUILD_REGEX, image, re.I):
+    if re.match(_CROS_ANDROID_BUILD_REGEX, image, re.I):
         return CROS_ANDROID_VERSION_PREFIX
     else:
         return CROS_VERSION_PREFIX
@@ -312,8 +305,6 @@
                 'provision_FirmwareUpdate',
                 extra_kwargs={'rw_only': True,
                               'tag': 'rw_only'}),
-        ANDROID_BUILD_VERSION_PREFIX : actionables.TestActionable(
-                'provision_AndroidUpdate'),
     }
 
     name = 'provision'
diff --git a/server/cros/provision_unittest.py b/server/cros/provision_unittest.py
index 2daa23d..d0ca926 100755
--- a/server/cros/provision_unittest.py
+++ b/server/cros/provision_unittest.py
@@ -18,9 +18,6 @@
     'git_nyc-mr1-arc/cheets_arm-user/P6244267',
     'git_nyc-mr1-arc/cheets_x86-user/P6256537',
 ]
-_ANDROID_VERSION_SAMPLES = [
-    'git_mnc-release/shamu-userdebug/2457013'
-]
 
 
 class ActionTestCase(unittest.TestCase):
@@ -58,11 +55,6 @@
         self._do_test_prefixes(provision.CROS_ANDROID_VERSION_PREFIX,
                                _CROS_ANDROID_VERSION_SAMPLES)
 
-    def test_android_prefix(self):
-        """Test handling of Android version strings."""
-        self._do_test_prefixes(provision.ANDROID_BUILD_VERSION_PREFIX,
-                               _ANDROID_VERSION_SAMPLES)
-
 
 if __name__ == '__main__':
     unittest.main()
diff --git a/server/hosts/host_info.py b/server/hosts/host_info.py
index d9d36eb..fd79462 100644
--- a/server/hosts/host_info.py
+++ b/server/hosts/host_info.py
@@ -41,7 +41,6 @@
     _VERSION_LABELS = (
             provision.CROS_VERSION_PREFIX,
             provision.CROS_ANDROID_VERSION_PREFIX,
-            provision.ANDROID_BUILD_VERSION_PREFIX,
     )
 
     def __init__(self, labels=None, attributes=None):
diff --git a/server/hosts/host_info_unittest.py b/server/hosts/host_info_unittest.py
index 45b668e..1fcf2bf 100644
--- a/server/hosts/host_info_unittest.py
+++ b/server/hosts/host_info_unittest.py
@@ -57,15 +57,13 @@
 
     def test_build_needs_prefix(self):
         """The build prefix is of the form '<type>-version:'"""
-        self.info.labels = ['cros-version', 'ab-version',
-                            'fwrw-version', 'fwro-version']
+        self.info.labels = ['cros-version', 'fwrw-version', 'fwro-version']
         self.assertIsNone(self.info.build)
 
 
     def test_build_prefix_must_be_anchored(self):
         """Ensure that build ignores prefixes occuring mid-string."""
-        self.info.labels = ['not-at-start-cros-version:cros1',
-                            'not-at-start-ab-version:ab1']
+        self.info.labels = ['not-at-start-cros-version:cros1']
         self.assertIsNone(self.info.build)
 
 
@@ -79,15 +77,13 @@
         """When multiple labels match, first one should be used as build."""
         self.info.labels = ['cros-version:cros1', 'cros-version:cros2']
         self.assertEqual(self.info.build, 'cros1')
-        self.info.labels = ['ab-version:ab1', 'ab-version:ab2']
-        self.assertEqual(self.info.build, 'ab1')
 
 
     def test_build_prefer_cros_over_others(self):
         """When multiple versions are available, prefer cros."""
-        self.info.labels = ['ab-version:ab1', 'cros-version:cros1']
+        self.info.labels = ['cheets-version:ab1', 'cros-version:cros1']
         self.assertEqual(self.info.build, 'cros1')
-        self.info.labels = ['cros-version:cros1', 'ab-version:ab1']
+        self.info.labels = ['cros-version:cros1', 'cheets-version:ab1']
         self.assertEqual(self.info.build, 'cros1')
 
 
@@ -139,9 +135,9 @@
 
 
     def test_clear_version_labels_no_labels(self):
-        """When no version labels exit, do nothing for clear_version_labels."""
+        """When no version labels exist, do nothing for clear_version_labels."""
         original_labels = ['board:something', 'os:something_else',
-                           'pool:mypool', 'ab-version-corrupted:blah',
+                           'pool:mypool', 'cheets-version-corrupted:blah',
                            'cros-version']
         self.info.labels = list(original_labels)
         self.info.clear_version_labels()
@@ -150,14 +146,15 @@
 
     def test_clear_all_version_labels(self):
         """Clear each recognized type of version label."""
-        original_labels = ['extra_label', 'cros-version:cr1', 'ab-version:ab1']
+        original_labels = ['extra_label', 'cros-version:cr1',
+                           'cheets-version:ab1']
         self.info.labels = list(original_labels)
         self.info.clear_version_labels()
         self.assertListEqual(self.info.labels, ['extra_label'])
 
     def test_clear_all_version_label_prefixes(self):
         """Clear each recognized type of version label with empty value."""
-        original_labels = ['extra_label', 'cros-version:', 'ab-version:']
+        original_labels = ['extra_label', 'cros-version:', 'cheets-version:']
         self.info.labels = list(original_labels)
         self.info.clear_version_labels()
         self.assertListEqual(self.info.labels, ['extra_label'])
@@ -165,16 +162,16 @@
 
     def test_set_version_labels_updates_in_place(self):
         """Update version label in place if prefix already exists."""
-        self.info.labels = ['extra', 'cros-version:X', 'ab-version:Y']
+        self.info.labels = ['extra', 'cros-version:X', 'cheets-version:Y']
         self.info.set_version_label('cros-version', 'Z')
         self.assertListEqual(self.info.labels, ['extra', 'cros-version:Z',
-                                                'ab-version:Y'])
+                                                'cheets-version:Y'])
 
     def test_set_version_labels_appends(self):
         """Append a new version label if the prefix doesn't exist."""
-        self.info.labels = ['extra', 'ab-version:Y']
+        self.info.labels = ['extra', 'cheets-version:Y']
         self.info.set_version_label('cros-version', 'Z')
-        self.assertListEqual(self.info.labels, ['extra', 'ab-version:Y',
+        self.assertListEqual(self.info.labels, ['extra', 'cheets-version:Y',
                                                 'cros-version:Z'])
 
 
diff --git a/server/site_tests/provision_AndroidUpdate/control b/server/site_tests/provision_AndroidUpdate/control
deleted file mode 100644
index 8ab4095..0000000
--- a/server/site_tests/provision_AndroidUpdate/control
+++ /dev/null
@@ -1,39 +0,0 @@
-# Copyright 2016 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-
-AUTHOR = "sbasi"
-NAME = "provision_AndroidUpdate"
-PURPOSE = "Provision an android-based system to the correct OS version."
-TIME = "MEDIUM"
-TEST_CATEGORY = "System"
-TEST_CLASS = "provision"
-TEST_TYPE = "Server"
-
-DOC = """
-This is a test used by the provision control segment in autoserv to set the
-ab-version label of a host to the desired setting and reimage the host to a
-specific version.
-"""
-
-
-from autotest_lib.client.common_lib import error, utils
-from autotest_lib.client.cros import constants
-
-
-# Autoserv may inject a local variable called value to supply the desired
-# version. If it does not exist, check if it was supplied as a test arg.
-if not locals().get('value'):
-    args = utils.args_to_dict(args)
-    if not args.get('value'):
-        raise error.TestError("No provision value!")
-    value = args['value']
-
-
-def run(machine):
-    host = hosts.create_host(machine)
-    job.run_test('provision_AndroidUpdate', host=host, value=value)
-
-
-job.parallel_simple(run, machines)
diff --git a/server/site_tests/provision_AndroidUpdate/provision_AndroidUpdate.py b/server/site_tests/provision_AndroidUpdate/provision_AndroidUpdate.py
deleted file mode 100644
index 8738760..0000000
--- a/server/site_tests/provision_AndroidUpdate/provision_AndroidUpdate.py
+++ /dev/null
@@ -1,100 +0,0 @@
-# Copyright 2016 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import logging
-import sys
-
-from autotest_lib.client.common_lib import error
-from autotest_lib.client.common_lib import global_config
-from autotest_lib.server import afe_utils
-from autotest_lib.server import test
-
-
-_CONFIG = global_config.global_config
-# pylint: disable-msg=E1120
-_IMAGE_URL_PATTERN = _CONFIG.get_config_value(
-        'ANDROID', 'image_url_pattern', type=str)
-
-
-class provision_AndroidUpdate(test.test):
-    """A test that can provision a machine to the correct Android version."""
-    version = 1
-
-    def initialize(self, host, value, force=False, is_test_na=False,
-                   repair=False):
-        """Initialize.
-
-        @param host: The host object to update to |value|.
-        @param value: String of the image we want to install on the host.
-        @param force: not used by initialize.
-        @param is_test_na: boolean, if True, will simply skip the test
-                           and emit TestNAError. The control file
-                           determines whether the test should be skipped
-                           and passes the decision via this argument. Note
-                           we can't raise TestNAError in control file as it won't
-                           be caught and handled properly.
-        @param repair: not used by initialize.
-        """
-        if is_test_na:
-            raise error.TestNAError('Provisioning not applicable.')
-        # We check value in initialize so that it fails faster.
-        if not (value or repair):
-            raise error.TestFail('No build version specified.')
-
-
-    def run_once(self, host, value=None, force=False, repair=False):
-        """The method called by the control file to start the test.
-
-        @param host: The host object to update to |value|.
-        @param value: The host object to provision with a build corresponding
-                      to |value|.
-        @param force: True iff we should re-provision the machine regardless of
-                      the current image version.  If False and the image
-                      version matches our expected image version, no
-                      provisioning will be done.
-        @param repair: If True, we are doing a repair provision, therefore the
-                       build to provision is looked up from the AFE's
-                       get_stable_version RPC.
-        """
-        logging.debug('Start provisioning %s to %s', host, value)
-
-        if not value and not repair:
-            raise error.TestFail('No build provided and this is not a repair '
-                                 ' job.')
-
-        info = host.host_info_store.get()
-        # If the host is already on the correct build, we have nothing to do.
-        if not force and info.build == value:
-            # We can't raise a TestNA, as would make sense, as that makes
-            # job.run_test return False as if the job failed.  However, it'd
-            # still be nice to get this into the status.log, so we manually
-            # emit an INFO line instead.
-            self.job.record('INFO', None, None,
-                            'Host already running %s' % value)
-            return
-
-        board = info.board
-        os = info.os
-        logging.debug('Host %s is board type: %s, OS type: %s', host, board, os)
-        if repair:
-            # TODO(kevcheng): remove the board.split() line when all android
-            # devices have their board label updated to have no android in
-            # there.
-            board = board.split('-')[-1]
-            value = afe_utils.get_stable_android_version(board)
-            if not value:
-                raise error.TestFail('No stable version assigned for board: '
-                                     '%s' % board)
-            logging.debug('Stable version found for board %s: %s', board, value)
-
-        url, _ = host.stage_build_for_install(value, os_type=os)
-        logging.debug('Installing image from: %s', url)
-        args = {'build_url': url, 'os_type': os}
-        try:
-            afe_utils.machine_install_and_update_labels(
-                    host, **args)
-        except error.InstallError as e:
-            logging.error(e)
-            raise error.TestFail, str(e), sys.exc_info()[2]
-        logging.debug('Finished provisioning %s to %s', host, value)
diff --git a/server/site_utils.py b/server/site_utils.py
index 15d7225..71e3150 100644
--- a/server/site_utils.py
+++ b/server/site_utils.py
@@ -191,11 +191,10 @@
              were multiple build labels assigned to this host.
 
     """
-    for prefix in [provision.CROS_VERSION_PREFIX,
-                   provision.ANDROID_BUILD_VERSION_PREFIX]:
-        build = get_label_from_afe(hostname, prefix + ':', afe)
-        if build:
-            return build
+    prefix = provision.CROS_VERSION_PREFIX
+    build = get_label_from_afe(hostname, prefix + ':', afe)
+    if build:
+        return build
     return None