1# Copyright 2019 - 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"""GceRemoteImageRemoteInstance class. 15 16Create class that is responsible for creating a gce remote instance AVD with a 17remote image. 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 import device_driver 26 27 28logger = logging.getLogger(__name__) 29 30 31class GceRemoteImageRemoteInstance(base_avd_create.BaseAVDCreate): 32 """Create class for a gce remote image remote instance AVD.""" 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 report = device_driver.CreateGCETypeAVD( 47 avd_spec.cfg, 48 avd_spec.remote_image[constants.BUILD_TARGET], 49 avd_spec.remote_image[constants.BUILD_ID], 50 num=avd_spec.num, 51 autoconnect=avd_spec.autoconnect, 52 report_internal_ip=avd_spec.report_internal_ip, 53 avd_spec=avd_spec) 54 55 # Launch vnc client if we're auto-connecting. 56 if avd_spec.connect_vnc: 57 utils.LaunchVNCFromReport(report, avd_spec, no_prompts) 58 59 return report 60