swift 2.33.0__py2.py3-none-any.whl → 2.34.1__py2.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/account/auditor.py +11 -0
- swift/account/reaper.py +11 -1
- swift/account/replicator.py +22 -0
- swift/account/server.py +12 -1
- swift-2.33.0.data/scripts/swift-account-audit → swift/cli/account_audit.py +6 -2
- swift-2.33.0.data/scripts/swift-config → swift/cli/config.py +1 -1
- swift-2.33.0.data/scripts/swift-dispersion-populate → swift/cli/dispersion_populate.py +6 -2
- swift-2.33.0.data/scripts/swift-drive-audit → swift/cli/drive_audit.py +12 -3
- swift-2.33.0.data/scripts/swift-get-nodes → swift/cli/get_nodes.py +6 -2
- swift/cli/info.py +103 -2
- swift-2.33.0.data/scripts/swift-oldies → swift/cli/oldies.py +6 -3
- swift-2.33.0.data/scripts/swift-orphans → swift/cli/orphans.py +7 -2
- swift/cli/recon_cron.py +5 -5
- swift-2.33.0.data/scripts/swift-reconciler-enqueue → swift/cli/reconciler_enqueue.py +2 -3
- swift/cli/relinker.py +1 -1
- swift/cli/ringbuilder.py +24 -0
- swift/common/db.py +2 -1
- swift/common/db_auditor.py +2 -2
- swift/common/db_replicator.py +6 -0
- swift/common/exceptions.py +12 -0
- swift/common/manager.py +102 -0
- swift/common/memcached.py +6 -13
- swift/common/middleware/account_quotas.py +144 -43
- swift/common/middleware/backend_ratelimit.py +166 -24
- swift/common/middleware/catch_errors.py +1 -3
- swift/common/middleware/cname_lookup.py +3 -5
- swift/common/middleware/container_sync.py +6 -10
- swift/common/middleware/crypto/crypto_utils.py +4 -5
- swift/common/middleware/crypto/decrypter.py +4 -5
- swift/common/middleware/crypto/kms_keymaster.py +2 -1
- swift/common/middleware/listing_formats.py +26 -38
- swift/common/middleware/proxy_logging.py +22 -16
- swift/common/middleware/ratelimit.py +6 -7
- swift/common/middleware/recon.py +6 -7
- swift/common/middleware/s3api/acl_handlers.py +9 -0
- swift/common/middleware/s3api/controllers/multi_upload.py +1 -9
- swift/common/middleware/s3api/controllers/obj.py +20 -1
- swift/common/middleware/s3api/s3api.py +2 -0
- swift/common/middleware/s3api/s3request.py +171 -62
- swift/common/middleware/s3api/s3response.py +35 -6
- swift/common/middleware/s3api/s3token.py +2 -2
- swift/common/middleware/s3api/utils.py +1 -0
- swift/common/middleware/slo.py +153 -52
- swift/common/middleware/tempauth.py +6 -4
- swift/common/middleware/tempurl.py +2 -2
- swift/common/middleware/x_profile/exceptions.py +1 -4
- swift/common/middleware/x_profile/html_viewer.py +10 -11
- swift/common/middleware/x_profile/profile_model.py +1 -2
- swift/common/middleware/xprofile.py +6 -2
- swift/common/request_helpers.py +69 -0
- swift/common/statsd_client.py +207 -0
- swift/common/utils/__init__.py +97 -1635
- swift/common/utils/base.py +138 -0
- swift/common/utils/config.py +443 -0
- swift/common/utils/logs.py +999 -0
- swift/common/wsgi.py +11 -3
- swift/container/auditor.py +11 -0
- swift/container/backend.py +10 -10
- swift/container/reconciler.py +11 -2
- swift/container/replicator.py +22 -1
- swift/container/server.py +12 -1
- swift/container/sharder.py +36 -12
- swift/container/sync.py +11 -1
- swift/container/updater.py +11 -2
- swift/obj/auditor.py +18 -2
- swift/obj/diskfile.py +8 -6
- swift/obj/expirer.py +155 -36
- swift/obj/reconstructor.py +28 -4
- swift/obj/replicator.py +61 -22
- swift/obj/server.py +64 -36
- swift/obj/updater.py +11 -2
- swift/proxy/controllers/base.py +38 -22
- swift/proxy/controllers/obj.py +23 -26
- swift/proxy/server.py +15 -1
- {swift-2.33.0.dist-info → swift-2.34.1.dist-info}/AUTHORS +11 -3
- {swift-2.33.0.dist-info → swift-2.34.1.dist-info}/METADATA +34 -35
- {swift-2.33.0.dist-info → swift-2.34.1.dist-info}/RECORD +82 -108
- {swift-2.33.0.dist-info → swift-2.34.1.dist-info}/WHEEL +1 -1
- {swift-2.33.0.dist-info → swift-2.34.1.dist-info}/entry_points.txt +38 -1
- swift-2.34.1.dist-info/pbr.json +1 -0
- swift-2.33.0.data/scripts/swift-account-auditor +0 -23
- swift-2.33.0.data/scripts/swift-account-info +0 -52
- swift-2.33.0.data/scripts/swift-account-reaper +0 -23
- swift-2.33.0.data/scripts/swift-account-replicator +0 -34
- swift-2.33.0.data/scripts/swift-account-server +0 -23
- swift-2.33.0.data/scripts/swift-container-auditor +0 -23
- swift-2.33.0.data/scripts/swift-container-info +0 -59
- swift-2.33.0.data/scripts/swift-container-reconciler +0 -21
- swift-2.33.0.data/scripts/swift-container-replicator +0 -34
- swift-2.33.0.data/scripts/swift-container-server +0 -23
- swift-2.33.0.data/scripts/swift-container-sharder +0 -37
- swift-2.33.0.data/scripts/swift-container-sync +0 -23
- swift-2.33.0.data/scripts/swift-container-updater +0 -23
- swift-2.33.0.data/scripts/swift-dispersion-report +0 -24
- swift-2.33.0.data/scripts/swift-form-signature +0 -20
- swift-2.33.0.data/scripts/swift-init +0 -119
- swift-2.33.0.data/scripts/swift-object-auditor +0 -29
- swift-2.33.0.data/scripts/swift-object-expirer +0 -33
- swift-2.33.0.data/scripts/swift-object-info +0 -60
- swift-2.33.0.data/scripts/swift-object-reconstructor +0 -33
- swift-2.33.0.data/scripts/swift-object-relinker +0 -23
- swift-2.33.0.data/scripts/swift-object-replicator +0 -37
- swift-2.33.0.data/scripts/swift-object-server +0 -27
- swift-2.33.0.data/scripts/swift-object-updater +0 -23
- swift-2.33.0.data/scripts/swift-proxy-server +0 -23
- swift-2.33.0.data/scripts/swift-recon +0 -24
- swift-2.33.0.data/scripts/swift-recon-cron +0 -24
- swift-2.33.0.data/scripts/swift-ring-builder +0 -37
- swift-2.33.0.data/scripts/swift-ring-builder-analyzer +0 -22
- swift-2.33.0.data/scripts/swift-ring-composer +0 -22
- swift-2.33.0.dist-info/pbr.json +0 -1
- {swift-2.33.0.dist-info → swift-2.34.1.dist-info}/LICENSE +0 -0
- {swift-2.33.0.dist-info → swift-2.34.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,207 @@
|
|
1
|
+
# Copyright (c) 2010-2012 OpenStack Foundation
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
12
|
+
# implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
|
16
|
+
""" Statsd Client """
|
17
|
+
|
18
|
+
import time
|
19
|
+
import warnings
|
20
|
+
from contextlib import closing
|
21
|
+
from random import random
|
22
|
+
|
23
|
+
from eventlet.green import socket
|
24
|
+
import six
|
25
|
+
|
26
|
+
|
27
|
+
def get_statsd_client(conf=None, tail_prefix='', logger=None):
|
28
|
+
"""
|
29
|
+
Get an instance of StatsdClient using config settings.
|
30
|
+
|
31
|
+
**config and defaults**::
|
32
|
+
|
33
|
+
log_statsd_host = (disabled)
|
34
|
+
log_statsd_port = 8125
|
35
|
+
log_statsd_default_sample_rate = 1.0
|
36
|
+
log_statsd_sample_rate_factor = 1.0
|
37
|
+
log_statsd_metric_prefix = (empty-string)
|
38
|
+
|
39
|
+
:param conf: Configuration dict to read settings from
|
40
|
+
:param tail_prefix: tail prefix to pass to statsd client
|
41
|
+
:param logger: stdlib logger instance used by statsd client for logging
|
42
|
+
:return: an instance of ``StatsdClient``
|
43
|
+
|
44
|
+
"""
|
45
|
+
conf = conf or {}
|
46
|
+
|
47
|
+
host = conf.get('log_statsd_host')
|
48
|
+
port = int(conf.get('log_statsd_port', 8125))
|
49
|
+
base_prefix = conf.get('log_statsd_metric_prefix', '')
|
50
|
+
default_sample_rate = float(
|
51
|
+
conf.get('log_statsd_default_sample_rate', 1))
|
52
|
+
sample_rate_factor = float(
|
53
|
+
conf.get('log_statsd_sample_rate_factor', 1))
|
54
|
+
|
55
|
+
return StatsdClient(host, port, base_prefix=base_prefix,
|
56
|
+
tail_prefix=tail_prefix,
|
57
|
+
default_sample_rate=default_sample_rate,
|
58
|
+
sample_rate_factor=sample_rate_factor, logger=logger)
|
59
|
+
|
60
|
+
|
61
|
+
class StatsdClient(object):
|
62
|
+
def __init__(self, host, port, base_prefix='', tail_prefix='',
|
63
|
+
default_sample_rate=1, sample_rate_factor=1, logger=None):
|
64
|
+
self._host = host
|
65
|
+
self._port = port
|
66
|
+
self._base_prefix = base_prefix
|
67
|
+
self._default_sample_rate = default_sample_rate
|
68
|
+
self._sample_rate_factor = sample_rate_factor
|
69
|
+
self.random = random
|
70
|
+
self.logger = logger
|
71
|
+
self._set_prefix(tail_prefix)
|
72
|
+
self._sock_family = self._target = None
|
73
|
+
|
74
|
+
if self._host:
|
75
|
+
self._set_sock_family_and_target(self._host, self._port)
|
76
|
+
|
77
|
+
def _set_sock_family_and_target(self, host, port):
|
78
|
+
# Determine if host is IPv4 or IPv6
|
79
|
+
addr_info = None
|
80
|
+
try:
|
81
|
+
addr_info = socket.getaddrinfo(host, port, socket.AF_INET)
|
82
|
+
self._sock_family = socket.AF_INET
|
83
|
+
except socket.gaierror:
|
84
|
+
try:
|
85
|
+
addr_info = socket.getaddrinfo(host, port, socket.AF_INET6)
|
86
|
+
self._sock_family = socket.AF_INET6
|
87
|
+
except socket.gaierror:
|
88
|
+
# Don't keep the server from starting from what could be a
|
89
|
+
# transient DNS failure. Any hostname will get re-resolved as
|
90
|
+
# necessary in the .sendto() calls.
|
91
|
+
# However, we don't know if we're IPv4 or IPv6 in this case, so
|
92
|
+
# we assume legacy IPv4.
|
93
|
+
self._sock_family = socket.AF_INET
|
94
|
+
|
95
|
+
# NOTE: we use the original host value, not the DNS-resolved one
|
96
|
+
# because if host is a hostname, we don't want to cache the DNS
|
97
|
+
# resolution for the entire lifetime of this process. Let standard
|
98
|
+
# name resolution caching take effect. This should help operators use
|
99
|
+
# DNS trickery if they want.
|
100
|
+
if addr_info is not None:
|
101
|
+
# addr_info is a list of 5-tuples with the following structure:
|
102
|
+
# (family, socktype, proto, canonname, sockaddr)
|
103
|
+
# where sockaddr is the only thing of interest to us, and we only
|
104
|
+
# use the first result. We want to use the originally supplied
|
105
|
+
# host (see note above) and the remainder of the variable-length
|
106
|
+
# sockaddr: IPv4 has (address, port) while IPv6 has (address,
|
107
|
+
# port, flow info, scope id).
|
108
|
+
sockaddr = addr_info[0][-1]
|
109
|
+
self._target = (host,) + (sockaddr[1:])
|
110
|
+
else:
|
111
|
+
self._target = (host, port)
|
112
|
+
|
113
|
+
def _set_prefix(self, tail_prefix):
|
114
|
+
"""
|
115
|
+
Modifies the prefix that is added to metric names. The resulting prefix
|
116
|
+
is the concatenation of the component parts `base_prefix` and
|
117
|
+
`tail_prefix`. Only truthy components are included. Each included
|
118
|
+
component is followed by a period, e.g.::
|
119
|
+
|
120
|
+
<base_prefix>.<tail_prefix>.
|
121
|
+
<tail_prefix>.
|
122
|
+
<base_prefix>.
|
123
|
+
<the empty string>
|
124
|
+
|
125
|
+
Note: this method is expected to be called from the constructor only,
|
126
|
+
but exists to provide backwards compatible functionality for the
|
127
|
+
deprecated set_prefix() method.
|
128
|
+
|
129
|
+
:param tail_prefix: The new value of tail_prefix
|
130
|
+
"""
|
131
|
+
if tail_prefix and self._base_prefix:
|
132
|
+
self._prefix = '.'.join([self._base_prefix, tail_prefix, ''])
|
133
|
+
elif tail_prefix:
|
134
|
+
self._prefix = tail_prefix + '.'
|
135
|
+
elif self._base_prefix:
|
136
|
+
self._prefix = self._base_prefix + '.'
|
137
|
+
else:
|
138
|
+
self._prefix = ''
|
139
|
+
|
140
|
+
def set_prefix(self, tail_prefix):
|
141
|
+
"""
|
142
|
+
This method is deprecated; use the ``tail_prefix`` argument of the
|
143
|
+
constructor when instantiating the class instead.
|
144
|
+
"""
|
145
|
+
warnings.warn(
|
146
|
+
'set_prefix() is deprecated; use the ``tail_prefix`` argument of '
|
147
|
+
'the constructor when instantiating the class instead.',
|
148
|
+
DeprecationWarning, stacklevel=2
|
149
|
+
)
|
150
|
+
self._set_prefix(tail_prefix)
|
151
|
+
|
152
|
+
def _send(self, m_name, m_value, m_type, sample_rate):
|
153
|
+
if not self._host:
|
154
|
+
# StatsD not configured
|
155
|
+
return
|
156
|
+
|
157
|
+
if sample_rate is None:
|
158
|
+
sample_rate = self._default_sample_rate
|
159
|
+
sample_rate = sample_rate * self._sample_rate_factor
|
160
|
+
|
161
|
+
parts = ['%s%s:%s' % (self._prefix, m_name, m_value), m_type]
|
162
|
+
if sample_rate < 1:
|
163
|
+
if self.random() < sample_rate:
|
164
|
+
parts.append('@%s' % (sample_rate,))
|
165
|
+
else:
|
166
|
+
return
|
167
|
+
if six.PY3:
|
168
|
+
parts = [part.encode('utf-8') for part in parts]
|
169
|
+
# Ideally, we'd cache a sending socket in self, but that
|
170
|
+
# results in a socket getting shared by multiple green threads.
|
171
|
+
with closing(self._open_socket()) as sock:
|
172
|
+
try:
|
173
|
+
return sock.sendto(b'|'.join(parts), self._target)
|
174
|
+
except IOError as err:
|
175
|
+
if self.logger:
|
176
|
+
self.logger.warning(
|
177
|
+
'Error sending UDP message to %(target)r: %(err)s',
|
178
|
+
{'target': self._target, 'err': err})
|
179
|
+
|
180
|
+
def _open_socket(self):
|
181
|
+
return socket.socket(self._sock_family, socket.SOCK_DGRAM)
|
182
|
+
|
183
|
+
def update_stats(self, m_name, m_value, sample_rate=None):
|
184
|
+
return self._send(m_name, m_value, 'c', sample_rate)
|
185
|
+
|
186
|
+
def increment(self, metric, sample_rate=None):
|
187
|
+
return self.update_stats(metric, 1, sample_rate)
|
188
|
+
|
189
|
+
def decrement(self, metric, sample_rate=None):
|
190
|
+
return self.update_stats(metric, -1, sample_rate)
|
191
|
+
|
192
|
+
def _timing(self, metric, timing_ms, sample_rate):
|
193
|
+
# This method was added to disagregate timing metrics when testing
|
194
|
+
return self._send(metric, round(timing_ms, 4), 'ms', sample_rate)
|
195
|
+
|
196
|
+
def timing(self, metric, timing_ms, sample_rate=None):
|
197
|
+
return self._timing(metric, timing_ms, sample_rate)
|
198
|
+
|
199
|
+
def timing_since(self, metric, orig_time, sample_rate=None):
|
200
|
+
return self._timing(metric, (time.time() - orig_time) * 1000,
|
201
|
+
sample_rate)
|
202
|
+
|
203
|
+
def transfer_rate(self, metric, elapsed_time, byte_xfer, sample_rate=None):
|
204
|
+
if byte_xfer:
|
205
|
+
return self.timing(metric,
|
206
|
+
elapsed_time * 1000 / byte_xfer * 1000,
|
207
|
+
sample_rate)
|