[autotest] Update autoserv to support server-side packaging.

Code change is made so autoserv will honer the --require-ssp arg. When the
argument is specified, autoserv will:
1. Try to locate server-side package based on --image, host attribute
   job_repo_url and host's cros-version label.
2. If no server-side package can be staged, the job will be run without ssp.
3. If package can be staged, autoserv will start a container to run the test.
   a) parent autoserv process's log will be stored in [results]/wrapper folder.
   b) A container will be created from base container, with proper setup.
   c) The same autoserv command line (with update on result path and control
      etc.), will be executed inside the container.
   d) Parent autoserv process will wait for above command to finish and destroy
      the container afterwards. If the test job was aborted, container should
      also be destroyed.

BUG=chromium:453624
TEST=local setup and run test command:
/usr/local/autotest/server/autoserv -p -r /usr/local/autotest/results/16-debug_\
user/$result_dir  -m 172.27.215.232 -u udebug_user -l dummy_PassServer -s -P \
16-debug_user/$result_dir -n /usr/local/autotest/results/drone_tmp/attach.2  \
--verify_job_repo_url --require-ssp
create job from afe:
http://dshi.mtv.corp.google.com/afe/#tab_id=view_job&object_id=19

Change-Id: Ida36374dd500cd1fd0b67a86ab8c0198ade4cc36
Reviewed-on: https://chromium-review.googlesource.com/259834
Reviewed-by: Dan Shi <dshi@chromium.org>
Commit-Queue: Dan Shi <dshi@chromium.org>
Trybot-Ready: Dan Shi <dshi@chromium.org>
Tested-by: Dan Shi <dshi@chromium.org>
diff --git a/server/cros/dynamic_suite/tools.py b/server/cros/dynamic_suite/tools.py
index 608d069..a09be3b 100644
--- a/server/cros/dynamic_suite/tools.py
+++ b/server/cros/dynamic_suite/tools.py
@@ -81,6 +81,23 @@
             devserver_build_tuple[1].replace('archive/', ''))
 
 
+def get_build_from_image(image):
+    """Get the build name from the image string.
+
+    @param image: A string of image, can be the build name or a url to the
+                  build, e.g.,
+                  http://devserver/update/alex-release/R27-3837.0.0
+
+    @return: Name of the build. Return None if fail to parse build name.
+    """
+    if not image.startswith('http://'):
+        return image
+    else:
+        match = re.match('.*/([^/]+/R\d+-[^/]+)', image)
+        if match:
+            return match.group(1)
+
+
 def get_random_best_host(afe, host_list, require_usable_hosts=True):
     """
     Randomly choose the 'best' host from host_list, using fresh status.