Enable autotest client package fetching based on updated image.
The new customization will enable autotest client to fetch a test package
from dev server based on its update url. This could avoid to pre-load all
client packages on stateful partition and shrinked its space from 450M ~ 90M
approximately.
It will only be activated after we add a fetch_location entry in global_config.ini.
Change-Id: I0f57a856b9d78c3245f1ff2a841acd98d6d3717e
BUG=None
TEST=server/autoserv -m IP {client,server}/tests/sleeptest/control --image update_url
carefully read autoserv and client DEBUG log to see packages were downloaded from the dev server.
Review URL: http://codereview.chromium.org/6883099
diff --git a/client/common_lib/site_packages.py b/client/common_lib/site_packages.py
new file mode 100644
index 0000000..c9cb75b
--- /dev/null
+++ b/client/common_lib/site_packages.py
@@ -0,0 +1,16 @@
+from autotest_lib.client.common_lib import base_packages
+
+
+class SiteHttpFetcher(base_packages.HttpFetcher):
+ # shortcut quick http test for now since our dev server does not support
+ # this operation.
+ def _quick_http_test(self):
+ return
+
+
+class SitePackageManager(base_packages.BasePackageManager):
+ def get_fetcher(self, url):
+ if url.startswith('http://'):
+ return SiteHttpFetcher(self, url)
+ else:
+ return super(SitePackageManager, self).get_fetcher(url)
diff --git a/server/site_autotest.py b/server/site_autotest.py
index 1709b28..4b66712 100755
--- a/server/site_autotest.py
+++ b/server/site_autotest.py
@@ -1,5 +1,11 @@
import os
-from autotest_lib.server import installable_object
+from autotest_lib.client.common_lib import global_config
+from autotest_lib.server import autoserv_parser, installable_object
+
+
+config = global_config.global_config
+parser = autoserv_parser.autoserv_parser
+
class SiteAutotest(installable_object.InstallableObject):
@@ -11,5 +17,21 @@
self.got = True
+ def get_fetch_location(self):
+ if not parser.options.image:
+ return super(SiteAutotest, self).get_fetch_location()
+
+ repos = config.get_config_value('PACKAGES', 'fetch_location', type=list,
+ default=[])
+ new_repos = []
+ for repo in repos[::-1]:
+ if repo.endswith('static/archive'):
+ path = parser.options.image.rstrip('/')
+ build = '/'.join(path.split('/')[-2:])
+ repo += '/%s/autotest' % build
+ new_repos.append(repo)
+ return new_repos
+
+
class _SiteRun(object):
pass