swift 2.23.3__py3-none-any.whl → 2.35.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- swift/__init__.py +29 -50
- swift/account/auditor.py +21 -118
- swift/account/backend.py +33 -28
- swift/account/reaper.py +37 -28
- swift/account/replicator.py +22 -0
- swift/account/server.py +60 -26
- swift/account/utils.py +28 -11
- swift-2.23.3.data/scripts/swift-account-audit → swift/cli/account_audit.py +23 -13
- swift-2.23.3.data/scripts/swift-config → swift/cli/config.py +2 -2
- swift/cli/container_deleter.py +5 -11
- swift-2.23.3.data/scripts/swift-dispersion-populate → swift/cli/dispersion_populate.py +8 -7
- swift/cli/dispersion_report.py +10 -9
- swift-2.23.3.data/scripts/swift-drive-audit → swift/cli/drive_audit.py +63 -21
- swift/cli/form_signature.py +3 -7
- swift-2.23.3.data/scripts/swift-get-nodes → swift/cli/get_nodes.py +8 -2
- swift/cli/info.py +154 -14
- swift/cli/manage_shard_ranges.py +705 -37
- swift-2.23.3.data/scripts/swift-oldies → swift/cli/oldies.py +25 -14
- swift-2.23.3.data/scripts/swift-orphans → swift/cli/orphans.py +7 -3
- swift/cli/recon.py +196 -67
- swift-2.23.3.data/scripts/swift-recon-cron → swift/cli/recon_cron.py +17 -20
- swift-2.23.3.data/scripts/swift-reconciler-enqueue → swift/cli/reconciler_enqueue.py +2 -3
- swift/cli/relinker.py +807 -126
- swift/cli/reload.py +135 -0
- swift/cli/ringbuilder.py +217 -20
- swift/cli/ringcomposer.py +0 -1
- swift/cli/shard-info.py +4 -3
- swift/common/base_storage_server.py +9 -20
- swift/common/bufferedhttp.py +48 -74
- swift/common/constraints.py +20 -15
- swift/common/container_sync_realms.py +9 -11
- swift/common/daemon.py +25 -8
- swift/common/db.py +195 -128
- swift/common/db_auditor.py +168 -0
- swift/common/db_replicator.py +95 -55
- swift/common/digest.py +141 -0
- swift/common/direct_client.py +144 -33
- swift/common/error_limiter.py +93 -0
- swift/common/exceptions.py +25 -1
- swift/common/header_key_dict.py +2 -9
- swift/common/http_protocol.py +373 -0
- swift/common/internal_client.py +129 -59
- swift/common/linkat.py +3 -4
- swift/common/manager.py +284 -67
- swift/common/memcached.py +390 -145
- swift/common/middleware/__init__.py +4 -0
- swift/common/middleware/account_quotas.py +211 -46
- swift/common/middleware/acl.py +3 -8
- swift/common/middleware/backend_ratelimit.py +230 -0
- swift/common/middleware/bulk.py +22 -34
- swift/common/middleware/catch_errors.py +1 -3
- swift/common/middleware/cname_lookup.py +6 -11
- swift/common/middleware/container_quotas.py +1 -1
- swift/common/middleware/container_sync.py +39 -17
- swift/common/middleware/copy.py +12 -0
- swift/common/middleware/crossdomain.py +22 -9
- swift/common/middleware/crypto/__init__.py +2 -1
- swift/common/middleware/crypto/crypto_utils.py +11 -15
- swift/common/middleware/crypto/decrypter.py +28 -11
- swift/common/middleware/crypto/encrypter.py +12 -17
- swift/common/middleware/crypto/keymaster.py +8 -15
- swift/common/middleware/crypto/kms_keymaster.py +2 -1
- swift/common/middleware/dlo.py +15 -11
- swift/common/middleware/domain_remap.py +5 -4
- swift/common/middleware/etag_quoter.py +128 -0
- swift/common/middleware/formpost.py +73 -70
- swift/common/middleware/gatekeeper.py +8 -1
- swift/common/middleware/keystoneauth.py +33 -3
- swift/common/middleware/list_endpoints.py +4 -4
- swift/common/middleware/listing_formats.py +85 -49
- swift/common/middleware/memcache.py +4 -95
- swift/common/middleware/name_check.py +3 -2
- swift/common/middleware/proxy_logging.py +160 -92
- swift/common/middleware/ratelimit.py +17 -10
- swift/common/middleware/read_only.py +6 -4
- swift/common/middleware/recon.py +59 -22
- swift/common/middleware/s3api/acl_handlers.py +25 -3
- swift/common/middleware/s3api/acl_utils.py +6 -1
- swift/common/middleware/s3api/controllers/__init__.py +6 -0
- swift/common/middleware/s3api/controllers/acl.py +3 -2
- swift/common/middleware/s3api/controllers/bucket.py +242 -137
- swift/common/middleware/s3api/controllers/logging.py +2 -2
- swift/common/middleware/s3api/controllers/multi_delete.py +43 -20
- swift/common/middleware/s3api/controllers/multi_upload.py +219 -133
- swift/common/middleware/s3api/controllers/obj.py +112 -8
- swift/common/middleware/s3api/controllers/object_lock.py +44 -0
- swift/common/middleware/s3api/controllers/s3_acl.py +2 -2
- swift/common/middleware/s3api/controllers/tagging.py +57 -0
- swift/common/middleware/s3api/controllers/versioning.py +36 -7
- swift/common/middleware/s3api/etree.py +22 -9
- swift/common/middleware/s3api/exception.py +0 -4
- swift/common/middleware/s3api/s3api.py +113 -41
- swift/common/middleware/s3api/s3request.py +384 -218
- swift/common/middleware/s3api/s3response.py +126 -23
- swift/common/middleware/s3api/s3token.py +16 -17
- swift/common/middleware/s3api/schema/delete.rng +1 -1
- swift/common/middleware/s3api/subresource.py +7 -10
- swift/common/middleware/s3api/utils.py +27 -10
- swift/common/middleware/slo.py +665 -358
- swift/common/middleware/staticweb.py +64 -37
- swift/common/middleware/symlink.py +51 -18
- swift/common/middleware/tempauth.py +76 -58
- swift/common/middleware/tempurl.py +191 -173
- swift/common/middleware/versioned_writes/__init__.py +51 -0
- swift/common/middleware/{versioned_writes.py → versioned_writes/legacy.py} +27 -26
- swift/common/middleware/versioned_writes/object_versioning.py +1482 -0
- swift/common/middleware/x_profile/exceptions.py +1 -4
- swift/common/middleware/x_profile/html_viewer.py +18 -19
- swift/common/middleware/x_profile/profile_model.py +1 -2
- swift/common/middleware/xprofile.py +10 -10
- swift-2.23.3.data/scripts/swift-container-server → swift/common/recon.py +13 -8
- swift/common/registry.py +147 -0
- swift/common/request_helpers.py +324 -57
- swift/common/ring/builder.py +67 -25
- swift/common/ring/composite_builder.py +1 -1
- swift/common/ring/ring.py +177 -51
- swift/common/ring/utils.py +1 -1
- swift/common/splice.py +10 -6
- swift/common/statsd_client.py +205 -0
- swift/common/storage_policy.py +49 -44
- swift/common/swob.py +86 -102
- swift/common/{utils.py → utils/__init__.py} +2163 -2772
- swift/common/utils/base.py +131 -0
- swift/common/utils/config.py +433 -0
- swift/common/utils/ipaddrs.py +256 -0
- swift/common/utils/libc.py +345 -0
- swift/common/utils/logs.py +859 -0
- swift/common/utils/timestamp.py +412 -0
- swift/common/wsgi.py +553 -535
- swift/container/auditor.py +14 -100
- swift/container/backend.py +490 -231
- swift/container/reconciler.py +126 -37
- swift/container/replicator.py +96 -22
- swift/container/server.py +358 -165
- swift/container/sharder.py +1540 -684
- swift/container/sync.py +94 -88
- swift/container/updater.py +53 -32
- swift/obj/auditor.py +153 -35
- swift/obj/diskfile.py +466 -217
- swift/obj/expirer.py +406 -124
- swift/obj/mem_diskfile.py +7 -4
- swift/obj/mem_server.py +1 -0
- swift/obj/reconstructor.py +523 -262
- swift/obj/replicator.py +249 -188
- swift/obj/server.py +207 -122
- swift/obj/ssync_receiver.py +145 -85
- swift/obj/ssync_sender.py +113 -54
- swift/obj/updater.py +652 -139
- swift/obj/watchers/__init__.py +0 -0
- swift/obj/watchers/dark_data.py +213 -0
- swift/proxy/controllers/account.py +11 -11
- swift/proxy/controllers/base.py +848 -604
- swift/proxy/controllers/container.py +433 -92
- swift/proxy/controllers/info.py +3 -2
- swift/proxy/controllers/obj.py +1000 -489
- swift/proxy/server.py +185 -112
- {swift-2.23.3.dist-info → swift-2.35.0.dist-info}/AUTHORS +58 -11
- {swift-2.23.3.dist-info → swift-2.35.0.dist-info}/METADATA +51 -56
- swift-2.35.0.dist-info/RECORD +201 -0
- {swift-2.23.3.dist-info → swift-2.35.0.dist-info}/WHEEL +1 -1
- {swift-2.23.3.dist-info → swift-2.35.0.dist-info}/entry_points.txt +43 -0
- swift-2.35.0.dist-info/pbr.json +1 -0
- swift/locale/de/LC_MESSAGES/swift.po +0 -1216
- swift/locale/en_GB/LC_MESSAGES/swift.po +0 -1207
- swift/locale/es/LC_MESSAGES/swift.po +0 -1085
- swift/locale/fr/LC_MESSAGES/swift.po +0 -909
- swift/locale/it/LC_MESSAGES/swift.po +0 -894
- swift/locale/ja/LC_MESSAGES/swift.po +0 -965
- swift/locale/ko_KR/LC_MESSAGES/swift.po +0 -964
- swift/locale/pt_BR/LC_MESSAGES/swift.po +0 -881
- swift/locale/ru/LC_MESSAGES/swift.po +0 -891
- swift/locale/tr_TR/LC_MESSAGES/swift.po +0 -832
- swift/locale/zh_CN/LC_MESSAGES/swift.po +0 -833
- swift/locale/zh_TW/LC_MESSAGES/swift.po +0 -838
- swift-2.23.3.data/scripts/swift-account-auditor +0 -23
- swift-2.23.3.data/scripts/swift-account-info +0 -51
- swift-2.23.3.data/scripts/swift-account-reaper +0 -23
- swift-2.23.3.data/scripts/swift-account-replicator +0 -34
- swift-2.23.3.data/scripts/swift-account-server +0 -23
- swift-2.23.3.data/scripts/swift-container-auditor +0 -23
- swift-2.23.3.data/scripts/swift-container-info +0 -55
- swift-2.23.3.data/scripts/swift-container-reconciler +0 -21
- swift-2.23.3.data/scripts/swift-container-replicator +0 -34
- swift-2.23.3.data/scripts/swift-container-sharder +0 -37
- swift-2.23.3.data/scripts/swift-container-sync +0 -23
- swift-2.23.3.data/scripts/swift-container-updater +0 -23
- swift-2.23.3.data/scripts/swift-dispersion-report +0 -24
- swift-2.23.3.data/scripts/swift-form-signature +0 -20
- swift-2.23.3.data/scripts/swift-init +0 -119
- swift-2.23.3.data/scripts/swift-object-auditor +0 -29
- swift-2.23.3.data/scripts/swift-object-expirer +0 -33
- swift-2.23.3.data/scripts/swift-object-info +0 -60
- swift-2.23.3.data/scripts/swift-object-reconstructor +0 -33
- swift-2.23.3.data/scripts/swift-object-relinker +0 -41
- swift-2.23.3.data/scripts/swift-object-replicator +0 -37
- swift-2.23.3.data/scripts/swift-object-server +0 -27
- swift-2.23.3.data/scripts/swift-object-updater +0 -23
- swift-2.23.3.data/scripts/swift-proxy-server +0 -23
- swift-2.23.3.data/scripts/swift-recon +0 -24
- swift-2.23.3.data/scripts/swift-ring-builder +0 -24
- swift-2.23.3.data/scripts/swift-ring-builder-analyzer +0 -22
- swift-2.23.3.data/scripts/swift-ring-composer +0 -22
- swift-2.23.3.dist-info/RECORD +0 -220
- swift-2.23.3.dist-info/pbr.json +0 -1
- {swift-2.23.3.dist-info → swift-2.35.0.dist-info}/LICENSE +0 -0
- {swift-2.23.3.dist-info → swift-2.35.0.dist-info}/top_level.txt +0 -0
swift/common/internal_client.py
CHANGED
@@ -13,29 +13,26 @@
|
|
13
13
|
# See the License for the specific language governing permissions and
|
14
14
|
# limitations under the License.
|
15
15
|
|
16
|
-
from eventlet import sleep, Timeout
|
17
|
-
from eventlet.green import
|
16
|
+
from eventlet import sleep, Timeout, spawn
|
17
|
+
from eventlet.green import socket
|
18
|
+
from eventlet.green.http import client as http_client
|
19
|
+
from eventlet.green.urllib import request as urllib_request
|
18
20
|
import json
|
19
|
-
import
|
20
|
-
from six.moves import range
|
21
|
-
from six.moves import urllib
|
21
|
+
import urllib
|
22
22
|
import struct
|
23
|
-
from sys import
|
23
|
+
from sys import exit
|
24
24
|
import zlib
|
25
25
|
from time import gmtime, strftime, time
|
26
26
|
from zlib import compressobj
|
27
27
|
|
28
28
|
from swift.common.exceptions import ClientException
|
29
29
|
from swift.common.http import (HTTP_NOT_FOUND, HTTP_MULTIPLE_CHOICES,
|
30
|
-
is_server_error)
|
30
|
+
is_client_error, is_server_error)
|
31
|
+
from swift.common.middleware.gatekeeper import GatekeeperMiddleware
|
32
|
+
from swift.common.request_helpers import USE_REPLICATION_NETWORK_HEADER
|
31
33
|
from swift.common.swob import Request, bytes_to_wsgi
|
32
|
-
from swift.common.utils import quote,
|
33
|
-
from swift.common.wsgi import loadapp
|
34
|
-
|
35
|
-
if six.PY3:
|
36
|
-
from eventlet.green.urllib import request as urllib2
|
37
|
-
else:
|
38
|
-
from eventlet.green import urllib2
|
34
|
+
from swift.common.utils import quote, close_if_possible, drain_and_close
|
35
|
+
from swift.common.wsgi import loadapp
|
39
36
|
|
40
37
|
|
41
38
|
class UnexpectedResponse(Exception):
|
@@ -125,8 +122,6 @@ class CompressingFileReader(object):
|
|
125
122
|
return chunk
|
126
123
|
raise StopIteration
|
127
124
|
|
128
|
-
next = __next__
|
129
|
-
|
130
125
|
def seek(self, offset, whence=0):
|
131
126
|
if not (offset == 0 and whence == 0):
|
132
127
|
raise NotImplementedError('Seek implemented on offset 0 only')
|
@@ -143,22 +138,48 @@ class InternalClient(object):
|
|
143
138
|
:param user_agent: User agent to be sent to requests to Swift.
|
144
139
|
:param request_tries: Number of tries before InternalClient.make_request()
|
145
140
|
gives up.
|
141
|
+
:param use_replication_network: Force the client to use the replication
|
142
|
+
network over the cluster.
|
143
|
+
:param global_conf: a dict of options to update the loaded proxy config.
|
144
|
+
Options in ``global_conf`` will override those in ``conf_path`` except
|
145
|
+
where the ``conf_path`` option is preceded by ``set``.
|
146
|
+
:param app: Optionally provide a WSGI app for the internal client to use.
|
146
147
|
"""
|
147
148
|
|
148
149
|
def __init__(self, conf_path, user_agent, request_tries,
|
149
|
-
|
150
|
+
use_replication_network=False, global_conf=None, app=None,
|
151
|
+
**kwargs):
|
150
152
|
if request_tries < 1:
|
151
153
|
raise ValueError('request_tries must be positive')
|
152
|
-
|
153
|
-
|
154
|
-
|
154
|
+
# Internal clients don't use the gatekeeper and the pipeline remains
|
155
|
+
# static so we never allow anything to modify the proxy pipeline.
|
156
|
+
if kwargs.get('allow_modify_pipeline'):
|
157
|
+
raise ValueError("'allow_modify_pipeline' is no longer supported")
|
158
|
+
self.app = app or loadapp(conf_path, global_conf=global_conf,
|
159
|
+
allow_modify_pipeline=False,)
|
160
|
+
self.check_gatekeeper_not_loaded(self.app)
|
161
|
+
self.user_agent = \
|
162
|
+
self.app._pipeline_final_app.backend_user_agent = user_agent
|
155
163
|
self.request_tries = request_tries
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
164
|
+
self.use_replication_network = use_replication_network
|
165
|
+
self.get_object_ring = self.app._pipeline_final_app.get_object_ring
|
166
|
+
self.container_ring = self.app._pipeline_final_app.container_ring
|
167
|
+
self.account_ring = self.app._pipeline_final_app.account_ring
|
168
|
+
self.auto_create_account_prefix = \
|
169
|
+
self.app._pipeline_final_app.auto_create_account_prefix
|
170
|
+
|
171
|
+
@staticmethod
|
172
|
+
def check_gatekeeper_not_loaded(app):
|
173
|
+
# the Gatekeeper middleware would prevent an InternalClient passing
|
174
|
+
# X-Backend-* headers to the proxy app, so ensure it's not present
|
175
|
+
try:
|
176
|
+
for app in app._pipeline:
|
177
|
+
if isinstance(app, GatekeeperMiddleware):
|
178
|
+
raise ValueError(
|
179
|
+
"Gatekeeper middleware is not allowed in the "
|
180
|
+
"InternalClient proxy pipeline")
|
181
|
+
except AttributeError:
|
182
|
+
pass
|
162
183
|
|
163
184
|
def make_request(
|
164
185
|
self, method, path, headers, acceptable_statuses, body_file=None,
|
@@ -184,8 +205,12 @@ class InternalClient(object):
|
|
184
205
|
|
185
206
|
headers = dict(headers)
|
186
207
|
headers['user-agent'] = self.user_agent
|
208
|
+
headers.setdefault('x-backend-allow-reserved-names', 'true')
|
209
|
+
if self.use_replication_network:
|
210
|
+
headers.setdefault(USE_REPLICATION_NETWORK_HEADER, 'true')
|
211
|
+
|
187
212
|
for attempt in range(self.request_tries):
|
188
|
-
resp =
|
213
|
+
resp = err = None
|
189
214
|
req = Request.blank(
|
190
215
|
path, environ={'REQUEST_METHOD': method}, headers=headers)
|
191
216
|
if body_file is not None:
|
@@ -195,9 +220,10 @@ class InternalClient(object):
|
|
195
220
|
if params:
|
196
221
|
req.params = params
|
197
222
|
try:
|
198
|
-
|
199
|
-
|
200
|
-
|
223
|
+
# execute in a separate greenthread to not polute corolocals
|
224
|
+
resp = spawn(req.get_response, self.app).wait()
|
225
|
+
except (Exception, Timeout) as e:
|
226
|
+
err = e
|
201
227
|
else:
|
202
228
|
if resp.status_int in acceptable_statuses or \
|
203
229
|
resp.status_int // 100 in acceptable_statuses:
|
@@ -208,13 +234,13 @@ class InternalClient(object):
|
|
208
234
|
# sleep only between tries, not after each one
|
209
235
|
if attempt < self.request_tries - 1:
|
210
236
|
if resp:
|
211
|
-
#
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
237
|
+
# for non 2XX requests it's safe and useful to drain
|
238
|
+
# the response body so we log the correct status code
|
239
|
+
if resp.status_int // 100 != 2:
|
240
|
+
drain_and_close(resp)
|
241
|
+
else:
|
242
|
+
# Just close; the 499 is appropriate
|
243
|
+
close_if_possible(resp.app_iter)
|
218
244
|
sleep(2 ** (attempt + 1))
|
219
245
|
if resp:
|
220
246
|
msg = 'Unexpected response: %s' % resp.status
|
@@ -223,9 +249,14 @@ class InternalClient(object):
|
|
223
249
|
# non 2XX responses
|
224
250
|
msg += ' (%s)' % resp.body
|
225
251
|
raise UnexpectedResponse(msg, resp)
|
226
|
-
if
|
227
|
-
|
228
|
-
|
252
|
+
if err:
|
253
|
+
raise err
|
254
|
+
|
255
|
+
def handle_request(self, *args, **kwargs):
|
256
|
+
resp = self.make_request(*args, **kwargs)
|
257
|
+
# Drain the response body to prevent unexpected disconnect
|
258
|
+
# in proxy-server
|
259
|
+
drain_and_close(resp)
|
229
260
|
|
230
261
|
def _get_metadata(
|
231
262
|
self, path, metadata_prefix='', acceptable_statuses=(2,),
|
@@ -356,7 +387,7 @@ class InternalClient(object):
|
|
356
387
|
headers[k] = v
|
357
388
|
else:
|
358
389
|
headers['%s%s' % (metadata_prefix, k)] = v
|
359
|
-
self.
|
390
|
+
self.handle_request('POST', path, headers, acceptable_statuses)
|
360
391
|
|
361
392
|
# account methods
|
362
393
|
|
@@ -384,6 +415,34 @@ class InternalClient(object):
|
|
384
415
|
return self._iter_items(path, marker, end_marker, prefix,
|
385
416
|
acceptable_statuses)
|
386
417
|
|
418
|
+
def create_account(self, account):
|
419
|
+
"""
|
420
|
+
Creates an account.
|
421
|
+
|
422
|
+
:param account: Account to create.
|
423
|
+
:raises UnexpectedResponse: Exception raised when requests fail
|
424
|
+
to get a response with an acceptable status
|
425
|
+
:raises Exception: Exception is raised when code fails in an
|
426
|
+
unexpected way.
|
427
|
+
"""
|
428
|
+
path = self.make_path(account)
|
429
|
+
self.handle_request('PUT', path, {}, (201, 202))
|
430
|
+
|
431
|
+
def delete_account(self, account, acceptable_statuses=(2, HTTP_NOT_FOUND)):
|
432
|
+
"""
|
433
|
+
Deletes an account.
|
434
|
+
|
435
|
+
:param account: Account to delete.
|
436
|
+
:param acceptable_statuses: List of status for valid responses,
|
437
|
+
defaults to (2, HTTP_NOT_FOUND).
|
438
|
+
:raises UnexpectedResponse: Exception raised when requests fail
|
439
|
+
to get a response with an acceptable status
|
440
|
+
:raises Exception: Exception is raised when code fails in an
|
441
|
+
unexpected way.
|
442
|
+
"""
|
443
|
+
path = self.make_path(account)
|
444
|
+
self.handle_request('DELETE', path, {}, acceptable_statuses)
|
445
|
+
|
387
446
|
def get_account_info(
|
388
447
|
self, account, acceptable_statuses=(2, HTTP_NOT_FOUND)):
|
389
448
|
"""
|
@@ -496,10 +555,11 @@ class InternalClient(object):
|
|
496
555
|
|
497
556
|
headers = headers or {}
|
498
557
|
path = self.make_path(account, container)
|
499
|
-
self.
|
558
|
+
self.handle_request('PUT', path, headers, acceptable_statuses)
|
500
559
|
|
501
560
|
def delete_container(
|
502
|
-
self, account, container,
|
561
|
+
self, account, container, headers=None,
|
562
|
+
acceptable_statuses=(2, HTTP_NOT_FOUND)):
|
503
563
|
"""
|
504
564
|
Deletes a container.
|
505
565
|
|
@@ -514,8 +574,9 @@ class InternalClient(object):
|
|
514
574
|
unexpected way.
|
515
575
|
"""
|
516
576
|
|
577
|
+
headers = headers or {}
|
517
578
|
path = self.make_path(account, container)
|
518
|
-
self.
|
579
|
+
self.handle_request('DELETE', path, headers, acceptable_statuses)
|
519
580
|
|
520
581
|
def get_container_metadata(
|
521
582
|
self, account, container, metadata_prefix='',
|
@@ -618,7 +679,8 @@ class InternalClient(object):
|
|
618
679
|
"""
|
619
680
|
|
620
681
|
path = self.make_path(account, container, obj)
|
621
|
-
self.
|
682
|
+
self.handle_request('DELETE', path, (headers or {}),
|
683
|
+
acceptable_statuses)
|
622
684
|
|
623
685
|
def get_object_metadata(
|
624
686
|
self, account, container, obj, metadata_prefix='',
|
@@ -647,7 +709,7 @@ class InternalClient(object):
|
|
647
709
|
return self._get_metadata(path, metadata_prefix, acceptable_statuses,
|
648
710
|
headers=headers, params=params)
|
649
711
|
|
650
|
-
def get_object(self, account, container, obj, headers,
|
712
|
+
def get_object(self, account, container, obj, headers=None,
|
651
713
|
acceptable_statuses=(2,), params=None):
|
652
714
|
"""
|
653
715
|
Gets an object.
|
@@ -749,13 +811,17 @@ class InternalClient(object):
|
|
749
811
|
path, metadata, metadata_prefix, acceptable_statuses)
|
750
812
|
|
751
813
|
def upload_object(
|
752
|
-
self, fobj, account, container, obj, headers=None
|
814
|
+
self, fobj, account, container, obj, headers=None,
|
815
|
+
acceptable_statuses=(2,), params=None):
|
753
816
|
"""
|
754
817
|
:param fobj: File object to read object's content from.
|
755
818
|
:param account: The object's account.
|
756
819
|
:param container: The object's container.
|
757
820
|
:param obj: The object.
|
758
821
|
:param headers: Headers to send with request, defaults to empty dict.
|
822
|
+
:param acceptable_statuses: List of acceptable statuses for request.
|
823
|
+
:param params: A dict of params to be set in request query string,
|
824
|
+
defaults to None.
|
759
825
|
|
760
826
|
:raises UnexpectedResponse: Exception raised when requests fail
|
761
827
|
to get a response with an acceptable status
|
@@ -767,16 +833,17 @@ class InternalClient(object):
|
|
767
833
|
if 'Content-Length' not in headers:
|
768
834
|
headers['Transfer-Encoding'] = 'chunked'
|
769
835
|
path = self.make_path(account, container, obj)
|
770
|
-
self.
|
836
|
+
self.handle_request('PUT', path, headers, acceptable_statuses, fobj,
|
837
|
+
params=params)
|
771
838
|
|
772
839
|
|
773
840
|
def get_auth(url, user, key, auth_version='1.0', **kwargs):
|
774
841
|
if auth_version != '1.0':
|
775
842
|
exit('ERROR: swiftclient missing, only auth v1.0 supported')
|
776
|
-
req =
|
843
|
+
req = urllib_request.Request(url)
|
777
844
|
req.add_header('X-Auth-User', user)
|
778
845
|
req.add_header('X-Auth-Key', key)
|
779
|
-
conn =
|
846
|
+
conn = urllib_request.urlopen(req)
|
780
847
|
headers = conn.info()
|
781
848
|
return (
|
782
849
|
headers.getheader('X-Storage-Url'),
|
@@ -839,12 +906,12 @@ class SimpleClient(object):
|
|
839
906
|
|
840
907
|
url += '?' + '&'.join(params)
|
841
908
|
|
842
|
-
req =
|
909
|
+
req = urllib_request.Request(url, headers=headers, data=contents)
|
843
910
|
if proxy:
|
844
911
|
proxy = urllib.parse.urlparse(proxy)
|
845
912
|
req.set_proxy(proxy.netloc, proxy.scheme)
|
846
913
|
req.get_method = lambda: method
|
847
|
-
conn =
|
914
|
+
conn = urllib_request.urlopen(req, timeout=timeout)
|
848
915
|
body = conn.read()
|
849
916
|
info = conn.info()
|
850
917
|
try:
|
@@ -886,14 +953,17 @@ class SimpleClient(object):
|
|
886
953
|
self.attempts += 1
|
887
954
|
try:
|
888
955
|
return self.base_request(method, **kwargs)
|
889
|
-
except
|
890
|
-
|
956
|
+
except urllib_request.HTTPError as err:
|
957
|
+
if is_client_error(err.getcode() or 500):
|
958
|
+
raise ClientException('Client error',
|
959
|
+
http_status=err.getcode())
|
960
|
+
elif self.attempts > retries:
|
961
|
+
raise ClientException('Raise too many retries',
|
962
|
+
http_status=err.getcode())
|
963
|
+
except (socket.error, http_client.HTTPException,
|
964
|
+
urllib_request.URLError):
|
891
965
|
if self.attempts > retries:
|
892
|
-
|
893
|
-
raise ClientException('Raise too many retries',
|
894
|
-
http_status=err.getcode())
|
895
|
-
else:
|
896
|
-
raise
|
966
|
+
raise
|
897
967
|
sleep(backoff)
|
898
968
|
backoff = min(backoff * 2, self.max_backoff)
|
899
969
|
|
swift/common/linkat.py
CHANGED
@@ -17,8 +17,6 @@ import os
|
|
17
17
|
import ctypes
|
18
18
|
from ctypes.util import find_library
|
19
19
|
|
20
|
-
import six
|
21
|
-
|
22
20
|
__all__ = ['linkat']
|
23
21
|
|
24
22
|
|
@@ -72,12 +70,13 @@ class Linkat(object):
|
|
72
70
|
if not isinstance(olddirfd, int) or not isinstance(newdirfd, int):
|
73
71
|
raise TypeError("fd must be an integer.")
|
74
72
|
|
75
|
-
if isinstance(oldpath,
|
73
|
+
if isinstance(oldpath, str):
|
76
74
|
oldpath = oldpath.encode('utf8')
|
77
|
-
if isinstance(newpath,
|
75
|
+
if isinstance(newpath, str):
|
78
76
|
newpath = newpath.encode('utf8')
|
79
77
|
|
80
78
|
return self._c_linkat(olddirfd, oldpath, newdirfd, newpath, flags)
|
81
79
|
|
80
|
+
|
82
81
|
linkat = Linkat()
|
83
82
|
del Linkat
|