diff options
Diffstat (limited to 'swiftclient')
-rw-r--r-- | swiftclient/service.py | 16 | ||||
-rwxr-xr-x | swiftclient/shell.py | 20 |
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 ' |