Check threads number options validation
Add checking object-threads, container-threads and segment-threads options validation The values should be a positive integer Change-Id: Iaf98e33dae4b9a7f82e33f7cc2e5a0b293a1c76f Close-Bug: #1546973
This commit is contained in:
@@ -92,11 +92,11 @@ def st_delete(parser, args, output_manager):
|
|||||||
parser.add_option(
|
parser.add_option(
|
||||||
'', '--object-threads', type=int,
|
'', '--object-threads', type=int,
|
||||||
default=10, help='Number of threads to use for deleting objects. '
|
default=10, help='Number of threads to use for deleting objects. '
|
||||||
'Default is 10.')
|
'Its value must be a positive integer. Default is 10.')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
'', '--container-threads', type=int,
|
'', '--container-threads', type=int,
|
||||||
default=10, help='Number of threads to use for deleting containers. '
|
default=10, help='Number of threads to use for deleting containers. '
|
||||||
'Default is 10.')
|
'Its value must be a positive integer. Default is 10.')
|
||||||
(options, args) = parse_args(parser, args)
|
(options, args) = parse_args(parser, args)
|
||||||
args = args[1:]
|
args = args[1:]
|
||||||
if (not args and not options.yes_all) or (args and options.yes_all):
|
if (not args and not options.yes_all) or (args and options.yes_all):
|
||||||
@@ -105,6 +105,22 @@ def st_delete(parser, args, output_manager):
|
|||||||
st_delete_help)
|
st_delete_help)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if options.object_threads <= 0:
|
||||||
|
output_manager.error(
|
||||||
|
'ERROR: option --object-threads should be a positive integer.'
|
||||||
|
'\n\nUsage: %s delete %s\n%s',
|
||||||
|
BASENAME, st_delete_options,
|
||||||
|
st_delete_help)
|
||||||
|
return
|
||||||
|
|
||||||
|
if options.container_threads <= 0:
|
||||||
|
output_manager.error(
|
||||||
|
'ERROR: option --container-threads should be a positive integer.'
|
||||||
|
'\n\nUsage: %s delete %s\n%s',
|
||||||
|
BASENAME, st_delete_options,
|
||||||
|
st_delete_help)
|
||||||
|
return
|
||||||
|
|
||||||
_opts = vars(options)
|
_opts = vars(options)
|
||||||
_opts['object_dd_threads'] = options.object_threads
|
_opts['object_dd_threads'] = options.object_threads
|
||||||
with SwiftService(options=_opts) as swift:
|
with SwiftService(options=_opts) as swift:
|
||||||
@@ -272,11 +288,11 @@ def st_download(parser, args, output_manager):
|
|||||||
parser.add_option(
|
parser.add_option(
|
||||||
'', '--object-threads', type=int,
|
'', '--object-threads', type=int,
|
||||||
default=10, help='Number of threads to use for downloading objects. '
|
default=10, help='Number of threads to use for downloading objects. '
|
||||||
'Default is 10.')
|
'Its value must be a positive integer. Default is 10.')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
'', '--container-threads', type=int, default=10,
|
'', '--container-threads', type=int, default=10,
|
||||||
help='Number of threads to use for downloading containers. '
|
help='Number of threads to use for downloading containers. '
|
||||||
'Default is 10.')
|
'Its value must be a positive integer. Default is 10.')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
'', '--no-download', action='store_true',
|
'', '--no-download', action='store_true',
|
||||||
default=False,
|
default=False,
|
||||||
@@ -318,6 +334,20 @@ def st_download(parser, args, output_manager):
|
|||||||
st_download_options, st_download_help)
|
st_download_options, st_download_help)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if options.object_threads <= 0:
|
||||||
|
output_manager.error(
|
||||||
|
'ERROR: option --object-threads should be a positive integer.\n\n'
|
||||||
|
'Usage: %s download %s\n%s', BASENAME,
|
||||||
|
st_download_options, st_download_help)
|
||||||
|
return
|
||||||
|
|
||||||
|
if options.container_threads <= 0:
|
||||||
|
output_manager.error(
|
||||||
|
'ERROR: option --container-threads should be a positive integer.'
|
||||||
|
'\n\nUsage: %s download %s\n%s', BASENAME,
|
||||||
|
st_download_options, st_download_help)
|
||||||
|
return
|
||||||
|
|
||||||
_opts = vars(options)
|
_opts = vars(options)
|
||||||
_opts['object_dd_threads'] = options.object_threads
|
_opts['object_dd_threads'] = options.object_threads
|
||||||
with SwiftService(options=_opts) as swift:
|
with SwiftService(options=_opts) as swift:
|
||||||
@@ -803,11 +833,11 @@ def st_upload(parser, args, output_manager):
|
|||||||
parser.add_option(
|
parser.add_option(
|
||||||
'', '--object-threads', type=int, default=10,
|
'', '--object-threads', type=int, default=10,
|
||||||
help='Number of threads to use for uploading full objects. '
|
help='Number of threads to use for uploading full objects. '
|
||||||
'Default is 10.')
|
'Its value must be a positive integer. Default is 10.')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
'', '--segment-threads', type=int, default=10,
|
'', '--segment-threads', type=int, default=10,
|
||||||
help='Number of threads to use for uploading object segments. '
|
help='Number of threads to use for uploading object segments. '
|
||||||
'Default is 10.')
|
'Its value must be a positive integer. Default is 10.')
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
'-H', '--header', action='append', dest='header',
|
'-H', '--header', action='append', dest='header',
|
||||||
default=[], help='Set request headers with the syntax header:value. '
|
default=[], help='Set request headers with the syntax header:value. '
|
||||||
@@ -860,6 +890,20 @@ def st_upload(parser, args, output_manager):
|
|||||||
output_manager.error("segment-size should be positive")
|
output_manager.error("segment-size should be positive")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if options.object_threads <= 0:
|
||||||
|
output_manager.error(
|
||||||
|
'ERROR: option --object-threads should be a positive integer.'
|
||||||
|
'\n\nUsage: %s upload %s\n%s', BASENAME, st_upload_options,
|
||||||
|
st_upload_help)
|
||||||
|
return
|
||||||
|
|
||||||
|
if options.segment_threads <= 0:
|
||||||
|
output_manager.error(
|
||||||
|
'ERROR: option --segment-threads should be a positive integer.'
|
||||||
|
'\n\nUsage: %s upload %s\n%s', BASENAME, st_upload_options,
|
||||||
|
st_upload_help)
|
||||||
|
return
|
||||||
|
|
||||||
_opts = vars(options)
|
_opts = vars(options)
|
||||||
_opts['object_uu_threads'] = options.object_threads
|
_opts['object_uu_threads'] = options.object_threads
|
||||||
with SwiftService(options=_opts) as swift:
|
with SwiftService(options=_opts) as swift:
|
||||||
|
Reference in New Issue
Block a user