Add test_list option enable_sync_log

Add this option to enable/disable sync system logs to server.
If there are core dump files matching watchlist, they will stay on
machine until they get uploaded or removed.

BUG=chrome-os-partner:20855
TEST=run goofy with options.enable_sync_log disabled
check system_logs folder on server. There should be no logs.
run goofy with options.enable_sync_log enabled (by default)
check system_logs folder on server. There should be logs.

Change-Id: I73a8b59dc9055c71f9cdca251d7b17c991b3914c
Reviewed-on: https://gerrit.chromium.org/gerrit/62331
Reviewed-by: Vic Yang <victoryang@chromium.org>
Commit-Queue: Cheng-Yi Chiang <cychiang@chromium.org>
Tested-by: Cheng-Yi Chiang <cychiang@chromium.org>
diff --git a/py/goofy/goofy.py b/py/goofy/goofy.py
index 995af52..327af1f 100755
--- a/py/goofy/goofy.py
+++ b/py/goofy/goofy.py
@@ -1352,11 +1352,12 @@
     # sync_log_period_secs isn't set (no background
     # syncing), since we may kick it to sync logs in its
     # thread.
-    self.system_log_manager = SystemLogManager(
-      sync_log_paths=self.test_list.options.sync_log_paths,
-      sync_period_sec=self.test_list.options.sync_log_period_secs,
-      clear_log_paths=self.test_list.options.clear_log_paths)
-    self.system_log_manager.StartSyncThread()
+    if self.test_list.options.enable_sync_log:
+      self.system_log_manager = SystemLogManager(
+        sync_log_paths=self.test_list.options.sync_log_paths,
+        sync_period_sec=self.test_list.options.sync_log_period_secs,
+        clear_log_paths=self.test_list.options.clear_log_paths)
+      self.system_log_manager.StartSyncThread()
 
     self.update_system_info()
 
@@ -1681,7 +1682,8 @@
                              charger_connected=ac_present,
                              critical=critical_low_battery)
           self.log_watcher.KickWatchThread()
-          self.system_log_manager.KickSyncThread()
+          if self.system_log_manager:
+            self.system_log_manager.KickSyncThread()
     except: # pylint: disable=W0702
       logging.exception('Unable to check battery or notify shopfloor')
     finally:
@@ -1709,8 +1711,9 @@
       self.log_watcher.KickWatchThread()
 
       # Syncs files to server
-      self.system_log_manager.KickSyncThread(
-          core_dump_files, self.core_dump_manager.ClearFiles)
+      if self.system_log_manager:
+        self.system_log_manager.KickSyncThread(
+            core_dump_files, self.core_dump_manager.ClearFiles)
 
   def sync_time_in_background(self):
     '''Writes out current time and tries to sync with shopfloor server.'''
diff --git a/py/test/factory.py b/py/test/factory.py
index ece2c56..1a2ce89 100644
--- a/py/test/factory.py
+++ b/py/test/factory.py
@@ -433,6 +433,7 @@
   clear_log_paths = ['/var/log/connectivity.bak']
 
   # The time interval to rsync system logs.
+  enable_sync_log = True
   sync_log_period_secs = None
   _types['sync_log_period_secs'] = (type(None), int)
   # The list of log files to rsync periodically.