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