1# Copyright 2021 - The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14r"""GoldfishRemoteHost class. 15 16Create class that is responsible for creating a goldfish instance with remote 17or local images on a remote host. 18""" 19 20import logging 21 22from acloud.create import base_avd_create 23from acloud.internal import constants 24from acloud.internal.lib import utils 25from acloud.public.actions import common_operations 26from acloud.public.actions import remote_host_gf_device_factory 27 28logger = logging.getLogger(__name__) 29 30 31class GoldfishRemoteHost(base_avd_create.BaseAVDCreate): 32 """Create goldfish on a remote host.""" 33 34 @utils.TimeExecute(function_description="Total time: ", 35 print_before_call=False, print_status=False) 36 def _CreateAVD(self, avd_spec, no_prompts): 37 """Create the AVD. 38 39 Args: 40 avd_spec: AVDSpec object that tells us what we're going to create. 41 no_prompts: Boolean, True to skip all prompts. 42 43 Returns: 44 A Report instance. 45 """ 46 device_factory = remote_host_gf_device_factory.RemoteHostGoldfishDeviceFactory( 47 avd_spec=avd_spec) 48 if avd_spec.num != 1: 49 logger.warning("Multiple goldfish instances on remote host are " 50 "not supported.") 51 if avd_spec.connect_webrtc: 52 logger.warning("Goldfish on remote host does not support WebRTC.") 53 if avd_spec.serial_log_file: 54 logger.warning("Goldfish on remote host does not support serial " 55 "log file.") 56 return common_operations.CreateDevices( 57 "create", avd_spec.cfg, device_factory, avd_spec.num, 58 constants.TYPE_GF, 59 report_internal_ip=avd_spec.report_internal_ip, 60 autoconnect=avd_spec.autoconnect, 61 serial_log_file=avd_spec.serial_log_file, 62 client_adb_port=avd_spec.client_adb_port, 63 boot_timeout_secs=avd_spec.boot_timeout_secs, 64 unlock_screen=avd_spec.unlock_screen, wait_for_boot=False, 65 connect_webrtc=avd_spec.connect_webrtc, 66 ssh_private_key_path=avd_spec.host_ssh_private_key_path, 67 ssh_user=avd_spec.host_user) 68