Acloud: acloud create failed to create ssh tunnel but still did adb connect.

Test: atest acloud_test && m acloud &&
      acloud create

Bug: 120114903
Change-Id: I371869234f75990f3d51ece6155e0b32cafa8314
diff --git a/internal/lib/utils.py b/internal/lib/utils.py
index c039b73..d1cea11 100755
--- a/internal/lib/utils.py
+++ b/internal/lib/utils.py
@@ -827,6 +827,8 @@
     except subprocess.CalledProcessError:
         PrintColorString("Failed to create ssh tunnels, retry with '#acloud "
                          "reconnect'.", TextColors.FAIL)
+        return ForwardedPorts(vnc_port=None, adb_port=None)
+
     try:
         adb_connect_args = _ADB_CONNECT_ARGS % {"adb_port": local_free_adb_port}
         _ExecuteCommand(constants.ADB_BIN, adb_connect_args.split())
@@ -887,10 +889,13 @@
         avd_spec: AVDSpec object that tells us what we're going to create.
     """
     for device in report.data.get("devices", []):
-        LaunchVncClient(device.get(constants.VNC_PORT),
-                        avd_width=avd_spec.hw_property["x_res"],
-                        avd_height=avd_spec.hw_property["y_res"])
-
+        if device.get(constants.VNC_PORT):
+            LaunchVncClient(device.get(constants.VNC_PORT),
+                            avd_width=avd_spec.hw_property["x_res"],
+                            avd_height=avd_spec.hw_property["y_res"])
+        else:
+            PrintColorString("No VNC port specified, skipping VNC startup.",
+                             TextColors.FAIL)
 
 def LaunchVncClient(port=constants.DEFAULT_VNC_PORT, avd_width=None,
                     avd_height=None):
diff --git a/internal/lib/utils_test.py b/internal/lib/utils_test.py
index 8c8a460..9a7ffc4 100644
--- a/internal/lib/utils_test.py
+++ b/internal/lib/utils_test.py
@@ -399,6 +399,23 @@
         except errors.FunctionTimeoutError:
             self.fail("shouldn't timeout")
 
+    def testAutoConnectCreateSSHTunnelFail(self):
+        """test auto connect."""
+        fake_ip_addr = "1.1.1.1"
+        fake_rsa_key_file = "/tmp/rsa_file"
+        fake_target_vnc_port = 8888
+        target_adb_port = 9999
+        ssh_user = "fake_user"
+        call_side_effect = subprocess.CalledProcessError(123, "fake",
+                                                         "fake error")
+        result = utils.ForwardedPorts(vnc_port=None, adb_port=None)
+        self.Patch(subprocess, "check_call", side_effect=call_side_effect)
+        self.assertEqual(result, utils.AutoConnect(fake_ip_addr,
+                                                   fake_rsa_key_file,
+                                                   fake_target_vnc_port,
+                                                   target_adb_port,
+                                                   ssh_user))
+
 
 if __name__ == "__main__":
     unittest.main()