blob: b37819d1e8608133abf467bea9cb9351f95b1836 [file] [log] [blame]
# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import logging
import re
from autotest_lib.client.common_lib import error, global_config
from autotest_lib.server import test
from autotest_lib.server.hosts import moblab_host
DEFAULT_IMAGE_STORAGE_SERVER = global_config.global_config.get_config_value(
'CROS', 'image_storage_server')
class MoblabTest(test.test):
"""Base class for Moblab tests.
def initialize(self, host, boto_path='',
"""Initialize the Moblab Host.
* Installs a boto file.
* Sets up the image storage server for this test.
* Finds and adds DUTs on the testing subnet.
@param boto_path: Path to the boto file we want to install.
@param image_storage_server: image storage server to use for grabbing
images from Google Storage.
super(MoblabTest, self).initialize()
self._host = host
def set_image_storage_server(self, image_storage_server):
"""Set the image storage server.
@param image_storage_server: Name of image storage server to use. Must
follow format or gs://bucket-name/
(Note trailing slash is required).
@raises error.TestError if the image_storage_server is incorrectly
if not re.match(STORAGE_SERVER_REGEX, image_storage_server):
raise error.TestError(
'Image Storage Server supplied is not in the correct '
'format. Must start with gs:// and end with a trailing '
'slash: %s' % image_storage_server)
logging.debug('Setting image_storage_server to %s',
# If the image_storage_server is already set, delete it.'sed -i /image_storage_server/d %s' %
moblab_host.SHADOW_CONFIG_PATH, ignore_status=True)"sed -i '/\[CROS\]/ a\image_storage_server: "
"%s' %s" %(image_storage_server,