Merge "Allow to specify segment container"
This commit is contained in:
commit
974f530bdb
26
bin/swift
26
bin/swift
@ -754,7 +754,9 @@ upload [options] container file_or_directory [file_or_directory] [...]
|
|||||||
Uploads to the given container the files and directories specified by the
|
Uploads to the given container the files and directories specified by the
|
||||||
remaining args. -c or --changed is an option that will only upload files
|
remaining args. -c or --changed is an option that will only upload files
|
||||||
that have changed since the last upload. -S <size> or --segment-size <size>
|
that have changed since the last upload. -S <size> or --segment-size <size>
|
||||||
and --leave-segments are options as well (see --help for more).
|
will upload the files in segments no larger than size. -C <container> or
|
||||||
|
--segment-container <container> will specify the location of the segments
|
||||||
|
to <container>. --leave-segments are options as well (see --help for more).
|
||||||
'''.strip('\n')
|
'''.strip('\n')
|
||||||
|
|
||||||
|
|
||||||
@ -765,7 +767,10 @@ def st_upload(parser, args, print_queue, error_queue):
|
|||||||
parser.add_option('-S', '--segment-size', dest='segment_size', help='Will '
|
parser.add_option('-S', '--segment-size', dest='segment_size', help='Will '
|
||||||
'upload files in segments no larger than <size> and then create a '
|
'upload files in segments no larger than <size> and then create a '
|
||||||
'"manifest" file that will download all the segments as if it were '
|
'"manifest" file that will download all the segments as if it were '
|
||||||
'the original file. The segments will be uploaded to a '
|
'the original file.')
|
||||||
|
parser.add_option('-C', '--segment-container', dest='segment_container',
|
||||||
|
help='Will upload the segments into the specified container.'
|
||||||
|
'If not specified, the segments will be uploaded to '
|
||||||
'<container>_segments container so as to not pollute the main '
|
'<container>_segments container so as to not pollute the main '
|
||||||
'<container> listings.')
|
'<container> listings.')
|
||||||
parser.add_option('', '--leave-segments', action='store_true',
|
parser.add_option('', '--leave-segments', action='store_true',
|
||||||
@ -792,7 +797,10 @@ def st_upload(parser, args, print_queue, error_queue):
|
|||||||
else:
|
else:
|
||||||
fp = open(job['path'], 'rb')
|
fp = open(job['path'], 'rb')
|
||||||
fp.seek(job['segment_start'])
|
fp.seek(job['segment_start'])
|
||||||
conn.put_object(job.get('container', args[0] + '_segments'),
|
seg_container = args[0] +'_segments'
|
||||||
|
if options.segment_container:
|
||||||
|
seg_container = options.segment_container
|
||||||
|
conn.put_object(job.get('container', seg_container),
|
||||||
job['obj'], fp, content_length=job['segment_size'])
|
job['obj'], fp, content_length=job['segment_size'])
|
||||||
if options.verbose and 'log_line' in job:
|
if options.verbose and 'log_line' in job:
|
||||||
if conn.attempts > 1:
|
if conn.attempts > 1:
|
||||||
@ -852,6 +860,9 @@ def st_upload(parser, args, print_queue, error_queue):
|
|||||||
# Don't do segment job if object is not big enough
|
# Don't do segment job if object is not big enough
|
||||||
if options.segment_size and \
|
if options.segment_size and \
|
||||||
getsize(path) > int(options.segment_size):
|
getsize(path) > int(options.segment_size):
|
||||||
|
seg_container = container + '_segments'
|
||||||
|
if options.segment_container:
|
||||||
|
seg_container = options.segment_container
|
||||||
full_size = getsize(path)
|
full_size = getsize(path)
|
||||||
segment_queue = Queue(10000)
|
segment_queue = Queue(10000)
|
||||||
segment_threads = [QueueFunctionThread(segment_queue,
|
segment_threads = [QueueFunctionThread(segment_queue,
|
||||||
@ -884,8 +895,8 @@ def st_upload(parser, args, print_queue, error_queue):
|
|||||||
raise ClientException('Aborting manifest creation '
|
raise ClientException('Aborting manifest creation '
|
||||||
'because not all segments could be uploaded. %s/%s'
|
'because not all segments could be uploaded. %s/%s'
|
||||||
% (container, obj))
|
% (container, obj))
|
||||||
new_object_manifest = '%s_segments/%s/%s/%s/%s' % (
|
new_object_manifest = '%s/%s/%s/%s/%s' % (
|
||||||
quote(container), quote(obj),
|
quote(seg_container), quote(obj),
|
||||||
put_headers['x-object-meta-mtime'], full_size,
|
put_headers['x-object-meta-mtime'], full_size,
|
||||||
options.segment_size)
|
options.segment_size)
|
||||||
if old_manifest == new_object_manifest:
|
if old_manifest == new_object_manifest:
|
||||||
@ -954,7 +965,10 @@ def st_upload(parser, args, print_queue, error_queue):
|
|||||||
try:
|
try:
|
||||||
conn.put_container(args[0])
|
conn.put_container(args[0])
|
||||||
if options.segment_size is not None:
|
if options.segment_size is not None:
|
||||||
conn.put_container(args[0] + '_segments')
|
seg_container = args[0] + '_segments'
|
||||||
|
if options.segment_container:
|
||||||
|
seg_container = options.segment_container
|
||||||
|
conn.put_container(seg_container)
|
||||||
except ClientException, err:
|
except ClientException, err:
|
||||||
msg = ' '.join(str(x) for x in (err.http_status, err.http_reason))
|
msg = ' '.join(str(x) for x in (err.http_status, err.http_reason))
|
||||||
if err.http_response_content:
|
if err.http_response_content:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user