Autotest: Add logging to copy to results repo logic

We have been only using 1 drone because of the email spam sent out
regarding copying to results repo. We want to try enabling multiple
drones so that the lab will not go down in the case one drone dies.

Copy_to_results_repository is now gated by the enale_archiving flag,
meaning it should not happen.

Added logging to SSHHost's get/send file methods that drone_utility
uses to send files to the results repo. Also added logging to the
drone_utility's send/get functions as well.

BUG=chromium:231452
TEST=Local setup with multiple drones. Ensure tests still run.

Change-Id: I62a0196880d4b25ff8abb47825e280d193a4b9b7
Reviewed-on: https://chromium-review.googlesource.com/175005
Reviewed-by: Simran Basi <sbasi@chromium.org>
Commit-Queue: Simran Basi <sbasi@chromium.org>
Tested-by: Simran Basi <sbasi@chromium.org>
diff --git a/scheduler/drone_manager.py b/scheduler/drone_manager.py
index 520dff7..8493a29 100644
--- a/scheduler/drone_manager.py
+++ b/scheduler/drone_manager.py
@@ -679,6 +679,10 @@
 
     def _copy_results_helper(self, process, source_path, destination_path,
                              to_results_repository=False):
+        logging.debug('_copy_results_helper. process: %s, source_path: %s, '
+                      'destination_path: %s, to_results_repository: %s',
+                      process, source_path, destination_path,
+                      to_results_repository)
         full_source = self.absolute_path(source_path)
         full_destination = self.absolute_path(
                 destination_path, on_results_repository=to_results_repository)
diff --git a/scheduler/drone_manager_unittest.py b/scheduler/drone_manager_unittest.py
index 6d9949d..d2ee2a2 100755
--- a/scheduler/drone_manager_unittest.py
+++ b/scheduler/drone_manager_unittest.py
@@ -5,7 +5,7 @@
 from autotest_lib.client.common_lib import global_config
 from autotest_lib.client.common_lib.test_utils import mock
 from autotest_lib.scheduler import drone_manager, drone_utility, drones
-from autotest_lib.scheduler import scheduler_config
+from autotest_lib.scheduler import scheduler_config, site_drone_manager
 
 class MockDrone(drones._AbstractDrone):
     def __init__(self, name, active_processes=0, max_processes=10,
@@ -293,6 +293,7 @@
 
 
     def test_copy_to_results_repository(self):
+        site_drone_manager.ENABLE_ARCHIVING = True
         self.manager.copy_to_results_repository(self.mock_drone_process,
                                                 self._SOURCE_PATH)
         self.assert_(self.mock_drone.was_file_sent(
diff --git a/scheduler/drone_utility.py b/scheduler/drone_utility.py
index 2531bfa..53f5338 100755
--- a/scheduler/drone_utility.py
+++ b/scheduler/drone_utility.py
@@ -338,6 +338,9 @@
 
 
     def _sync_get_file_from(self, hostname, source_path, destination_path):
+        logging.debug('_sync_get_file_from hostname: %s, source_path: %s,'
+                      'destination_path: %s', hostname, source_path,
+                      destination_path)
         self._ensure_directory_exists(os.path.dirname(destination_path))
         host = create_host(hostname)
         host.get_file(source_path, destination_path, delete_dest=True)
@@ -350,6 +353,9 @@
 
     def sync_send_file_to(self, hostname, source_path, destination_path,
                            can_fail):
+        logging.debug('sync_send_file_to. hostname: %s, source_path: %s, '
+                      'destination_path: %s, can_fail:%s', hostname,
+                      source_path, destination_path, can_fail)
         host = create_host(hostname)
         try:
             host.run('mkdir -p ' + os.path.dirname(destination_path))
diff --git a/scheduler/site_drone_manager.py b/scheduler/site_drone_manager.py
index 9f54854..c41d8d7 100644
--- a/scheduler/site_drone_manager.py
+++ b/scheduler/site_drone_manager.py
@@ -9,6 +9,8 @@
 
 HOSTS_JOB_SUBDIR = 'hosts/'
 PARSE_LOG = '.parse.log'
+ENABLE_ARCHIVING =  global_config.global_config.get_config_value(
+        scheduler_config.CONFIG_SECTION, 'enable_archiving', type=bool)
 
 
 class SiteDroneManager(object):
@@ -31,6 +33,8 @@
         It will also only copy .parse.log files back to the scheduler if the
         copy_parse_log_back flag in global_config.ini has been set to True.
         """
+        if not ENABLE_ARCHIVING:
+            return
         copy_task_results_back = global_config.global_config.get_config_value(
                 scheduler_config.CONFIG_SECTION, 'copy_task_results_back',
                 type=bool)