Ensure there is a slash in the object prefix

zuul sends the destination address without a trailing slash.
This is because the LOG_PATH does not contain one.

Check to see if we need to add a slash to object paths before
pushing to swift

Change-Id: I3e43c4ea266b57028fcaf9aa5fd09f1f5e37c306
This commit is contained in:
Joshua Hesketh 2014-07-03 15:33:21 +10:00 committed by Clark Boylan
parent df4f93b891
commit 28be6108c9

View File

@ -92,8 +92,14 @@ def swift_form_post_submit(file_list, url, hmac_body, signature):
files = {} files = {}
# Zuul's log path is generated without a tailing slash. As such the
# object prefix does not contain a slash and the files would be
# uploaded as 'prefix' + 'filename'. Assume we want the destination
# url to look like a folder and make sure there's a slash between.
filename_prefix = '/' if url[-1] != '/' else ''
for i, f in enumerate(file_list): for i, f in enumerate(file_list):
files['file%d' % (i + 1)] = (f['filename'], open(f['path'], 'rb'), files['file%d' % (i + 1)] = (filename_prefix + f['filename'],
open(f['path'], 'rb'),
get_file_mime(f['path'])) get_file_mime(f['path']))
requests.post(url, data=payload, files=files) requests.post(url, data=payload, files=files)