1#!/usr/bin/python2 -t 2 3""" 4Nice little script to quickly stage a build onto a devserver. 5""" 6 7import argparse 8import sys 9 10import common 11from autotest_lib.client.common_lib.cros import dev_server 12from autotest_lib.server.cros.dynamic_suite import tools 13from autotest_lib.server import frontend 14 15def parse_args(): 16 """Parse command line arguments.""" 17 parser = argparse.ArgumentParser() 18 parser.add_argument('--build', help='e.g. lumpy-release/R26-4321.0.0') 19 parser.add_argument('--server', help='OPTIONAL: e.g. devserver.cros') 20 parser.add_argument('--host', 21 help='OPTIONAL: e.g. chromeos2-row3-rack4-host5') 22 23 args = parser.parse_args() 24 if not args.build: 25 parser.print_help() 26 sys.exit(1) 27 28 return args 29 30def main(): 31 """Stage a build on the devserver.""" 32 options = parse_args() 33 if options.server: 34 server = 'http://%s/' % options.server 35 ds = dev_server.ImageServer(server) 36 else: 37 ds = dev_server.ImageServer.resolve(options.build) 38 39 print "Downloading %s..." % options.build 40 ds.stage_artifacts(options.build, ['full_payload', 'stateful', 41 'control_files', 'autotest_packages']) 42 if options.host: 43 print "Poking job_repo_url on %s..." % options.host 44 repo_url = tools.get_package_url(ds.url(), options.build) 45 AFE = frontend.AFE() 46 AFE.set_host_attribute('job_repo_url', repo_url, hostname=options.host) 47 48if __name__ == '__main__': 49 main() 50