ovl: Add prefix match for ./ovl select

Since the machine id is now a MD5 hash, and the web interface only shows
the first 24 characters, allow ./ovl select to select based on prefix
match if there's no exact match.

BUG=b:62647237
TEST=make test
TEST=manually

Change-Id: I4d009987ec3b967ce7f0b40351461d02f9ea63a6
Reviewed-on: https://chromium-review.googlesource.com/538459
Commit-Ready: Pi-Hsun Shih <pihsun@chromium.org>
Tested-by: Pi-Hsun Shih <pihsun@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
diff --git a/py/tools/ovl.py b/py/tools/ovl.py
index 44c5567..5d44aa0 100755
--- a/py/tools/ovl.py
+++ b/py/tools/ovl.py
@@ -1080,7 +1080,13 @@
         raise RuntimeError('select: selection out of range')
     else:
       if mid not in clients:
-        raise RuntimeError('select: client %s does not exist' % mid)
+        # Find a prefix match if no exact match found.
+        matched_mid = [x for x in clients if x.startswith(mid)]
+        if not matched_mid:
+          raise RuntimeError('select: client %s does not exist' % mid)
+        if len(matched_mid) > 1:
+          raise RuntimeError('select: multiple client matched %r' % mid)
+        mid = matched_mid[0]
 
     self._selected_mid = mid
     if store: