tast: Try resolving the DUT hostname on Tast failures

When Tast command fails, run "getent ahosts $hostname" to diagnose
possible DNS resolution issues.

Note that this patch uses getent(1) instead of other popular DNS lookup
commands like host(1) or dig(1) so that requests go through NSS.

BUG=b:191721645
BUG=b:189332919
TEST=CQ

Change-Id: Iedf15547615457b3c58b97f7474f064305e6f08e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/autotest/+/2978155
Tested-by: Shuhei Takahashi <nya@chromium.org>
Reviewed-by: Derek Beckett <dbeckett@chromium.org>
Reviewed-by: Otabek Kasimov <otabek@google.com>
Reviewed-by: Seewai Fu <seewaifu@google.com>
Commit-Queue: Shuhei Takahashi <nya@chromium.org>
diff --git a/server/site_tests/tast/tast.py b/server/site_tests/tast/tast.py
index f095039..19a7363 100644
--- a/server/site_tests/tast/tast.py
+++ b/server/site_tests/tast/tast.py
@@ -425,10 +425,18 @@
                     stdout_level=logging.INFO,
                     stderr_level=logging.ERROR)
         except error.CmdError as e:
-            # Run the ssh command to debug possible SSH issues.
+            # Run several commands to debug possible network issues.
             # TODO(b/189332919): Remove this logic once we finish debugging.
-            logging.info('Tast exited abnormally. Running ssh to diagnose '
-                         'possible SSH issues...')
+            logging.info('Tast exited abnormally. Running several commands to '
+                         'diagnose possible network issues...')
+            utils.run('time getent ahosts %s' % self._host.hostname,
+                      timeout=60,
+                      ignore_status=True,
+                      stdout_tee=utils.TEE_TO_LOGS,
+                      stderr_tee=utils.TEE_TO_LOGS,
+                      stderr_is_expected=True,
+                      stdout_level=logging.INFO,
+                      stderr_level=logging.ERROR)
             utils.run(
                     'ssh '
                     # Enable maximum debug logging.