herbertxue | df01c42 | 2018-09-06 19:52:52 +0800 | [diff] [blame] | 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. |
| 16 | r"""RemoteImageRemoteInstance class. |
| 17 | |
| 18 | Create class that is responsible for creating a remote instance AVD with a |
| 19 | remote image. |
| 20 | """ |
herbertxue | df01c42 | 2018-09-06 19:52:52 +0800 | [diff] [blame] | 21 | from acloud.create import base_avd_create |
| 22 | from acloud.internal.lib import utils |
herbertxue | af7382e | 2019-06-06 16:20:51 +0800 | [diff] [blame] | 23 | from acloud.public.actions import common_operations |
| 24 | from acloud.public.actions import remote_instance_cf_device_factory |
| 25 | from acloud.internal import constants |
herbertxue | df01c42 | 2018-09-06 19:52:52 +0800 | [diff] [blame] | 26 | |
| 27 | |
| 28 | class RemoteImageRemoteInstance(base_avd_create.BaseAVDCreate): |
| 29 | """Create class for a remote image remote instance AVD.""" |
| 30 | |
cylan | 31fc533 | 2018-09-17 22:12:08 +0800 | [diff] [blame] | 31 | @utils.TimeExecute(function_description="Total time: ", |
| 32 | print_before_call=False, print_status=False) |
herbertxue | 7ef23b2 | 2019-02-27 09:34:24 +0800 | [diff] [blame] | 33 | def _CreateAVD(self, avd_spec, no_prompts): |
herbertxue | df01c42 | 2018-09-06 19:52:52 +0800 | [diff] [blame] | 34 | """Create the AVD. |
| 35 | |
| 36 | Args: |
| 37 | avd_spec: AVDSpec object that tells us what we're going to create. |
herbertxue | 7ef23b2 | 2019-02-27 09:34:24 +0800 | [diff] [blame] | 38 | no_prompts: Boolean, True to skip all prompts. |
herbertxue | df01c42 | 2018-09-06 19:52:52 +0800 | [diff] [blame] | 39 | |
| 40 | Returns: |
| 41 | A Report instance. |
| 42 | """ |
herbertxue | af7382e | 2019-06-06 16:20:51 +0800 | [diff] [blame] | 43 | 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, |
chojoyce | c60fa58 | 2019-07-11 16:09:02 +0800 | [diff] [blame] | 49 | avd_type=constants.TYPE_CF, |
herbertxue | 660d419 | 2019-08-21 20:14:39 +0800 | [diff] [blame] | 50 | boot_timeout_secs=avd_spec.boot_timeout_secs, |
| 51 | unlock_screen=avd_spec.unlock_screen, |
cylan | 0a4d645 | 2020-03-13 14:19:49 +0800 | [diff] [blame] | 52 | wait_for_boot=False, |
| 53 | connect_webrtc=avd_spec.connect_webrtc) |
cylan | 6671372 | 2018-10-06 01:38:26 +0800 | [diff] [blame] | 54 | # Launch vnc client if we're auto-connecting. |
chojoyce | e86730a | 2019-12-11 15:37:58 +0800 | [diff] [blame] | 55 | if avd_spec.connect_vnc: |
herbertxue | 7ef23b2 | 2019-02-27 09:34:24 +0800 | [diff] [blame] | 56 | utils.LaunchVNCFromReport(report, avd_spec, no_prompts) |
chojoyce | 4e2d922 | 2020-01-03 17:04:05 +0800 | [diff] [blame] | 57 | if avd_spec.connect_webrtc: |
| 58 | utils.LaunchBrowserFromReport(report) |
Sam Chiu | 7a477f5 | 2018-10-22 11:20:36 +0800 | [diff] [blame] | 59 | |
herbertxue | df01c42 | 2018-09-06 19:52:52 +0800 | [diff] [blame] | 60 | return report |