[autotest] Set container's hostname to the dut hostname

Update the hostname of the test container to be `dut_name`. Some TradeFed tests
use hostname in test results, which is used to group test results in dashboard.
The default container name is set to be the name of the folder, which is unique
(as it is composed of job id and timestamp. For better result view, the
container's hostname is set to be the dut hostname.

BUG=chromium:637467
TEST=local verify

Change-Id: I1481d88a890020af634a499fb6d469574f9e4504
Reviewed-on: https://chromium-review.googlesource.com/376221
Commit-Ready: Dan Shi <dshi@google.com>
Tested-by: Dan Shi <dshi@chromium.org>
Reviewed-by: Simran Basi <sbasi@chromium.org>
diff --git a/server/autoserv b/server/autoserv
index d5e6ce3..46728e1 100755
--- a/server/autoserv
+++ b/server/autoserv
@@ -155,7 +155,7 @@
 
 
 def _run_with_ssp(job, container_name, job_id, results, parser, ssp_url,
-                  job_folder):
+                  job_folder, machines):
     """Run the server job with server-side packaging.
 
     @param job: The server job object.
@@ -169,14 +169,17 @@
     @param parser: Command line parser that contains the options.
     @param ssp_url: url of the staged server-side package.
     @param job_folder: Name of the job result folder.
+    @param machines: A list of machines to run the test.
     """
     bucket = lxc.ContainerBucket()
     control = (parser.args[0] if len(parser.args) > 0 and parser.args[0] != ''
                else None)
     try:
+        dut_name = machines[0] if len(machines) >= 1 else None
         test_container = bucket.setup_test(container_name, job_id, ssp_url,
                                            results, control=control,
-                                           job_folder=job_folder)
+                                           job_folder=job_folder,
+                                           dut_name=dut_name)
     except Exception as e:
         job.record('FAIL', None, None,
                    'Failed to setup container for test: %s. Check logs in '
@@ -540,7 +543,8 @@
                 if use_ssp:
                     try:
                         _run_with_ssp(job, container_name, job_or_task_id,
-                                      results, parser, ssp_url, job_folder)
+                                      results, parser, ssp_url, job_folder,
+                                      machines)
                     finally:
                         # Update the ownership of files in result folder.
                         correct_results_folder_permission(results)