devserver: Allow quick provision to be requested for cros_au RPC.
BUG=chromium:779870
TEST=curl "http://${ds}/stage?archive_url=gs://chromeos-image-archive/${build}&artifacts=quick_provision,stateful"; curl "http://${ds}/cros_au?full_update=False&force_update=True&build_name=${build}&host_name=${dut}&async=False&clobber_stateful=True&quick_provision=True"
Change-Id: I24fac73509a718d42cf64ec55f9597a235f6eca8
Reviewed-on: https://chromium-review.googlesource.com/751793
Commit-Ready: David Riley <davidriley@chromium.org>
Tested-by: David Riley <davidriley@chromium.org>
Reviewed-by: Xixuan Wu <xixuan@chromium.org>
diff --git a/autoupdate.py b/autoupdate.py
index 3fb9ff4..ca5dd1e 100644
--- a/autoupdate.py
+++ b/autoupdate.py
@@ -710,14 +710,20 @@
raise common_util.DevServerHTTPError(
400, 'Omaha requests need a valid update channel')
- def _GetStaticUrl(self):
- """Returns the static url base that should prefix all payload responses."""
+ def GetDevserverUrl(self):
+ """Returns the devserver url base."""
x_forwarded_host = cherrypy.request.headers.get('X-Forwarded-Host')
if x_forwarded_host:
hostname = 'http://' + x_forwarded_host
else:
hostname = cherrypy.request.base
+ return hostname
+
+ def GetStaticUrl(self):
+ """Returns the static url base that should prefix all payload responses."""
+ hostname = self.GetDevserverUrl()
+
if self.urlbase:
static_urlbase = self.urlbase
else:
@@ -864,7 +870,7 @@
"""
# Get the static url base that will form that base of our update url e.g.
# http://hostname:8080/static/update.gz.
- static_urlbase = self._GetStaticUrl()
+ static_urlbase = self.GetStaticUrl()
# Parse the XML we got into the components we care about.
protocol, app, event, update_check = autoupdate_lib.ParseUpdateRequest(data)
diff --git a/devserver.py b/devserver.py
index af7df5b..41fff12 100755
--- a/devserver.py
+++ b/devserver.py
@@ -902,6 +902,7 @@
reimage. If False, try stateful update first if the dut is already
installed with the same version.
async: Whether the auto_update function is ran in the background.
+ quick_provision: Whether the quick provision path is attempted first.
Returns:
A tuple includes two elements:
@@ -919,6 +920,10 @@
original_build = _parse_string_arg(kwargs, 'original_build')
payload_filename = _parse_string_arg(kwargs, 'payload_filename')
clobber_stateful = _parse_boolean_arg(kwargs, 'clobber_stateful')
+ quick_provision = _parse_boolean_arg(kwargs, 'quick_provision')
+
+ devserver_url = updater.GetDevserverUrl()
+ static_url = updater.GetStaticUrl()
if async:
path = os.path.dirname(os.path.abspath(__file__))
@@ -948,6 +953,15 @@
if clobber_stateful:
args = ('%s --clobber_stateful' % args)
+ if quick_provision:
+ args = ('%s --quick_provision' % args)
+
+ if devserver_url:
+ args = ('%s --devserver_url %s' % (args, devserver_url))
+
+ if static_url:
+ args = ('%s --static_url %s' % (args, static_url))
+
p = subprocess.Popen([args], shell=True, preexec_fn=os.setsid)
pid = os.getpgid(p.pid)
@@ -960,7 +974,9 @@
else:
cros_update_trigger = cros_update.CrOSUpdateTrigger(
host_name, build_name, updater.static_dir, force_update=force_update,
- full_update=full_update, original_build=original_build)
+ full_update=full_update, original_build=original_build,
+ quick_provision=quick_provision, devserver_url=devserver_url,
+ static_url=static_url)
cros_update_trigger.TriggerAU()
return json.dumps((True, -1))