1#!/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"""LocalImageRemoteInstance class. 17 18Create class that is responsible for creating a remote instance AVD with a 19local image. 20""" 21from acloud.create import create_common 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_instance_cf_device_factory 27from acloud.public.actions import remote_instance_fvp_device_factory 28from acloud.public.actions import remote_instance_trusty_device_factory 29from acloud.public import report 30 31 32class LocalImageRemoteInstance(base_avd_create.BaseAVDCreate): 33 """Create class for a local image remote instance AVD.""" 34 35 @utils.TimeExecute(function_description="Total time: ", 36 print_before_call=False, print_status=False) 37 def _CreateAVD(self, avd_spec, no_prompts): 38 """Create the AVD. 39 40 Args: 41 avd_spec: AVDSpec object that tells us what we're going to create. 42 no_prompts: Boolean, True to skip all prompts. 43 44 Returns: 45 A Report instance. 46 """ 47 # AVD type default to CF. 48 command = "create_cf" 49 device_factory = remote_instance_cf_device_factory.RemoteInstanceDeviceFactory( 50 avd_spec, 51 avd_spec.local_image_artifact, 52 create_common.GetCvdHostPackage(avd_spec.cvd_host_package)) 53 if avd_spec.avd_type == constants.TYPE_FVP: 54 device_factory = remote_instance_fvp_device_factory.RemoteInstanceDeviceFactory( 55 avd_spec) 56 command = "create_fvp" 57 elif avd_spec.avd_type == constants.TYPE_TRUSTY: 58 device_factory = remote_instance_trusty_device_factory.RemoteInstanceDeviceFactory( 59 avd_spec, avd_spec.local_image_artifact) 60 command = "create_trusty" 61 62 create_report = common_operations.CreateDevices( 63 command, avd_spec.cfg, device_factory, 64 avd_spec.num, 65 report_internal_ip=avd_spec.report_internal_ip, 66 autoconnect=avd_spec.autoconnect, 67 avd_type=avd_spec.avd_type, 68 boot_timeout_secs=avd_spec.boot_timeout_secs, 69 unlock_screen=avd_spec.unlock_screen, 70 wait_for_boot=False, 71 connect_webrtc=avd_spec.connect_webrtc, 72 client_adb_port=avd_spec.client_adb_port) 73 if create_report.status == report.Status.SUCCESS: 74 if avd_spec.connect_vnc: 75 utils.LaunchVNCFromReport(create_report, avd_spec, no_prompts) 76 if avd_spec.connect_webrtc: 77 utils.LaunchBrowserFromReport(create_report) 78 79 return create_report 80