Revert "autotest: Send metrics about the various host class' usage."

This reverts commit c2c6d54951e7581b047df233b9f4edfba7ced630.

Reason for revert: Said host classes deleted.

Original change's description:
> autotest: Send metrics about the various host class' usage.
>
> We have a lot of Host classes that we suspect are dead. Start spewing
> some metrics about what classes are actually in use so we can
> confidently start pouring gasoline over them all.
>
> BUG=chromium:834335
> TEST=moblab-generic-vm-pre-cq
>
> Change-Id: I8444906ee7c9cdf99f40da87b2c5658752065611
> Reviewed-on: https://chromium-review.googlesource.com/1022734
> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
> Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
> Reviewed-by: Prathmesh Prabhu <pprabhu@chromium.org>

Bug: chromium:834335
Change-Id: I2ddb6f649e4eab054ec551f501587648e4e4611d
Reviewed-on: https://chromium-review.googlesource.com/1237089
Commit-Ready: Prathmesh Prabhu <pprabhu@chromium.org>
Tested-by: Prathmesh Prabhu <pprabhu@chromium.org>
Reviewed-by: Aviv Keshet <akeshet@chromium.org>
diff --git a/server/cros/chaos_lib/chaos_runner.py b/server/cros/chaos_lib/chaos_runner.py
index f59acfd..6e563a2 100644
--- a/server/cros/chaos_lib/chaos_runner.py
+++ b/server/cros/chaos_lib/chaos_runner.py
@@ -70,7 +70,6 @@
 
         lock_manager = host_lock_manager.HostLockManager()
         webdriver_master = hosts.SSHHost(MASTERNAME, user='chaosvmmaster')
-        hosts.send_creation_metric(webdriver_instance, context='chaos_runner')
         host_prefix = self._host.hostname.split('-')[0]
         with host_lock_manager.HostsLockedBy(lock_manager):
             capture_host = utils.allocate_packet_capturer(
diff --git a/server/cros/network/chaos_clique_utils.py b/server/cros/network/chaos_clique_utils.py
index 735c316..0d9cd09 100644
--- a/server/cros/network/chaos_clique_utils.py
+++ b/server/cros/network/chaos_clique_utils.py
@@ -33,9 +33,7 @@
     @return: An SSHHost object representing a locked packet_capture machine.
     """
     if hostname is not None:
-        host = hosts.SSHHost(hostname)
-        hosts.send_creation_metric(host, context='chaos_clique_utils')
-        return host
+        return hosts.SSHHost(hostname)
 
     afe = frontend.AFE(debug=True,
                        server=site_utils.get_global_afe_hostname())
diff --git a/server/cros/packet_generation/IP_utils.py b/server/cros/packet_generation/IP_utils.py
index 74d7a36..45ff5a2 100644
--- a/server/cros/packet_generation/IP_utils.py
+++ b/server/cros/packet_generation/IP_utils.py
@@ -4,7 +4,7 @@
 
 import os
 
-from autotest_lib.server import hosts
+from autotest_lib.server.hosts import ssh_host
 
 RA_SCRIPT = 'sendra.py'
 SCAPY = 'scapy-2.2.0.tar.gz'
@@ -33,8 +33,7 @@
 
         """
         scapy = os.path.join(self.install_path, SCAPY)
-        ap_sshhost = hosts.SSHHost(hostname=self.host.hostname)
-        hosts.send_creation_metric(ap_sshhost, context='IP_utils')
+        ap_sshhost = ssh_host.SSHHost(hostname=self.host.hostname)
         current_dir = os.path.dirname(os.path.realpath(__file__))
         send_ra_script = os.path.join(current_dir, RA_SCRIPT)
         send_scapy = os.path.join(current_dir, SCAPY)
diff --git a/server/cros/update_engine/omaha_devserver.py b/server/cros/update_engine/omaha_devserver.py
index e0e5c41..0e6c9eb 100644
--- a/server/cros/update_engine/omaha_devserver.py
+++ b/server/cros/update_engine/omaha_devserver.py
@@ -70,8 +70,6 @@
 
         self._devserver_ssh = hosts.SSHHost(self._omaha_host,
                                             user='chromeos-test')
-        hosts.send_creation_metric(self._devserver_ssh,
-                                   context='omaha_devserver')
 
         # Temporary files for various devserver outputs.
         self._devserver_logfile = None
diff --git a/server/hosts/__init__.py b/server/hosts/__init__.py
index 1789e10..7d8b36f 100644
--- a/server/hosts/__init__.py
+++ b/server/hosts/__init__.py
@@ -22,7 +22,3 @@
 # factory function
 from factory import create_host
 from factory import create_target_machine
-
-# Many host creation sites only import the package, so also provide useful
-# methods associated with host creation.
-from base_classes import send_creation_metric
diff --git a/server/hosts/base_classes.py b/server/hosts/base_classes.py
index 8d679f8..79d2dfa 100644
--- a/server/hosts/base_classes.py
+++ b/server/hosts/base_classes.py
@@ -17,13 +17,8 @@
 stutsman@google.com (Ryan Stutsman)
 """
 
-from autotest_lib.client.bin import utils
 from autotest_lib.client.common_lib import hosts
-from autotest_lib.server import utils as server_utils
-try:
-    from chromite.lib import metrics
-except ImportError:
-    metrics = utils.metrics_mock
+from autotest_lib.server import utils
 
 
 class Host(hosts.Host):
@@ -67,7 +62,7 @@
     def _initialize(self, *args, **dargs):
         super(Host, self)._initialize(*args, **dargs)
 
-        self.serverdir = server_utils.get_server_dir()
+        self.serverdir = utils.get_server_dir()
         self.env = {}
 
 
@@ -77,41 +72,3 @@
 
         if self.job:
             self.job.hosts.discard(self)
-
-
-_CREATION_METRIC_WHITELIST = {
-        'AbstractSSHHost',
-        'ADBHost',
-        'CastOSHost',
-        'ChameleonHost',
-        'CrosHost',
-        'EmulatedAdbHost',
-        'GceHost',
-        'JetstreamHost',
-        'MoblabHost',
-        'PlanktonHost',
-        'ServoHost',
-        'SonicHost',
-        'SSHHost',
-        'TestBed',
-        'TestStationHost',
-}
-_CREATION_METRIC = '/chrome/infra/chromeos/autotest/host/class_instantiated'
-
-
-def send_creation_metric(host, context=''):
-    """Send a metric about which host class we ended up creating.
-
-    Creating host classes is black magic. Once a host class has been created
-    through the various channels, use this function to report what got created.
-
-    @param host: An instace of one of the host classes to send a report about.
-    @param context: Optional context for who created the host instance.
-    """
-    bases = {b.__name__ for b in host.__class__.__bases__}
-    bases = bases & _CREATION_METRIC_WHITELIST
-    for base in bases:
-        metrics.Counter(_CREATION_METRIC).increment(fields={
-                'class': base,
-                'context': context,
-        })
diff --git a/server/hosts/chameleon_host.py b/server/hosts/chameleon_host.py
index f1307b3..39b8e44 100644
--- a/server/hosts/chameleon_host.py
+++ b/server/hosts/chameleon_host.py
@@ -12,7 +12,6 @@
 from autotest_lib.client.cros.chameleon import chameleon
 from autotest_lib.server.cros import dnsname_mangler
 from autotest_lib.server.cros.dynamic_suite import frontend_wrappers
-from autotest_lib.server.hosts import base_classes
 from autotest_lib.server.hosts import ssh_host
 
 
@@ -180,9 +179,7 @@
                            'Chameleon %s is not accessible. Please file a bug'
                            ' to test lab', chameleon_hostname)
                    return None
-                host = ChameleonHost(chameleon_host=chameleon_hostname)
-                base_classes.send_creation_metric(host)
-                return host
+                return ChameleonHost(chameleon_host=chameleon_hostname)
         if chameleon_args:
             return ChameleonHost(**chameleon_args)
         else:
@@ -191,12 +188,10 @@
         afe = frontend_wrappers.RetryingAFE(timeout_min=5, delay_sec=10)
         hosts = afe.get_hosts(hostname=dut)
         if hosts and CHAMELEON_HOST_ATTR in hosts[0].attributes:
-            host = ChameleonHost(
+            return ChameleonHost(
                 chameleon_host=hosts[0].attributes[CHAMELEON_HOST_ATTR],
                 chameleon_port=hosts[0].attributes.get(
                     CHAMELEON_PORT_ATTR, 9992)
             )
-            base_classes.send_creation_metric(host)
-            return host
         else:
             return None
diff --git a/server/hosts/factory.py b/server/hosts/factory.py
index 6248238..31a2051 100644
--- a/server/hosts/factory.py
+++ b/server/hosts/factory.py
@@ -3,8 +3,6 @@
 import logging
 from contextlib import closing
 
-import common
-
 from autotest_lib.client.bin import local_host
 from autotest_lib.client.bin import utils
 from autotest_lib.client.common_lib import deprecation
@@ -13,7 +11,6 @@
 from autotest_lib.server import utils as server_utils
 from autotest_lib.server.cros.dynamic_suite import constants
 from autotest_lib.server.hosts import adb_host
-from autotest_lib.server.hosts import base_classes
 from autotest_lib.server.hosts import cros_host
 from autotest_lib.server.hosts import host_info
 from autotest_lib.server.hosts import jetstream_host
@@ -234,7 +231,6 @@
         host_instance.job_start()
         _started_hostnames.add(hostname)
 
-    base_classes.send_creation_metric(host_instance, context='factory')
     return host_instance
 
 
diff --git a/server/hosts/plankton_host.py b/server/hosts/plankton_host.py
index e0f525d..ab7def1 100644
--- a/server/hosts/plankton_host.py
+++ b/server/hosts/plankton_host.py
@@ -8,7 +8,6 @@
 
 """This file provides core logic for servo verify/repair process."""
 
-from autotest_lib.server.hosts import base_classes
 from autotest_lib.server.hosts import servo_host
 
 
@@ -71,6 +70,4 @@
     # TODO Make this work in the lab chromium:564836
     if plankton_args is None:
         return None
-    host = PlanktonHost(Required_by_test=True, is_in_lab=False, **plankton_args)
-    base_classes.send_creation_metric(host)
-    return host
+    return PlanktonHost(Required_by_test=True, is_in_lab=False, **plankton_args)
diff --git a/server/hosts/servo_host.py b/server/hosts/servo_host.py
index 7d55709..4510132 100644
--- a/server/hosts/servo_host.py
+++ b/server/hosts/servo_host.py
@@ -33,7 +33,6 @@
 from autotest_lib.server.cros.dynamic_suite import control_file_getter
 from autotest_lib.server.cros.dynamic_suite import frontend_wrappers
 from autotest_lib.server.cros.servo import servo
-from autotest_lib.server.hosts import base_classes
 from autotest_lib.server.hosts import servo_repair
 from autotest_lib.server.hosts import ssh_host
 from autotest_lib.site_utils.rpm_control_system import rpm_client
@@ -847,8 +846,6 @@
                                servo_args[SERVO_HOST_ATTR])),
             **servo_args
     )
-    base_classes.send_creation_metric(newhost)
-
     # Note that the logic of repair() includes everything done
     # by verify().  It's sufficient to call one or the other;
     # we don't need both.
diff --git a/server/hosts/teststation_host.py b/server/hosts/teststation_host.py
index bc17d83..e2fac55 100644
--- a/server/hosts/teststation_host.py
+++ b/server/hosts/teststation_host.py
@@ -34,9 +34,7 @@
     else:
         classes.append(ssh_host.SSHHost)
     host_class = type('new_teststationhost', tuple(classes), {})
-    host = host_class(hostname, **kwargs)
-    base_classes.send_creation_metric(host)
-    return host
+    return host_class(hostname, **kwargs)
 
 
 class TestStationHost(base_classes.Host):
diff --git a/server/site_tests/factory_InstallServo/factory_InstallServo.py b/server/site_tests/factory_InstallServo/factory_InstallServo.py
index 2cf3f5a..3574d94 100644
--- a/server/site_tests/factory_InstallServo/factory_InstallServo.py
+++ b/server/site_tests/factory_InstallServo/factory_InstallServo.py
@@ -36,7 +36,6 @@
     def _create_servo(self, servo_host, servo_port):
         self.servo = servo.Servo(
                 hosts.ServoHost(servo_host=servo_host, servo_port=servo_port))
-        hosts.send_creation_metric(self.servo, context='factory_InstallServo')
         def kill_servo():
             del self.servo
         self.cleanup_tasks.append(kill_servo)
@@ -58,9 +57,7 @@
         """
         Overridden from superclass.
         """
-        host = hosts.SSHHost(self.dut_ip)
-        hosts.send_creation_metric(host, context='factory_InstallServo')
-        return host
+        return hosts.SSHHost(self.dut_ip)
 
     def run_factory_install(self, shim_image):
         """
diff --git a/server/site_tests/factory_InstallVM/factory_InstallVM.py b/server/site_tests/factory_InstallVM/factory_InstallVM.py
index b25a0bb..d2517fe 100644
--- a/server/site_tests/factory_InstallVM/factory_InstallVM.py
+++ b/server/site_tests/factory_InstallVM/factory_InstallVM.py
@@ -19,7 +19,7 @@
 
 from autotest_lib.client.bin import utils as client_utils
 from autotest_lib.server.cros.factory_install_test import FactoryInstallTest
-from autotest_lib.server import hosts
+from autotest_lib.server.hosts import ssh_host
 
 
 # How long to wait after killing KVMs.
@@ -92,9 +92,7 @@
         """
         Overridden from superclass.
         """
-        host = hosts.SSHHost("localhost", port=self.ssh_tunnel_port)
-        hosts.send_creation_metric(host, context='factory_InstallVM')
-        return host
+        return ssh_host.SSHHost("localhost", port=self.ssh_tunnel_port)
 
     def run_factory_install(self, local_hdb):
         """
diff --git a/site_utils/lib/infra.py b/site_utils/lib/infra.py
index 50bfd90..64d9003 100644
--- a/site_utils/lib/infra.py
+++ b/site_utils/lib/infra.py
@@ -8,7 +8,7 @@
 import os
 
 import common
-from autotest_lib.server import hosts
+from autotest_lib.server.hosts import ssh_host
 from autotest_lib.client.common_lib import error
 from autotest_lib.client.common_lib import global_config
 from autotest_lib.client.common_lib import utils
@@ -76,8 +76,7 @@
     except KeyError:
         username = global_config.global_config.get_config_value(
                 'CROS', 'infrastructure_user')
-        host_object = hosts.SSHHost(host, user=username)
-        hosts.send_creation_metric(host_object, context='site_utils/lib/infra')
+        host_object = ssh_host.SSHHost(host, user=username)
         _host_objects[host] = host_object
 
     def runner(cmd):