• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/usr/bin/env python
2# Copyright 2015 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6"""Main routine for the `deploy` command line tool.
7
8# Purpose
9This command automates key steps for several use cases relating to DUTs
10in the Autotest Test Lab:
11  * Deploying a DUT+Servo assembly with a DUT that is fresh from the
12    factory.
13  * Redeploying an existing DUT+Servo assembly to a new location.
14  * Manually repairing a DUT+Servo assembly that has failed automated
15    repair.
16
17# Syntax
18
19deploy <subcommand> [options] [HOSTNAME ...]
20
21## Available subcommands:
22  servo:  Validate that the servo is in working order, and then install
23      the repair image for the target DUTs on the servo's USB stick.
24  firmware:  Install dev-signed RO+RW firmware on the target DUTs, and
25      then install the image from the servo USB stick to the target
26      DUTs.
27  test-image:  Install the image from the servo USB stick to the target
28      DUTs.
29  repair:  Install the image from the servo USB stick to the target
30      DUTs.  Differs from the 'test-image' subcommand in that certain
31      default behaviors are different.
32
33For all subcommands, the servo part of the assembly must be fully
34functional for deployment to succeed.
35
36For all subcommands except the `servo` subcommand, installing the
37current repair imge on the servo's USB stick may be skipped to save
38time.  If this step is skipped, the user is responsible for making
39sure the correct image is on the stick prior to running the command.
40
41For the `servo` subcommand, the DUT need not be present or in working
42order.  Other subcommands require the DUT to meet certain requirements,
43outlined below.
44
45For the `firmware` subcommand, the DUT must begin in dev-mode, with
46hardware write-protect disabled.  At successful completion, the DUT is
47in verified boot mode.
48
49For the `test-image` and `repair` subcommands, the DUT must already have
50dev-signed firmware installed, and must be in verified boot mode.
51
52## Available options:
53
54-w / --web SERVER
55    Specify an alternative AFE RPC service.
56
57-d / --dir DIRECTORY
58    Specify a directory where logs from the command will be stored.
59    By default, a new directory will be created under ~/Documents.
60
61-i / --build BUILD
62    Install the given BUILD onto the servo USB stick, and update the AFE
63    to make that build the default repair image for the target DUTS.
64    BUILD is specified in a form like 'R66-10447.0.0'.
65
66-f / --hostname_file FILE
67    Specifies a CSV formatted file with information about the target DUTs.
68    When supplied, this overrides any HOSTNAME arguments on the command
69    line.
70
71-b / --board BOARD
72    Specifies the board to assume for all target DUTs.
73
74-m / --model MODEL
75    Specifies the model to assume for all target DUTs.
76
77--[no]stageusb
78    This option isn't available for the `servo` subcommand.  For other
79    subcommands, when true this option enables the servo validation and
80    installation steps performed by the `servo` subcommand.
81
82## Command line arguments:
83
84HOSTNAME ...
85    If no `-f` option is supplied, the command line must have a list of
86    the hostnames of the target DUTs.
87"""
88
89import sys
90
91import common
92from autotest_lib.site_utils.deployment import cmdparse
93from autotest_lib.site_utils.deployment import install
94
95
96def main(argv):
97    """Standard main routine.
98
99    @param argv  Command line arguments including `sys.argv[0]`.
100    """
101    install.install_duts(cmdparse.parse_command(argv))
102
103
104if __name__ == '__main__':
105    try:
106        main(sys.argv)
107    except KeyboardInterrupt:
108        pass
109    except EnvironmentError as e:
110        sys.stderr.write('Unexpected OS error:\n    %s\n' % e)
111    except Exception as e:
112        sys.stderr.write('Unexpected exception:\n    %s\n' % e)
113