blob: 50bf99acabef2e97d21f8498825b5f8fa6e71b52 [file] [log] [blame]
herbertxuedf01c422018-09-06 19:52:52 +08001#!/usr/bin/env python
2#
3# Copyright 2018 - The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16r"""RemoteImageRemoteInstance class.
17
18Create class that is responsible for creating a remote instance AVD with a
19remote image.
20"""
herbertxuedf01c422018-09-06 19:52:52 +080021from acloud.create import base_avd_create
22from acloud.internal.lib import utils
herbertxueaf7382e2019-06-06 16:20:51 +080023from acloud.public.actions import common_operations
24from acloud.public.actions import remote_instance_cf_device_factory
25from acloud.internal import constants
herbertxuedf01c422018-09-06 19:52:52 +080026
27
28class RemoteImageRemoteInstance(base_avd_create.BaseAVDCreate):
29 """Create class for a remote image remote instance AVD."""
30
cylan31fc5332018-09-17 22:12:08 +080031 @utils.TimeExecute(function_description="Total time: ",
32 print_before_call=False, print_status=False)
herbertxue7ef23b22019-02-27 09:34:24 +080033 def _CreateAVD(self, avd_spec, no_prompts):
herbertxuedf01c422018-09-06 19:52:52 +080034 """Create the AVD.
35
36 Args:
37 avd_spec: AVDSpec object that tells us what we're going to create.
herbertxue7ef23b22019-02-27 09:34:24 +080038 no_prompts: Boolean, True to skip all prompts.
herbertxuedf01c422018-09-06 19:52:52 +080039
40 Returns:
41 A Report instance.
42 """
herbertxueaf7382e2019-06-06 16:20:51 +080043 device_factory = remote_instance_cf_device_factory.RemoteInstanceDeviceFactory(
44 avd_spec)
45 report = common_operations.CreateDevices(
46 "create_cf", avd_spec.cfg, device_factory, avd_spec.num,
47 report_internal_ip=avd_spec.report_internal_ip,
48 autoconnect=avd_spec.autoconnect,
chojoycec60fa582019-07-11 16:09:02 +080049 avd_type=constants.TYPE_CF,
herbertxue660d4192019-08-21 20:14:39 +080050 boot_timeout_secs=avd_spec.boot_timeout_secs,
51 unlock_screen=avd_spec.unlock_screen,
cylan0a4d6452020-03-13 14:19:49 +080052 wait_for_boot=False,
53 connect_webrtc=avd_spec.connect_webrtc)
cylan66713722018-10-06 01:38:26 +080054 # Launch vnc client if we're auto-connecting.
chojoycee86730a2019-12-11 15:37:58 +080055 if avd_spec.connect_vnc:
herbertxue7ef23b22019-02-27 09:34:24 +080056 utils.LaunchVNCFromReport(report, avd_spec, no_prompts)
chojoyce4e2d9222020-01-03 17:04:05 +080057 if avd_spec.connect_webrtc:
58 utils.LaunchBrowserFromReport(report)
Sam Chiu7a477f52018-10-22 11:20:36 +080059
herbertxuedf01c422018-09-06 19:52:52 +080060 return report