1# Copyright (c) 2012 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5import logging 6 7from autotest_lib.server import test 8 9class platform_InstallTestImage(test.test): 10 """Installs a specified test image onto a servo-connected DUT.""" 11 version = 1 12 13 def initialize(self, host, image_url=None, local=False): 14 """ Setup image url to install the image.. 15 16 @param host: Host object representing DUT to be re-imaged. 17 @param image_url: URL of a test image to be installed. 18 @param local: bool indicating it's a local run with an image already 19 on the usb stick of the servo 20 """ 21 self.local = local 22 # A 'None' value here indicates to servo below to use the image 23 # on the stick. 24 self.image_url = None 25 if not self.local: 26 self.image_url = image_url 27 if self.image_url is None: 28 image_name = host.get_cros_repair_image_name() 29 # Succeeded, so stage the build and get its URL. 30 # N.B. Failures from staging the build at this point 31 # are fatal by design. 32 _, self.image_url = host.stage_image_for_servo(image_name) 33 logging.info("Using staged image: %s", image_url) 34 35 36 def run_once(self, host): 37 """Install image from URL |self.image_url| on |host|. 38 39 @param host Host object representing DUT to be re-imaged. 40 """ 41 host.servo_install(image_url=self.image_url) 42