Home | History | Annotate | Download | only in deployment
      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
      9 This command automates key steps for several use cases relating to DUTs
     10 in 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 
     19 deploy <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 
     33 For all subcommands, the servo part of the assembly must be fully
     34 functional for deployment to succeed.
     35 
     36 For all subcommands except the `servo` subcommand, installing the
     37 current repair imge on the servo's USB stick may be skipped to save
     38 time.  If this step is skipped, the user is responsible for making
     39 sure the correct image is on the stick prior to running the command.
     40 
     41 For the `servo` subcommand, the DUT need not be present or in working
     42 order.  Other subcommands require the DUT to meet certain requirements,
     43 outlined below.
     44 
     45 For the `firmware` subcommand, the DUT must begin in dev-mode, with
     46 hardware write-protect disabled.  At successful completion, the DUT is
     47 in verified boot mode.
     48 
     49 For the `test-image` and `repair` subcommands, the DUT must already have
     50 dev-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 
     84 HOSTNAME ...
     85     If no `-f` option is supplied, the command line must have a list of
     86     the hostnames of the target DUTs.
     87 """
     88 
     89 import sys
     90 
     91 import common
     92 from autotest_lib.site_utils.deployment import cmdparse
     93 from autotest_lib.site_utils.deployment import install
     94 
     95 
     96 def 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 
    104 if __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