autoserv: get transmitted/received byte counts at test beginning/end.

This adds to the autoserv log TX and RX byte counts obtained
from the network card on the DUT.  It is done by adding a new
control segment, GET_NETWORK_STATS, which fails quickly if
the DUT is not immediately reachable.

Example output:
13:28:25 INFO | autoserv| get_network_stats: at-start RXbytes 56436340 TXbytes 109524115
...
13:28:42 INFO | autoserv| get_network_stats: at-end RXbytes 56595766 TXbytes 115204781

(this is from client/site_tests/hardware_DiskSize)

BUG=chromium:621319
TEST=ran with one autotest from client/site_tests

Change-Id: I5b1892ac58d8b6bffdaa2d9293703f1bf05f97be
Reviewed-on: https://chromium-review.googlesource.com/357131
Commit-Ready: Luigi Semenzato <[email protected]>
Tested-by: Luigi Semenzato <[email protected]>
Reviewed-by: Aviv Keshet <[email protected]>
Reviewed-by: Dan Shi <[email protected]>
diff --git a/server/server_job.py b/server/server_job.py
index a5ffe80..7de736a 100644
--- a/server/server_job.py
+++ b/server/server_job.py
@@ -47,6 +47,7 @@
 PROVISION_CONTROL_FILE = _control_segment_path('provision')
 VERIFY_JOB_REPO_URL_CONTROL_FILE = _control_segment_path('verify_job_repo_url')
 RESET_CONTROL_FILE = _control_segment_path('reset')
+GET_NETWORK_STATS_CONTROL_FILE = _control_segment_path('get_network_stats')
 
 # by default provide a stub that generates no site data
 def _get_site_job_data_dummy(job):
@@ -648,6 +649,8 @@
         temp_control_file_dir = None
         try:
             try:
+                namespace['network_stats_label'] = 'at-start'
+                self._execute_code(GET_NETWORK_STATS_CONTROL_FILE, namespace)
                 if install_before and machines:
                     self._execute_code(INSTALL_CONTROL_FILE, namespace)
 
@@ -727,6 +730,8 @@
                 os.remove(self._uncollected_log_file)
             if install_after and machines:
                 self._execute_code(INSTALL_CONTROL_FILE, namespace)
+            namespace['network_stats_label'] = 'at-end'
+            self._execute_code(GET_NETWORK_STATS_CONTROL_FILE, namespace)
 
 
     def run_test(self, url, *args, **dargs):