Add --dry-run option to zuul_swift_upload
To help with debugging Change-Id: I4e372382ab599b602cfbc2d5fa8a9cd47fa86e66
This commit is contained in:
parent
ad4abbbd5a
commit
6de6e20609
@ -452,7 +452,7 @@ def run(cloud, container, files,
|
|||||||
indexes=True, parent_links=True, partition=False,
|
indexes=True, parent_links=True, partition=False,
|
||||||
footer='index_footer.html',
|
footer='index_footer.html',
|
||||||
delete_after=15552000, prefix=None,
|
delete_after=15552000, prefix=None,
|
||||||
public=True):
|
public=True, dry_run=False):
|
||||||
|
|
||||||
if prefix:
|
if prefix:
|
||||||
prefix = prefix.lstrip('/')
|
prefix = prefix.lstrip('/')
|
||||||
@ -466,8 +466,6 @@ def run(cloud, container, files,
|
|||||||
file_list = FileList()
|
file_list = FileList()
|
||||||
indexer = Indexer(create_parent_links=parent_links,
|
indexer = Indexer(create_parent_links=parent_links,
|
||||||
append_footer=footer)
|
append_footer=footer)
|
||||||
uploader = Uploader(cloud, container, prefix, delete_after,
|
|
||||||
public)
|
|
||||||
|
|
||||||
# Scan the files.
|
# Scan the files.
|
||||||
for file_path in files:
|
for file_path in files:
|
||||||
@ -481,7 +479,14 @@ def run(cloud, container, files,
|
|||||||
for x in file_list:
|
for x in file_list:
|
||||||
logging.debug(x)
|
logging.debug(x)
|
||||||
|
|
||||||
|
# Do no connect to swift or do any uploading in a dry run
|
||||||
|
if dry_run:
|
||||||
|
# No URL is known, so return nothing
|
||||||
|
return
|
||||||
|
|
||||||
# Upload.
|
# Upload.
|
||||||
|
uploader = Uploader(cloud, container, prefix, delete_after,
|
||||||
|
public)
|
||||||
uploader.upload(file_list)
|
uploader.upload(file_list)
|
||||||
return uploader.url
|
return uploader.url
|
||||||
|
|
||||||
@ -542,6 +547,9 @@ def cli_main():
|
|||||||
parser.add_argument('--prefix',
|
parser.add_argument('--prefix',
|
||||||
help='Prepend this path to the object names when '
|
help='Prepend this path to the object names when '
|
||||||
'uploading')
|
'uploading')
|
||||||
|
parser.add_argument('--dry-run', action='store_true',
|
||||||
|
help='do not attempt to create containers or upload, '
|
||||||
|
'useful with --verbose for debugging')
|
||||||
parser.add_argument('cloud',
|
parser.add_argument('cloud',
|
||||||
help='Name of the cloud to use when uploading')
|
help='Name of the cloud to use when uploading')
|
||||||
parser.add_argument('container',
|
parser.add_argument('container',
|
||||||
@ -569,7 +577,8 @@ def cli_main():
|
|||||||
footer=append_footer,
|
footer=append_footer,
|
||||||
delete_after=args.delete_after,
|
delete_after=args.delete_after,
|
||||||
prefix=args.prefix,
|
prefix=args.prefix,
|
||||||
public=not args.no_public)
|
public=not args.no_public,
|
||||||
|
dry_run=args.dry_run)
|
||||||
print(url)
|
print(url)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user