cylan | d43f293 | 2019-11-26 17:37:28 +0800 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # Copyright 2019 - 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. |
| 16 | r"""LocalImageRemoteHost class. |
| 17 | |
| 18 | Create class that is responsible for creating a remote host AVD with a |
| 19 | local image. |
| 20 | """ |
| 21 | |
| 22 | from acloud.create import base_avd_create |
cylan | 487873d | 2019-11-27 19:48:45 +0800 | [diff] [blame] | 23 | from acloud.create import create_common |
| 24 | from acloud.internal import constants |
cylan | d43f293 | 2019-11-26 17:37:28 +0800 | [diff] [blame] | 25 | from acloud.internal.lib import utils |
cylan | 487873d | 2019-11-27 19:48:45 +0800 | [diff] [blame] | 26 | from acloud.public.actions import common_operations |
| 27 | from acloud.public.actions import remote_instance_cf_device_factory |
cylan | d43f293 | 2019-11-26 17:37:28 +0800 | [diff] [blame] | 28 | |
| 29 | |
| 30 | class LocalImageRemoteHost(base_avd_create.BaseAVDCreate): |
| 31 | """Create class for a local image remote host AVD.""" |
| 32 | |
| 33 | @utils.TimeExecute(function_description="Total time: ", |
| 34 | print_before_call=False, print_status=False) |
| 35 | def _CreateAVD(self, avd_spec, no_prompts): |
| 36 | """Create the AVD. |
| 37 | |
| 38 | Args: |
| 39 | avd_spec: AVDSpec object that tells us what we're going to create. |
cylan | 487873d | 2019-11-27 19:48:45 +0800 | [diff] [blame] | 40 | no_prompts: Boolean, True to skip all prompts. |
cylan | d43f293 | 2019-11-26 17:37:28 +0800 | [diff] [blame] | 41 | |
| 42 | Returns: |
| 43 | A Report instance. |
| 44 | """ |
cylan | 487873d | 2019-11-27 19:48:45 +0800 | [diff] [blame] | 45 | device_factory = remote_instance_cf_device_factory.RemoteInstanceDeviceFactory( |
| 46 | avd_spec, |
| 47 | avd_spec.local_image_artifact, |
cylan | cb41752 | 2019-12-30 19:28:36 +0000 | [diff] [blame] | 48 | create_common.GetCvdHostPackage()) |
cylan | 487873d | 2019-11-27 19:48:45 +0800 | [diff] [blame] | 49 | report = common_operations.CreateDevices( |
| 50 | "create_cf", avd_spec.cfg, device_factory, num=1, |
| 51 | report_internal_ip=avd_spec.report_internal_ip, |
| 52 | autoconnect=avd_spec.autoconnect, |
| 53 | avd_type=constants.TYPE_CF, |
| 54 | boot_timeout_secs=avd_spec.boot_timeout_secs, |
| 55 | unlock_screen=avd_spec.unlock_screen, |
| 56 | wait_for_boot=False) |
| 57 | # Launch vnc client if we're auto-connecting. |
chojoyce | e86730a | 2019-12-11 15:37:58 +0800 | [diff] [blame] | 58 | if avd_spec.connect_vnc: |
cylan | 487873d | 2019-11-27 19:48:45 +0800 | [diff] [blame] | 59 | utils.LaunchVNCFromReport(report, avd_spec, no_prompts) |
| 60 | return report |