blob: 6558bfbb5d68b84841daa0b82db6ba2f33bc728e [file] [log] [blame]
joychen3cb228e2013-06-12 12:13:13 -07001# Copyright (c) 2013 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
Chris Sosa0eecf962014-02-03 14:14:39 -08005"""Main module for parsing and interpreting XBuddy paths for the devserver."""
6
Yiming Chenaab488e2014-11-17 14:49:31 -08007import cherrypy
joychen562699a2013-08-13 15:22:14 -07008import ConfigParser
joychen3cb228e2013-06-12 12:13:13 -07009import datetime
10import operator
11import os
joychenf8f07e22013-07-12 17:45:51 -070012import re
joychen3cb228e2013-06-12 12:13:13 -070013import shutil
joychenf8f07e22013-07-12 17:45:51 -070014import time
joychen3cb228e2013-06-12 12:13:13 -070015import threading
16
joychen921e1fb2013-06-28 11:12:20 -070017import build_util
joychen3cb228e2013-06-12 12:13:13 -070018import artifact_info
joychen3cb228e2013-06-12 12:13:13 -070019import common_util
20import devserver_constants
21import downloader
joychenf8f07e22013-07-12 17:45:51 -070022import gsutil_util
joychen3cb228e2013-06-12 12:13:13 -070023import log_util
24
25# Module-local log function.
26def _Log(message, *args):
27 return log_util.LogWithTag('XBUDDY', message, *args)
28
joychen562699a2013-08-13 15:22:14 -070029# xBuddy config constants
30CONFIG_FILE = 'xbuddy_config.ini'
31SHADOW_CONFIG_FILE = 'shadow_xbuddy_config.ini'
32PATH_REWRITES = 'PATH_REWRITES'
33GENERAL = 'GENERAL'
joychen921e1fb2013-06-28 11:12:20 -070034
Chris Sosac2abc722013-08-26 17:11:22 -070035# Path for shadow config in chroot.
36CHROOT_SHADOW_DIR = '/mnt/host/source/src/platform/dev'
37
joychen25d25972013-07-30 14:54:16 -070038# XBuddy aliases
39TEST = 'test'
40BASE = 'base'
41DEV = 'dev'
42FULL = 'full_payload'
43RECOVERY = 'recovery'
44STATEFUL = 'stateful'
45AUTOTEST = 'autotest'
46
joychen921e1fb2013-06-28 11:12:20 -070047# Local build constants
joychenc3944cb2013-08-19 10:42:07 -070048ANY = "ANY"
joychen7df67f72013-07-18 14:21:12 -070049LATEST = "latest"
50LOCAL = "local"
51REMOTE = "remote"
Chris Sosa75490802013-09-30 17:21:45 -070052
53# TODO(sosa): Fix a lot of assumptions about these aliases. There is too much
54# implicit logic here that's unnecessary. What should be done:
55# 1) Collapse Alias logic to one set of aliases for xbuddy (not local/remote).
56# 2) Do not use zip when creating these dicts. Better to not rely on ordering.
57# 3) Move alias/artifact mapping to a central module rather than having it here.
58# 4) Be explicit when things are missing i.e. no dev images in image.zip.
59
joychen921e1fb2013-06-28 11:12:20 -070060LOCAL_ALIASES = [
joychen25d25972013-07-30 14:54:16 -070061 TEST,
joychen25d25972013-07-30 14:54:16 -070062 DEV,
Chris Sosa75490802013-09-30 17:21:45 -070063 BASE,
Gabe Black0d3286e2014-07-30 15:30:03 -070064 RECOVERY,
joychenc3944cb2013-08-19 10:42:07 -070065 FULL,
Chris Sosa7cd23202013-10-15 17:22:57 -070066 STATEFUL,
joychenc3944cb2013-08-19 10:42:07 -070067 ANY,
joychen921e1fb2013-06-28 11:12:20 -070068]
69
70LOCAL_FILE_NAMES = [
71 devserver_constants.TEST_IMAGE_FILE,
joychen921e1fb2013-06-28 11:12:20 -070072 devserver_constants.IMAGE_FILE,
Chris Sosa75490802013-09-30 17:21:45 -070073 devserver_constants.BASE_IMAGE_FILE,
Gabe Black0d3286e2014-07-30 15:30:03 -070074 devserver_constants.RECOVERY_IMAGE_FILE,
joychen7c2054a2013-07-25 11:14:07 -070075 devserver_constants.UPDATE_FILE,
Chris Sosa7cd23202013-10-15 17:22:57 -070076 devserver_constants.STATEFUL_FILE,
Chris Sosa75490802013-09-30 17:21:45 -070077 None, # For ANY.
joychen921e1fb2013-06-28 11:12:20 -070078]
79
80LOCAL_ALIAS_TO_FILENAME = dict(zip(LOCAL_ALIASES, LOCAL_FILE_NAMES))
81
82# Google Storage constants
83GS_ALIASES = [
joychen25d25972013-07-30 14:54:16 -070084 TEST,
85 BASE,
86 RECOVERY,
87 FULL,
88 STATEFUL,
89 AUTOTEST,
joychen3cb228e2013-06-12 12:13:13 -070090]
91
joychen921e1fb2013-06-28 11:12:20 -070092GS_FILE_NAMES = [
93 devserver_constants.TEST_IMAGE_FILE,
94 devserver_constants.BASE_IMAGE_FILE,
95 devserver_constants.RECOVERY_IMAGE_FILE,
joychen7c2054a2013-07-25 11:14:07 -070096 devserver_constants.UPDATE_FILE,
joychen121fc9b2013-08-02 14:30:30 -070097 devserver_constants.STATEFUL_FILE,
joychen3cb228e2013-06-12 12:13:13 -070098 devserver_constants.AUTOTEST_DIR,
99]
100
101ARTIFACTS = [
102 artifact_info.TEST_IMAGE,
103 artifact_info.BASE_IMAGE,
104 artifact_info.RECOVERY_IMAGE,
105 artifact_info.FULL_PAYLOAD,
106 artifact_info.STATEFUL_PAYLOAD,
107 artifact_info.AUTOTEST,
108]
109
joychen921e1fb2013-06-28 11:12:20 -0700110GS_ALIAS_TO_FILENAME = dict(zip(GS_ALIASES, GS_FILE_NAMES))
111GS_ALIAS_TO_ARTIFACT = dict(zip(GS_ALIASES, ARTIFACTS))
joychen3cb228e2013-06-12 12:13:13 -0700112
joychen921e1fb2013-06-28 11:12:20 -0700113LATEST_OFFICIAL = "latest-official"
joychen3cb228e2013-06-12 12:13:13 -0700114
Chris Sosaea734d92013-10-11 11:28:58 -0700115RELEASE = "-release"
joychen3cb228e2013-06-12 12:13:13 -0700116
joychen3cb228e2013-06-12 12:13:13 -0700117
118class XBuddyException(Exception):
119 """Exception classes used by this module."""
120 pass
121
122
123# no __init__ method
124#pylint: disable=W0232
125class Timestamp():
126 """Class to translate build path strings and timestamp filenames."""
127
128 _TIMESTAMP_DELIMITER = 'SLASH'
129 XBUDDY_TIMESTAMP_DIR = 'xbuddy_UpdateTimestamps'
130
131 @staticmethod
132 def TimestampToBuild(timestamp_filename):
133 return timestamp_filename.replace(Timestamp._TIMESTAMP_DELIMITER, '/')
134
135 @staticmethod
136 def BuildToTimestamp(build_path):
137 return build_path.replace('/', Timestamp._TIMESTAMP_DELIMITER)
joychen921e1fb2013-06-28 11:12:20 -0700138
139 @staticmethod
140 def UpdateTimestamp(timestamp_dir, build_id):
141 """Update timestamp file of build with build_id."""
142 common_util.MkDirP(timestamp_dir)
joychen562699a2013-08-13 15:22:14 -0700143 _Log("Updating timestamp for %s", build_id)
joychen921e1fb2013-06-28 11:12:20 -0700144 time_file = os.path.join(timestamp_dir,
145 Timestamp.BuildToTimestamp(build_id))
146 with file(time_file, 'a'):
147 os.utime(time_file, None)
joychen3cb228e2013-06-12 12:13:13 -0700148#pylint: enable=W0232
149
150
joychen921e1fb2013-06-28 11:12:20 -0700151class XBuddy(build_util.BuildObject):
joychen3cb228e2013-06-12 12:13:13 -0700152 """Class that manages image retrieval and caching by the devserver.
153
154 Image retrieval by xBuddy path:
155 XBuddy accesses images and artifacts that it stores using an xBuddy
156 path of the form: board/version/alias
157 The primary xbuddy.Get call retrieves the correct artifact or url to where
158 the artifacts can be found.
159
160 Image caching:
161 Images and other artifacts are stored identically to how they would have
162 been if devserver's stage rpc was called and the xBuddy cache replaces
163 build versions on a LRU basis. Timestamps are maintained by last accessed
164 times of representative files in the a directory in the static serve
165 directory (XBUDDY_TIMESTAMP_DIR).
166
167 Private class members:
joychen121fc9b2013-08-02 14:30:30 -0700168 _true_values: used for interpreting boolean values
169 _staging_thread_count: track download requests
170 _timestamp_folder: directory with empty files standing in as timestamps
joychen921e1fb2013-06-28 11:12:20 -0700171 for each image currently cached by xBuddy
joychen3cb228e2013-06-12 12:13:13 -0700172 """
173 _true_values = ['true', 't', 'yes', 'y']
174
175 # Number of threads that are staging images.
176 _staging_thread_count = 0
177 # Lock used to lock increasing/decreasing count.
178 _staging_thread_count_lock = threading.Lock()
179
Chris Sosa7cd23202013-10-15 17:22:57 -0700180 def __init__(self, manage_builds=False, board=None, images_dir=None,
Yiming Chenaab488e2014-11-17 14:49:31 -0800181 log_screen=True, **kwargs):
joychen921e1fb2013-06-28 11:12:20 -0700182 super(XBuddy, self).__init__(**kwargs)
joychenb0dfe552013-07-30 10:02:06 -0700183
Yiming Chenaab488e2014-11-17 14:49:31 -0800184 if not log_screen:
185 cherrypy.config.update({'log.screen': False})
186
joychen562699a2013-08-13 15:22:14 -0700187 self.config = self._ReadConfig()
188 self._manage_builds = manage_builds or self._ManageBuilds()
Chris Sosa75490802013-09-30 17:21:45 -0700189 self._board = board
joychen921e1fb2013-06-28 11:12:20 -0700190 self._timestamp_folder = os.path.join(self.static_dir,
joychen3cb228e2013-06-12 12:13:13 -0700191 Timestamp.XBUDDY_TIMESTAMP_DIR)
Chris Sosa7cd23202013-10-15 17:22:57 -0700192 if images_dir:
193 self.images_dir = images_dir
194 else:
195 self.images_dir = os.path.join(self.GetSourceRoot(), 'src/build/images')
196
joychen7df67f72013-07-18 14:21:12 -0700197 common_util.MkDirP(self._timestamp_folder)
joychen3cb228e2013-06-12 12:13:13 -0700198
199 @classmethod
200 def ParseBoolean(cls, boolean_string):
201 """Evaluate a string to a boolean value"""
202 if boolean_string:
203 return boolean_string.lower() in cls._true_values
204 else:
205 return False
206
joychen562699a2013-08-13 15:22:14 -0700207 def _ReadConfig(self):
208 """Read xbuddy config from ini files.
209
210 Reads the base config from xbuddy_config.ini, and then merges in the
211 shadow config from shadow_xbuddy_config.ini
212
213 Returns:
214 The merged configuration.
Yu-Ju Hongc54658c2014-01-22 09:18:07 -0800215
joychen562699a2013-08-13 15:22:14 -0700216 Raises:
217 XBuddyException if the config file is missing.
218 """
219 xbuddy_config = ConfigParser.ConfigParser()
220 config_file = os.path.join(self.devserver_dir, CONFIG_FILE)
221 if os.path.exists(config_file):
222 xbuddy_config.read(config_file)
223 else:
Yiming Chend9202142014-11-07 14:56:52 -0800224 # Get the directory of xbuddy.py file.
225 file_dir = os.path.dirname(os.path.realpath(__file__))
226 # Read the default xbuddy_config.ini from the directory.
227 xbuddy_config.read(os.path.join(file_dir, CONFIG_FILE))
joychen562699a2013-08-13 15:22:14 -0700228
229 # Read the shadow file if there is one.
Chris Sosac2abc722013-08-26 17:11:22 -0700230 if os.path.isdir(CHROOT_SHADOW_DIR):
231 shadow_config_file = os.path.join(CHROOT_SHADOW_DIR, SHADOW_CONFIG_FILE)
232 else:
233 shadow_config_file = os.path.join(self.devserver_dir, SHADOW_CONFIG_FILE)
234
235 _Log('Using shadow config file stored at %s', shadow_config_file)
joychen562699a2013-08-13 15:22:14 -0700236 if os.path.exists(shadow_config_file):
237 shadow_xbuddy_config = ConfigParser.ConfigParser()
238 shadow_xbuddy_config.read(shadow_config_file)
239
240 # Merge shadow config in.
241 sections = shadow_xbuddy_config.sections()
242 for s in sections:
243 if not xbuddy_config.has_section(s):
244 xbuddy_config.add_section(s)
245 options = shadow_xbuddy_config.options(s)
246 for o in options:
247 val = shadow_xbuddy_config.get(s, o)
248 xbuddy_config.set(s, o, val)
249
250 return xbuddy_config
251
252 def _ManageBuilds(self):
253 """Checks if xBuddy is managing local builds using the current config."""
254 try:
255 return self.ParseBoolean(self.config.get(GENERAL, 'manage_builds'))
256 except ConfigParser.Error:
257 return False
258
259 def _Capacity(self):
260 """Gets the xbuddy capacity from the current config."""
261 try:
262 return int(self.config.get(GENERAL, 'capacity'))
263 except ConfigParser.Error:
264 return 5
265
266 def _LookupAlias(self, alias, board):
267 """Given the full xbuddy config, look up an alias for path rewrite.
268
269 Args:
270 alias: The xbuddy path that could be one of the aliases in the
271 rewrite table.
272 board: The board to fill in with when paths are rewritten. Can be from
273 the update request xml or the default board from devserver.
Yu-Ju Hongc54658c2014-01-22 09:18:07 -0800274
joychen562699a2013-08-13 15:22:14 -0700275 Returns:
276 If a rewrite is found, a string with the current board substituted in.
277 If no rewrite is found, just return the original string.
278 """
joychen562699a2013-08-13 15:22:14 -0700279 try:
280 val = self.config.get(PATH_REWRITES, alias)
281 except ConfigParser.Error:
282 # No alias lookup found. Return original path.
283 return alias
284
285 if not val.strip():
286 # The found value was an empty string.
287 return alias
288 else:
289 # Fill in the board.
joychenc3944cb2013-08-19 10:42:07 -0700290 rewrite = val.replace("BOARD", "%(board)s") % {
joychen562699a2013-08-13 15:22:14 -0700291 'board': board}
292 _Log("Path was rewritten to %s", rewrite)
293 return rewrite
294
Simran Basi99e63c02014-05-20 10:39:52 -0700295 @staticmethod
296 def _ResolveImageDir(image_dir):
297 """Clean up and return the image dir to use.
298
299 Args:
300 image_dir: directory in Google Storage to use.
301
302 Returns:
303 |image_dir| if |image_dir| is not None. Otherwise, returns
304 devserver_constants.GS_IMAGE_DIR
305 """
306 image_dir = image_dir or devserver_constants.GS_IMAGE_DIR
307 # Remove trailing slashes.
308 return image_dir.rstrip('/')
309
310 def _LookupOfficial(self, board, suffix=RELEASE, image_dir=None):
joychenf8f07e22013-07-12 17:45:51 -0700311 """Check LATEST-master for the version number of interest."""
312 _Log("Checking gs for latest %s-%s image", board, suffix)
Simran Basi99e63c02014-05-20 10:39:52 -0700313 image_dir = XBuddy._ResolveImageDir(image_dir)
314 latest_addr = (devserver_constants.GS_LATEST_MASTER %
315 {'image_dir': image_dir,
316 'board': board,
317 'suffix': suffix})
joychenf8f07e22013-07-12 17:45:51 -0700318 cmd = 'gsutil cat %s' % latest_addr
319 msg = 'Failed to find build at %s' % latest_addr
joychen121fc9b2013-08-02 14:30:30 -0700320 # Full release + version is in the LATEST file.
joychenf8f07e22013-07-12 17:45:51 -0700321 version = gsutil_util.GSUtilRun(cmd, msg)
joychen3cb228e2013-06-12 12:13:13 -0700322
joychenf8f07e22013-07-12 17:45:51 -0700323 return devserver_constants.IMAGE_DIR % {'board':board,
324 'suffix':suffix,
325 'version':version}
Simran Basi99e63c02014-05-20 10:39:52 -0700326 def _LookupChannel(self, board, channel='stable', image_dir=None):
joychenf8f07e22013-07-12 17:45:51 -0700327 """Check the channel folder for the version number of interest."""
joychen121fc9b2013-08-02 14:30:30 -0700328 # Get all names in channel dir. Get 10 highest directories by version.
joychen7df67f72013-07-18 14:21:12 -0700329 _Log("Checking channel '%s' for latest '%s' image", channel, board)
Yu-Ju Hongc54658c2014-01-22 09:18:07 -0800330 # Due to historical reasons, gs://chromeos-releases uses
331 # daisy-spring as opposed to the board name daisy_spring. Convert
332 # the board name for the lookup.
333 channel_dir = devserver_constants.GS_CHANNEL_DIR % {
334 'channel':channel,
335 'board':re.sub('_', '-', board)}
joychen562699a2013-08-13 15:22:14 -0700336 latest_version = gsutil_util.GetLatestVersionFromGSDir(
337 channel_dir, with_release=False)
joychenf8f07e22013-07-12 17:45:51 -0700338
joychen121fc9b2013-08-02 14:30:30 -0700339 # Figure out release number from the version number.
joychenc3944cb2013-08-19 10:42:07 -0700340 image_url = devserver_constants.IMAGE_DIR % {
341 'board':board,
342 'suffix':RELEASE,
343 'version':'R*' + latest_version}
Simran Basi99e63c02014-05-20 10:39:52 -0700344 image_dir = XBuddy._ResolveImageDir(image_dir)
345 gs_url = os.path.join(image_dir, image_url)
joychenf8f07e22013-07-12 17:45:51 -0700346
347 # There should only be one match on cros-image-archive.
Simran Basi99e63c02014-05-20 10:39:52 -0700348 full_version = gsutil_util.GetLatestVersionFromGSDir(gs_url)
joychenf8f07e22013-07-12 17:45:51 -0700349
350 return devserver_constants.IMAGE_DIR % {'board':board,
351 'suffix':RELEASE,
352 'version':full_version}
353
354 def _LookupVersion(self, board, version):
355 """Search GS image releases for the highest match to a version prefix."""
joychen121fc9b2013-08-02 14:30:30 -0700356 # Build the pattern for GS to match.
joychen7df67f72013-07-18 14:21:12 -0700357 _Log("Checking gs for latest '%s' image with prefix '%s'", board, version)
joychenf8f07e22013-07-12 17:45:51 -0700358 image_url = devserver_constants.IMAGE_DIR % {'board':board,
359 'suffix':RELEASE,
360 'version':version + '*'}
361 image_dir = os.path.join(devserver_constants.GS_IMAGE_DIR, image_url)
362
joychen121fc9b2013-08-02 14:30:30 -0700363 # Grab the newest version of the ones matched.
joychenf8f07e22013-07-12 17:45:51 -0700364 full_version = gsutil_util.GetLatestVersionFromGSDir(image_dir)
365 return devserver_constants.IMAGE_DIR % {'board':board,
366 'suffix':RELEASE,
367 'version':full_version}
368
Chris Sosaea734d92013-10-11 11:28:58 -0700369 def _RemoteBuildId(self, board, version):
370 """Returns the remote build_id for the given board and version.
371
372 Raises:
373 XBuddyException: If we failed to resolve the version to a valid build_id.
374 """
375 build_id_as_is = devserver_constants.IMAGE_DIR % {'board':board,
376 'suffix':'',
377 'version':version}
378 build_id_release = devserver_constants.IMAGE_DIR % {'board':board,
379 'suffix':RELEASE,
380 'version':version}
381 # Return the first path that exists. We assume that what the user typed
382 # is better than with a default suffix added i.e. x86-generic/blah is
383 # more valuable than x86-generic-release/blah.
384 for build_id in build_id_as_is, build_id_release:
385 cmd = 'gsutil ls %s/%s' % (devserver_constants.GS_IMAGE_DIR, build_id)
386 try:
387 version = gsutil_util.GSUtilRun(cmd, None)
388 return build_id
389 except gsutil_util.GSUtilError:
390 continue
391 else:
392 raise XBuddyException('Could not find remote build_id for %s %s' % (
393 board, version))
394
Simran Basi99e63c02014-05-20 10:39:52 -0700395 def _ResolveVersionToBuildId(self, board, version, image_dir=None):
joychen121fc9b2013-08-02 14:30:30 -0700396 """Handle version aliases for remote payloads in GS.
joychen3cb228e2013-06-12 12:13:13 -0700397
398 Args:
399 board: as specified in the original call. (i.e. x86-generic, parrot)
400 version: as entered in the original call. can be
401 {TBD, 0. some custom alias as defined in a config file}
402 1. latest
403 2. latest-{channel}
404 3. latest-official-{board suffix}
405 4. version prefix (i.e. RX-Y.X, RX-Y, RX)
Simran Basi99e63c02014-05-20 10:39:52 -0700406 image_dir: image directory to check in Google Storage. If none,
407 the default bucket is used.
joychen3cb228e2013-06-12 12:13:13 -0700408
409 Returns:
Chris Sosaea734d92013-10-11 11:28:58 -0700410 Location where the image dir is actually found on GS (build_id)
joychen3cb228e2013-06-12 12:13:13 -0700411
Chris Sosaea734d92013-10-11 11:28:58 -0700412 Raises:
413 XBuddyException: If we failed to resolve the version to a valid url.
joychen3cb228e2013-06-12 12:13:13 -0700414 """
joychenf8f07e22013-07-12 17:45:51 -0700415 # Only the last segment of the alias is variable relative to the rest.
416 version_tuple = version.rsplit('-', 1)
joychen3cb228e2013-06-12 12:13:13 -0700417
joychenf8f07e22013-07-12 17:45:51 -0700418 if re.match(devserver_constants.VERSION_RE, version):
Chris Sosaea734d92013-10-11 11:28:58 -0700419 return self._RemoteBuildId(board, version)
joychenf8f07e22013-07-12 17:45:51 -0700420 elif version == LATEST_OFFICIAL:
421 # latest-official --> LATEST build in board-release
Simran Basi99e63c02014-05-20 10:39:52 -0700422 return self._LookupOfficial(board, image_dir=image_dir)
joychenf8f07e22013-07-12 17:45:51 -0700423 elif version_tuple[0] == LATEST_OFFICIAL:
424 # latest-official-{suffix} --> LATEST build in board-{suffix}
Simran Basi99e63c02014-05-20 10:39:52 -0700425 return self._LookupOfficial(board, version_tuple[1], image_dir=image_dir)
joychenf8f07e22013-07-12 17:45:51 -0700426 elif version == LATEST:
427 # latest --> latest build on stable channel
Simran Basi99e63c02014-05-20 10:39:52 -0700428 return self._LookupChannel(board, image_dir=image_dir)
joychenf8f07e22013-07-12 17:45:51 -0700429 elif version_tuple[0] == LATEST:
430 if re.match(devserver_constants.VERSION_RE, version_tuple[1]):
431 # latest-R* --> most recent qualifying build
432 return self._LookupVersion(board, version_tuple[1])
433 else:
434 # latest-{channel} --> latest build within that channel
Simran Basi99e63c02014-05-20 10:39:52 -0700435 return self._LookupChannel(board, version_tuple[1],
436 image_dir=image_dir)
joychen3cb228e2013-06-12 12:13:13 -0700437 else:
438 # The given version doesn't match any known patterns.
joychen921e1fb2013-06-28 11:12:20 -0700439 raise XBuddyException("Version %s unknown. Can't find on GS." % version)
joychen3cb228e2013-06-12 12:13:13 -0700440
joychen5260b9a2013-07-16 14:48:01 -0700441 @staticmethod
442 def _Symlink(link, target):
443 """Symlinks link to target, and removes whatever link was there before."""
444 _Log("Linking to %s from %s", link, target)
445 if os.path.lexists(link):
446 os.unlink(link)
447 os.symlink(target, link)
448
joychen121fc9b2013-08-02 14:30:30 -0700449 def _GetLatestLocalVersion(self, board):
joychen921e1fb2013-06-28 11:12:20 -0700450 """Get the version of the latest image built for board by build_image
451
452 Updates the symlink reference within the xBuddy static dir to point to
453 the real image dir in the local /build/images directory.
454
455 Args:
joychenc3944cb2013-08-19 10:42:07 -0700456 board: board that image was built for.
joychen921e1fb2013-06-28 11:12:20 -0700457
458 Returns:
joychen121fc9b2013-08-02 14:30:30 -0700459 The discovered version of the image.
joychenc3944cb2013-08-19 10:42:07 -0700460
461 Raises:
462 XBuddyException if neither test nor dev image was found in latest built
463 directory.
joychen3cb228e2013-06-12 12:13:13 -0700464 """
joychen921e1fb2013-06-28 11:12:20 -0700465 latest_local_dir = self.GetLatestImageDir(board)
joychenb0dfe552013-07-30 10:02:06 -0700466 if not latest_local_dir or not os.path.exists(latest_local_dir):
joychen921e1fb2013-06-28 11:12:20 -0700467 raise XBuddyException('No builds found for %s. Did you run build_image?' %
468 board)
469
joychen121fc9b2013-08-02 14:30:30 -0700470 # Assume that the version number is the name of the directory.
joychenc3944cb2013-08-19 10:42:07 -0700471 return os.path.basename(latest_local_dir.rstrip('/'))
joychen921e1fb2013-06-28 11:12:20 -0700472
joychenc3944cb2013-08-19 10:42:07 -0700473 @staticmethod
474 def _FindAny(local_dir):
475 """Returns the image_type for ANY given the local_dir."""
joychenc3944cb2013-08-19 10:42:07 -0700476 test_image = os.path.join(local_dir, devserver_constants.TEST_IMAGE_FILE)
Yu-Ju Hongc23c79b2014-03-17 12:40:33 -0700477 dev_image = os.path.join(local_dir, devserver_constants.IMAGE_FILE)
478 # Prioritize test images over dev images.
joychenc3944cb2013-08-19 10:42:07 -0700479 if os.path.exists(test_image):
480 return 'test'
481
Yu-Ju Hongc23c79b2014-03-17 12:40:33 -0700482 if os.path.exists(dev_image):
483 return 'dev'
484
joychenc3944cb2013-08-19 10:42:07 -0700485 raise XBuddyException('No images found in %s' % local_dir)
486
487 @staticmethod
Chris Sosa0eecf962014-02-03 14:14:39 -0800488 def _InterpretPath(path, default_board=None):
joychen121fc9b2013-08-02 14:30:30 -0700489 """Split and return the pieces of an xBuddy path name
joychen921e1fb2013-06-28 11:12:20 -0700490
joychen121fc9b2013-08-02 14:30:30 -0700491 Args:
492 path: the path xBuddy Get was called with.
Chris Sosa0eecf962014-02-03 14:14:39 -0800493 default_board: board to use in case board isn't in path.
joychen3cb228e2013-06-12 12:13:13 -0700494
Yu-Ju Hongc54658c2014-01-22 09:18:07 -0800495 Returns:
Chris Sosa75490802013-09-30 17:21:45 -0700496 tuple of (image_type, board, version, whether the path is local)
joychen3cb228e2013-06-12 12:13:13 -0700497
498 Raises:
499 XBuddyException: if the path can't be resolved into valid components
500 """
joychen121fc9b2013-08-02 14:30:30 -0700501 path_list = filter(None, path.split('/'))
joychen7df67f72013-07-18 14:21:12 -0700502
Chris Sosa0eecf962014-02-03 14:14:39 -0800503 # Do the stuff that is well known first. We know that if paths have a
504 # image_type, it must be one of the GS/LOCAL aliases and it must be at the
505 # end. Similarly, local/remote are well-known and must start the path list.
506 is_local = True
507 if path_list and path_list[0] in (REMOTE, LOCAL):
508 is_local = (path_list.pop(0) == LOCAL)
joychen7df67f72013-07-18 14:21:12 -0700509
Chris Sosa0eecf962014-02-03 14:14:39 -0800510 # Default image type is determined by remote vs. local.
511 if is_local:
512 image_type = ANY
513 else:
514 image_type = TEST
joychen7df67f72013-07-18 14:21:12 -0700515
Chris Sosa0eecf962014-02-03 14:14:39 -0800516 if path_list and path_list[-1] in GS_ALIASES + LOCAL_ALIASES:
517 image_type = path_list.pop(-1)
joychen3cb228e2013-06-12 12:13:13 -0700518
Chris Sosa0eecf962014-02-03 14:14:39 -0800519 # Now for the tricky part. We don't actually know at this point if the rest
520 # of the path is just a board | version (like R33-2341.0.0) or just a board
521 # or just a version. So we do our best to do the right thing.
522 board = default_board
523 version = LATEST
524 if len(path_list) == 1:
525 path = path_list.pop(0)
526 # If it's a version we know (contains latest), go for that, otherwise only
527 # treat it as a version if we were given an actual default board.
528 if LATEST in path or default_board is not None:
529 version = path
joychen7df67f72013-07-18 14:21:12 -0700530 else:
Chris Sosa0eecf962014-02-03 14:14:39 -0800531 board = path
joychen7df67f72013-07-18 14:21:12 -0700532
Chris Sosa0eecf962014-02-03 14:14:39 -0800533 elif len(path_list) == 2:
534 # Assumes board/version.
535 board = path_list.pop(0)
536 version = path_list.pop(0)
537
538 if path_list:
539 raise XBuddyException("Path isn't valid. Could not figure out how to "
540 "parse remaining components: %s." % path_list)
541
542 _Log("Get artifact '%s' with board %s and version %s'. Locally? %s",
joychen7df67f72013-07-18 14:21:12 -0700543 image_type, board, version, is_local)
544
545 return image_type, board, version, is_local
joychen3cb228e2013-06-12 12:13:13 -0700546
joychen921e1fb2013-06-28 11:12:20 -0700547 def _SyncRegistryWithBuildImages(self):
joychen5260b9a2013-07-16 14:48:01 -0700548 """ Crawl images_dir for build_ids of images generated from build_image.
549
550 This will find images and symlink them in xBuddy's static dir so that
551 xBuddy's cache can serve them.
552 If xBuddy's _manage_builds option is on, then a timestamp will also be
553 generated, and xBuddy will clear them from the directory they are in, as
554 necessary.
555 """
Yu-Ju Hong235d1b52014-04-16 11:01:47 -0700556 if not os.path.isdir(self.images_dir):
557 # Skip syncing if images_dir does not exist.
558 _Log('Cannot find %s; skip syncing image registry.', self.images_dir)
559 return
560
joychen921e1fb2013-06-28 11:12:20 -0700561 build_ids = []
562 for b in os.listdir(self.images_dir):
joychen5260b9a2013-07-16 14:48:01 -0700563 # Ensure we have directories to track all boards in build/images
564 common_util.MkDirP(os.path.join(self.static_dir, b))
joychen921e1fb2013-06-28 11:12:20 -0700565 board_dir = os.path.join(self.images_dir, b)
566 build_ids.extend(['/'.join([b, v]) for v
joychenc3944cb2013-08-19 10:42:07 -0700567 in os.listdir(board_dir) if not v == LATEST])
joychen921e1fb2013-06-28 11:12:20 -0700568
joychen121fc9b2013-08-02 14:30:30 -0700569 # Check currently registered images.
joychen921e1fb2013-06-28 11:12:20 -0700570 for f in os.listdir(self._timestamp_folder):
571 build_id = Timestamp.TimestampToBuild(f)
572 if build_id in build_ids:
573 build_ids.remove(build_id)
574
joychen121fc9b2013-08-02 14:30:30 -0700575 # Symlink undiscovered images, and update timestamps if manage_builds is on.
joychen5260b9a2013-07-16 14:48:01 -0700576 for build_id in build_ids:
577 link = os.path.join(self.static_dir, build_id)
578 target = os.path.join(self.images_dir, build_id)
579 XBuddy._Symlink(link, target)
580 if self._manage_builds:
581 Timestamp.UpdateTimestamp(self._timestamp_folder, build_id)
joychen921e1fb2013-06-28 11:12:20 -0700582
583 def _ListBuildTimes(self):
joychen3cb228e2013-06-12 12:13:13 -0700584 """ Returns the currently cached builds and their last access timestamp.
585
586 Returns:
587 list of tuples that matches xBuddy build/version to timestamps in long
588 """
joychen121fc9b2013-08-02 14:30:30 -0700589 # Update currently cached builds.
joychen3cb228e2013-06-12 12:13:13 -0700590 build_dict = {}
591
joychen7df67f72013-07-18 14:21:12 -0700592 for f in os.listdir(self._timestamp_folder):
joychen3cb228e2013-06-12 12:13:13 -0700593 last_accessed = os.path.getmtime(os.path.join(self._timestamp_folder, f))
594 build_id = Timestamp.TimestampToBuild(f)
joychenc3944cb2013-08-19 10:42:07 -0700595 stale_time = datetime.timedelta(seconds=(time.time() - last_accessed))
joychen921e1fb2013-06-28 11:12:20 -0700596 build_dict[build_id] = stale_time
joychen3cb228e2013-06-12 12:13:13 -0700597 return_tup = sorted(build_dict.iteritems(), key=operator.itemgetter(1))
598 return return_tup
599
Chris Sosa75490802013-09-30 17:21:45 -0700600 def _Download(self, gs_url, artifacts):
601 """Download the artifacts from the given gs_url.
602
603 Raises:
604 build_artifact.ArtifactDownloadError: If we failed to download the
605 artifact.
606 """
joychen3cb228e2013-06-12 12:13:13 -0700607 with XBuddy._staging_thread_count_lock:
608 XBuddy._staging_thread_count += 1
609 try:
Chris Sosa75490802013-09-30 17:21:45 -0700610 _Log("Downloading %s from %s", artifacts, gs_url)
611 downloader.Downloader(self.static_dir, gs_url).Download(artifacts, [])
joychen3cb228e2013-06-12 12:13:13 -0700612 finally:
613 with XBuddy._staging_thread_count_lock:
614 XBuddy._staging_thread_count -= 1
615
Chris Sosa75490802013-09-30 17:21:45 -0700616 def CleanCache(self):
joychen562699a2013-08-13 15:22:14 -0700617 """Delete all builds besides the newest N builds"""
joychen121fc9b2013-08-02 14:30:30 -0700618 if not self._manage_builds:
619 return
joychen921e1fb2013-06-28 11:12:20 -0700620 cached_builds = [e[0] for e in self._ListBuildTimes()]
joychen3cb228e2013-06-12 12:13:13 -0700621 _Log('In cache now: %s', cached_builds)
622
joychen562699a2013-08-13 15:22:14 -0700623 for b in range(self._Capacity(), len(cached_builds)):
joychen3cb228e2013-06-12 12:13:13 -0700624 b_path = cached_builds[b]
joychen7df67f72013-07-18 14:21:12 -0700625 _Log("Clearing '%s' from cache", b_path)
joychen3cb228e2013-06-12 12:13:13 -0700626
627 time_file = os.path.join(self._timestamp_folder,
628 Timestamp.BuildToTimestamp(b_path))
joychen921e1fb2013-06-28 11:12:20 -0700629 os.unlink(time_file)
630 clear_dir = os.path.join(self.static_dir, b_path)
joychen3cb228e2013-06-12 12:13:13 -0700631 try:
joychen121fc9b2013-08-02 14:30:30 -0700632 # Handle symlinks, in the case of links to local builds if enabled.
633 if os.path.islink(clear_dir):
joychen5260b9a2013-07-16 14:48:01 -0700634 target = os.readlink(clear_dir)
635 _Log('Deleting locally built image at %s', target)
joychen921e1fb2013-06-28 11:12:20 -0700636
637 os.unlink(clear_dir)
joychen5260b9a2013-07-16 14:48:01 -0700638 if os.path.exists(target):
joychen921e1fb2013-06-28 11:12:20 -0700639 shutil.rmtree(target)
640 elif os.path.exists(clear_dir):
joychen5260b9a2013-07-16 14:48:01 -0700641 _Log('Deleting downloaded image at %s', clear_dir)
joychen3cb228e2013-06-12 12:13:13 -0700642 shutil.rmtree(clear_dir)
joychen921e1fb2013-06-28 11:12:20 -0700643
joychen121fc9b2013-08-02 14:30:30 -0700644 except Exception as err:
645 raise XBuddyException('Failed to clear %s: %s' % (clear_dir, err))
joychen3cb228e2013-06-12 12:13:13 -0700646
Simran Basi99e63c02014-05-20 10:39:52 -0700647 def _GetFromGS(self, build_id, image_type, image_dir=None):
Chris Sosa75490802013-09-30 17:21:45 -0700648 """Check if the artifact is available locally. Download from GS if not.
649
Simran Basi99e63c02014-05-20 10:39:52 -0700650 Args:
651 build_id: Path to the image or update directory on the devserver or
652 in Google Storage. e.g. 'x86-generic/R26-4000.0.0'
653 image_type: Image type to download. Look at aliases at top of file for
654 options.
655 image_dir: Google Storage image archive to search in if requesting a
656 remote artifact. If none uses the default bucket.
657
Chris Sosa75490802013-09-30 17:21:45 -0700658 Raises:
659 build_artifact.ArtifactDownloadError: If we failed to download the
660 artifact.
661 """
Simran Basi99e63c02014-05-20 10:39:52 -0700662 image_dir = XBuddy._ResolveImageDir(image_dir)
663 gs_url = os.path.join(image_dir, build_id)
joychen921e1fb2013-06-28 11:12:20 -0700664
joychen121fc9b2013-08-02 14:30:30 -0700665 # Stage image if not found in cache.
joychen921e1fb2013-06-28 11:12:20 -0700666 file_name = GS_ALIAS_TO_FILENAME[image_type]
joychen346531c2013-07-24 16:55:56 -0700667 file_loc = os.path.join(self.static_dir, build_id, file_name)
668 cached = os.path.exists(file_loc)
669
joychen921e1fb2013-06-28 11:12:20 -0700670 if not cached:
Chris Sosa75490802013-09-30 17:21:45 -0700671 artifact = GS_ALIAS_TO_ARTIFACT[image_type]
672 self._Download(gs_url, [artifact])
joychen921e1fb2013-06-28 11:12:20 -0700673 else:
674 _Log('Image already cached.')
675
Simran Basi99e63c02014-05-20 10:39:52 -0700676 def _GetArtifact(self, path_list, board=None, lookup_only=False,
677 image_dir=None):
joychen346531c2013-07-24 16:55:56 -0700678 """Interpret an xBuddy path and return directory/file_name to resource.
679
Chris Sosa75490802013-09-30 17:21:45 -0700680 Note board can be passed that in but by default if self._board is set,
681 that is used rather than board.
682
Simran Basi99e63c02014-05-20 10:39:52 -0700683 Args:
684 path_list: [board, version, alias] as split from the xbuddy call url.
685 board: Board whos artifacts we are looking for. If None, use the board
686 XBuddy was initialized to use.
687 lookup_only: If true just look up the artifact, if False stage it on
688 the devserver as well.
689 image_dir: Google Storage image archive to search in if requesting a
690 remote artifact. If none uses the default bucket.
691
joychen346531c2013-07-24 16:55:56 -0700692 Returns:
Simran Basi99e63c02014-05-20 10:39:52 -0700693 build_id: Path to the image or update directory on the devserver or
694 in Google Storage. e.g. 'x86-generic/R26-4000.0.0'
695 file_name: of the artifact in the build_id directory.
joychen346531c2013-07-24 16:55:56 -0700696
697 Raises:
joychen121fc9b2013-08-02 14:30:30 -0700698 XBuddyException: if the path could not be translated
Chris Sosa75490802013-09-30 17:21:45 -0700699 build_artifact.ArtifactDownloadError: if we failed to download the
700 artifact.
joychen346531c2013-07-24 16:55:56 -0700701 """
joychen121fc9b2013-08-02 14:30:30 -0700702 path = '/'.join(path_list)
Chris Sosa0eecf962014-02-03 14:14:39 -0800703 default_board = self._board if self._board else board
joychenb0dfe552013-07-30 10:02:06 -0700704 # Rewrite the path if there is an appropriate default.
Chris Sosa0eecf962014-02-03 14:14:39 -0800705 path = self._LookupAlias(path, default_board)
joychen121fc9b2013-08-02 14:30:30 -0700706 # Parse the path.
Chris Sosa0eecf962014-02-03 14:14:39 -0800707 image_type, board, version, is_local = self._InterpretPath(
708 path, default_board)
joychen7df67f72013-07-18 14:21:12 -0700709 if is_local:
joychen121fc9b2013-08-02 14:30:30 -0700710 # Get a local image.
joychen7df67f72013-07-18 14:21:12 -0700711 if version == LATEST:
joychen121fc9b2013-08-02 14:30:30 -0700712 # Get the latest local image for the given board.
713 version = self._GetLatestLocalVersion(board)
joychen7df67f72013-07-18 14:21:12 -0700714
joychenc3944cb2013-08-19 10:42:07 -0700715 build_id = os.path.join(board, version)
716 artifact_dir = os.path.join(self.static_dir, build_id)
717 if image_type == ANY:
718 image_type = self._FindAny(artifact_dir)
joychen121fc9b2013-08-02 14:30:30 -0700719
joychenc3944cb2013-08-19 10:42:07 -0700720 file_name = LOCAL_ALIAS_TO_FILENAME[image_type]
721 artifact_path = os.path.join(artifact_dir, file_name)
722 if not os.path.exists(artifact_path):
723 raise XBuddyException('Local %s artifact not in static_dir at %s' %
724 (image_type, artifact_path))
joychen121fc9b2013-08-02 14:30:30 -0700725
joychen921e1fb2013-06-28 11:12:20 -0700726 else:
joychen121fc9b2013-08-02 14:30:30 -0700727 # Get a remote image.
joychen921e1fb2013-06-28 11:12:20 -0700728 if image_type not in GS_ALIASES:
joychen7df67f72013-07-18 14:21:12 -0700729 raise XBuddyException('Bad remote image type: %s. Use one of: %s' %
joychen921e1fb2013-06-28 11:12:20 -0700730 (image_type, GS_ALIASES))
Simran Basi99e63c02014-05-20 10:39:52 -0700731 build_id = self._ResolveVersionToBuildId(board, version,
732 image_dir=image_dir)
Chris Sosa75490802013-09-30 17:21:45 -0700733 _Log('Resolved version %s to %s.', version, build_id)
734 file_name = GS_ALIAS_TO_FILENAME[image_type]
735 if not lookup_only:
Simran Basi99e63c02014-05-20 10:39:52 -0700736 self._GetFromGS(build_id, image_type, image_dir=image_dir)
joychenf8f07e22013-07-12 17:45:51 -0700737
joychenc3944cb2013-08-19 10:42:07 -0700738 return build_id, file_name
joychen3cb228e2013-06-12 12:13:13 -0700739
740 ############################ BEGIN PUBLIC METHODS
741
742 def List(self):
743 """Lists the currently available images & time since last access."""
joychen921e1fb2013-06-28 11:12:20 -0700744 self._SyncRegistryWithBuildImages()
745 builds = self._ListBuildTimes()
746 return_string = ''
747 for build, timestamp in builds:
748 return_string += '<b>' + build + '</b> '
749 return_string += '(time since last access: ' + str(timestamp) + ')<br>'
750 return return_string
joychen3cb228e2013-06-12 12:13:13 -0700751
752 def Capacity(self):
753 """Returns the number of images cached by xBuddy."""
joychen562699a2013-08-13 15:22:14 -0700754 return str(self._Capacity())
joychen3cb228e2013-06-12 12:13:13 -0700755
Simran Basi99e63c02014-05-20 10:39:52 -0700756 def Translate(self, path_list, board=None, image_dir=None):
joychen346531c2013-07-24 16:55:56 -0700757 """Translates an xBuddy path to a real path to artifact if it exists.
758
joychen121fc9b2013-08-02 14:30:30 -0700759 Equivalent to the Get call, minus downloading and updating timestamps,
joychen346531c2013-07-24 16:55:56 -0700760
Simran Basi99e63c02014-05-20 10:39:52 -0700761 Args:
762 path_list: [board, version, alias] as split from the xbuddy call url.
763 board: Board whos artifacts we are looking for. If None, use the board
764 XBuddy was initialized to use.
765 image_dir: image directory to check in Google Storage. If none,
766 the default bucket is used.
767
joychen7c2054a2013-07-25 11:14:07 -0700768 Returns:
joychen121fc9b2013-08-02 14:30:30 -0700769 build_id: Path to the image or update directory on the devserver.
770 e.g. 'x86-generic/R26-4000.0.0'
771 The returned path is always the path to the directory within
772 static_dir, so it is always the build_id of the image.
773 file_name: The file name of the artifact. Can take any of the file
774 values in devserver_constants.
775 e.g. 'chromiumos_test_image.bin' or 'update.gz' if the path list
776 specified 'test' or 'full_payload' artifacts, respectively.
joychen7c2054a2013-07-25 11:14:07 -0700777
joychen121fc9b2013-08-02 14:30:30 -0700778 Raises:
779 XBuddyException: if the path couldn't be translated
joychen346531c2013-07-24 16:55:56 -0700780 """
781 self._SyncRegistryWithBuildImages()
Chris Sosa75490802013-09-30 17:21:45 -0700782 build_id, file_name = self._GetArtifact(path_list, board=board,
Simran Basi99e63c02014-05-20 10:39:52 -0700783 lookup_only=True,
784 image_dir=image_dir)
joychen346531c2013-07-24 16:55:56 -0700785
joychen121fc9b2013-08-02 14:30:30 -0700786 _Log('Returning path to payload: %s/%s', build_id, file_name)
787 return build_id, file_name
joychen346531c2013-07-24 16:55:56 -0700788
Yu-Ju Hong1bdb7a92014-04-10 16:02:11 -0700789 def StageTestArtifactsForUpdate(self, path_list):
Chris Sosa75490802013-09-30 17:21:45 -0700790 """Stages test artifacts for update and returns build_id.
791
792 Raises:
793 XBuddyException: if the path could not be translated
794 build_artifact.ArtifactDownloadError: if we failed to download the test
795 artifacts.
796 """
797 build_id, file_name = self.Translate(path_list)
798 if file_name == devserver_constants.TEST_IMAGE_FILE:
799 gs_url = os.path.join(devserver_constants.GS_IMAGE_DIR,
800 build_id)
801 artifacts = [FULL, STATEFUL]
802 self._Download(gs_url, artifacts)
803 return build_id
804
Simran Basi99e63c02014-05-20 10:39:52 -0700805 def Get(self, path_list, image_dir=None):
joychen921e1fb2013-06-28 11:12:20 -0700806 """The full xBuddy call, returns resource specified by path_list.
joychen3cb228e2013-06-12 12:13:13 -0700807
808 Please see devserver.py:xbuddy for full documentation.
joychen121fc9b2013-08-02 14:30:30 -0700809
joychen3cb228e2013-06-12 12:13:13 -0700810 Args:
Simran Basi99e63c02014-05-20 10:39:52 -0700811 path_list: [board, version, alias] as split from the xbuddy call url.
812 image_dir: image directory to check in Google Storage. If none,
813 the default bucket is used.
joychen3cb228e2013-06-12 12:13:13 -0700814
815 Returns:
joychen121fc9b2013-08-02 14:30:30 -0700816 build_id: Path to the image or update directory on the devserver.
Simran Basi99e63c02014-05-20 10:39:52 -0700817 e.g. 'x86-generic/R26-4000.0.0'
818 The returned path is always the path to the directory within
819 static_dir, so it is always the build_id of the image.
joychen121fc9b2013-08-02 14:30:30 -0700820 file_name: The file name of the artifact. Can take any of the file
Simran Basi99e63c02014-05-20 10:39:52 -0700821 values in devserver_constants.
822 e.g. 'chromiumos_test_image.bin' or 'update.gz' if the path list
823 specified 'test' or 'full_payload' artifacts, respectively.
joychen3cb228e2013-06-12 12:13:13 -0700824
825 Raises:
Chris Sosa75490802013-09-30 17:21:45 -0700826 XBuddyException: if the path could not be translated
827 build_artifact.ArtifactDownloadError: if we failed to download the
828 artifact.
joychen3cb228e2013-06-12 12:13:13 -0700829 """
joychen7df67f72013-07-18 14:21:12 -0700830 self._SyncRegistryWithBuildImages()
Simran Basi99e63c02014-05-20 10:39:52 -0700831 build_id, file_name = self._GetArtifact(path_list, image_dir=image_dir)
joychen921e1fb2013-06-28 11:12:20 -0700832 Timestamp.UpdateTimestamp(self._timestamp_folder, build_id)
joychen3cb228e2013-06-12 12:13:13 -0700833 #TODO (joyc): run in sep thread
Chris Sosa75490802013-09-30 17:21:45 -0700834 self.CleanCache()
joychen3cb228e2013-06-12 12:13:13 -0700835
joychen121fc9b2013-08-02 14:30:30 -0700836 _Log('Returning path to payload: %s/%s', build_id, file_name)
837 return build_id, file_name