summaryrefslogtreecommitdiff
path: root/swiftclient
diff options
context:
space:
mode:
authorZuul <zuul@review.opendev.org>2023-03-22 16:00:44 +0000
committerGerrit Code Review <review@openstack.org>2023-03-22 16:00:44 +0000
commit31c279ff0ea0d1ede1a118d7189dcd009c14e23a (patch)
tree7db9558ffb740364a787ca34c0619b4c458eb2b0 /swiftclient
parentcd82d15506307326afb2497e704df89ef04fb6f6 (diff)
parent6a8675e897e634abd26d993181ac4a45b9cf16f7 (diff)
downloadpython-swiftclient-31c279ff0ea0d1ede1a118d7189dcd009c14e23a.tar.gz
Merge "Use SLO by default for segmented uploads if the cluster supports it"
Diffstat (limited to 'swiftclient')
-rw-r--r--swiftclient/service.py16
-rwxr-xr-xswiftclient/shell.py20
2 files changed, 27 insertions, 9 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py
index e905ea6..dd71409 100644
--- a/swiftclient/service.py
+++ b/swiftclient/service.py
@@ -196,7 +196,7 @@ _default_global_options = _build_default_global_options()
_default_local_options = {
'sync_to': None,
'sync_key': None,
- 'use_slo': False,
+ 'use_slo': None,
'segment_size': None,
'segment_container': None,
'leave_segments': False,
@@ -1467,7 +1467,7 @@ class SwiftService:
'meta': [],
'header': [],
'segment_size': None,
- 'use_slo': False,
+ 'use_slo': True,
'segment_container': None,
'leave_segments': False,
'changed': None,
@@ -1493,6 +1493,18 @@ class SwiftService:
except ValueError:
raise SwiftError('Segment size should be an integer value')
+ if segment_size and options['use_slo'] is None:
+ try:
+ cap_result = self.capabilities()
+ except ClientException:
+ # pre-info swift, maybe? assume no slo middleware
+ options['use_slo'] = False
+ else:
+ if not cap_result['success']:
+ options['use_slo'] = False
+ else:
+ options['use_slo'] = 'slo' in cap_result['capabilities']
+
# Incase we have a psudeo-folder path for <container> arg, derive
# the container name from the top path and prepend the rest to
# the object name. (same as passing --object-name).
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index dc68aa9..69f9481 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -978,8 +978,8 @@ def st_copy(parser, args, output_manager, return_parser=False):
st_upload_options = '''[--changed] [--skip-identical] [--segment-size <size>]
[--segment-container <container>] [--leave-segments]
[--object-threads <thread>] [--segment-threads <threads>]
- [--meta <name:value>] [--header <header>]
- [--use-slo] [--ignore-checksum] [--skip-container-put]
+ [--meta <name:value>] [--header <header>] [--use-slo]
+ [--use-dlo] [--ignore-checksum] [--skip-container-put]
[--object-name <object-name>]
<container> <file_or_directory> [<file_or_directory>] [...]
'''
@@ -1024,8 +1024,11 @@ Optional arguments:
repeated. Example: -H "content-type:text/plain"
-H "Content-Length: 4000".
--use-slo When used in conjunction with --segment-size it will
- create a Static Large Object instead of the default
- Dynamic Large Object.
+ create a Static Large Object. Deprecated; this is now
+ the default behavior when the cluster supports it.
+ --use-dlo When used in conjunction with --segment-size it will
+ create a Dynamic Large Object. May be useful with old
+ swift clusters.
--ignore-checksum Turn off checksum validation for uploads.
--skip-container-put Assume all necessary containers already exist; don't
automatically try to create them.
@@ -1087,10 +1090,13 @@ def st_upload(parser, args, output_manager, return_parser=False):
' This option may be repeated. Example: -H "content-type:text/plain" '
'-H "Content-Length: 4000"')
parser.add_argument(
- '--use-slo', action='store_true', default=False,
+ '--use-slo', action='store_true', default=None,
help='When used in conjunction with --segment-size, it will '
- 'create a Static Large Object instead of the default '
- 'Dynamic Large Object.')
+ 'create a Static Large Object.')
+ parser.add_argument(
+ '--use-dlo', action='store_false', dest="use_slo", default=None,
+ help='When used in conjunction with --segment-size, it will '
+ 'create a Dynamic Large Object.')
parser.add_argument(
'--object-name', dest='object_name',
help='Upload file and name object to <object-name> or upload dir and '