blob: aaa272ca1dc91a3519b63fa5f48661555d53cd08 [file] [log] [blame]
Kevin Chengee6030f2018-06-26 10:55:30 -07001#!/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"""Setup entry point.
17
18Setup will handle all of the necessary steps to enable acloud to create a local
19or remote instance of an Android Virtual Device.
20"""
21
22from __future__ import print_function
23
Sam Chiu81bdc652018-06-29 18:45:08 +080024from acloud.internal.lib import utils
25from acloud.setup import host_setup_runner
herbertxue34776bb2018-07-03 21:57:48 +080026from acloud.setup import gcp_setup_runner
Kevin Chengee6030f2018-06-26 10:55:30 -070027
Sam Chiu81bdc652018-06-29 18:45:08 +080028
herbertxue34776bb2018-07-03 21:57:48 +080029def Run(args):
Kevin Chengee6030f2018-06-26 10:55:30 -070030 """Run setup.
31
herbertxue34776bb2018-07-03 21:57:48 +080032 Setup options:
33 -host: Setup host settings.
34 -gcp_init: Setup gcp settings.
35 -None, default behavior will setup host and gcp settings.
36
Kevin Chengee6030f2018-06-26 10:55:30 -070037 Args:
38 args: Namespace object from argparse.parse_args.
39 """
Sam Chiu81bdc652018-06-29 18:45:08 +080040 # Setup process will be in the following manner:
41 # 1.Print welcome message.
42 _PrintWelcomeMessage()
43
44 # 2.Init all subtasks in queue and traverse them.
herbertxue34776bb2018-07-03 21:57:48 +080045 host_runner = host_setup_runner.CuttlefishPkgInstaller()
46 host_env_runner = host_setup_runner.CuttlefishHostSetup()
47 gcp_runner = gcp_setup_runner.GcpTaskRunner(args.config_file)
48 task_queue = []
49 if args.host or not args.gcp_init:
50 task_queue.append(host_runner)
51 task_queue.append(host_env_runner)
52 if args.gcp_init or not args.host:
53 task_queue.append(gcp_runner)
Sam Chiu81bdc652018-06-29 18:45:08 +080054
55 for subtask in task_queue:
56 subtask.Run()
57
58 # 3.Print the usage hints.
59 _PrintUsage()
60
61
62def _PrintWelcomeMessage():
63 """Print welcome message when acloud setup been called."""
64
65 # pylint: disable=anomalous-backslash-in-string
66 asc_art = " \n" \
67 " ___ _______ ____ __ _____ \n" \
68 " / _ |/ ___/ / / __ \/ / / / _ \\ \n" \
69 " / __ / /__/ /__/ /_/ / /_/ / // / \n" \
70 "/_/ |_\\___/____/\\____/\\____/____/ \n" \
71 " \n"
72
73 print("\nWelcome to")
74 print(asc_art)
75
76
77def _PrintUsage():
78 """Print cmd usage hints when acloud setup been finished."""
herbertxue34776bb2018-07-03 21:57:48 +080079 utils.PrintColorString("")
80 utils.PrintColorString("Setup process finished")
81 utils.PrintColorString("To get started creating AVDs, run '#acloud create'")