We noticed a difference in download bandwidth while using
authentication details and pre-auth information for download.
Download using authentication details included authentication
time into the download bandwidth at each call of the function.
This time should have been excluded from download bandwidth.
This patch set is adding a timer variable to the client library.
That allows to accurately measure and store the time of each action.
Then while printing the download bandwith in the swift command
authentication time is excluded from bandwidth.
Change-Id: I63df9023e169f637f120ae9e25dac9c90a4e75a0
Fixes: bug #1197443
* log to debug for successes and info for errors
* remove dead code, neither body or raw_body are sent in kwargs
* include resp.reason and response headers in logging
* remove trailing \n in logging. users who want them can set logging.basicConfig(format=FORMAT)
* add --info option to swift cli
Change-Id: If07af46cb377f3f3d70f6c4284037241d360a8b7
Appends the container's name to the URL displayed, to be used to
replay the queries with curl.
Replaying the curl commands displayed by "swift --debug list
<container>" now works properly.
Example:
$ swift --debug list test-container
...
DEBUG:swiftclient:REQ: curl -i http://10.0.48.134:8080/v1/AUTH_6c554b8dd3d74e44878eddb92caf8687/test-container?format=json -X GET -H ...
...
Change-Id: I7ec33d185fedc44a529c016d38f841fde39d20d0
Closes-Bug: #1238612
I was gunna write a test, but mocking ImportErrors is a PITA, so I decided to
just get my tox py26 working instead. Tests seem to fail/pass as expected
without/with the inline NullHanlder.
Closes-Bug: 1212861
Change-Id: I20207374a77ee9969ab201c3a57e4caf40c02a61
This patch extracts the multi-threading code from bin/swift into
swiftclient/multithreading and adds tests. In particular, this new way
of doing it (with context managers) will prevent non-daemonic threads
from wedging the process when unexpected exceptions happen.
I enabled reporting of which lines, specifically, are not covered by
unit tests (added -m option to "coverage report" in .unittests).
This patch includes a drive-by fix for uploading a segmented file with
--use-slo when that object already exists. A key of "name" was used
instead of "path", raising KeyError.
There's also another drive-by fix for uploading segmented objects with
--use-slo. Commit 874e0e4427b80e1b15b74a1557b73ba9d61443ca regressed
this by removing the capturing of thread-worker results in
QueueFunctionThread.run(). This patch restores that functionality and
the feature (uploading SLO objects).
Change-Id: I0b4f677e4a734e83d1a25088d9a74f7d46384e53
Added log statements in swiftclient/client.py:_retry where exceptions
are being raised.
Fixes bug# 1202229
Change-Id: I727537177849d08bb9603aa884152bdebc62fb85
There were two undocumented parameters in there, one introduced
recently in 6411fd3, and the other some time before.
Change-Id: I3a7d59e1c272b382b035b88ba5495bc1c57a3154
See bug #1188896.
Comparing with Curl and Django, they both refuse carriage returns in
header values, so the request() method on the HTTP(S)Connection instance
returned by swiftclient.client.http_connection() will raise an
InvalidHeadersException if any of the headers to be sent contain a
newline.
Drive-by fix for a couple of header values which were integers instead
of strings (Content-Length getting set to zero).
Fixes bug #1188896
Change-Id: Ic6afdb92882284f843aacb06d20f682ddcb47151
The max-backoff concept prevents the backoff used in _retry to double infinitely (which in turn causes wait times of an hour or more between retries).
As per review, changed code to use min instead.
Fixes: bug #1183542
Change-Id: Ic084f54069b7fa7a33604741487045c5e697ff06
When --os-storage-url is specified on the command-line to bin/swift, it
will override the used storage URL regardless of authentication for both
authentication version 1 and version 2. This can be used to bypass a
load-balancer to hit a specific proxy server for testing/debugging
purposes.
Within the client library, this feature is accessed by passing the
desired storage URL into swiftclient.client.Conection.__init__() via the
os_options keyword argument. For example:
conn = Connection(auth_url, user, key, os_options={
'object_storage_url': 'http://overridden.storage.url/AUTH_foo'})
This patch also adds a dependency on mock>=0.8.0, which is the same as
openstack/swift.
Change-Id: Id2a36ed6abffd65e7762b6beea5bbfc6c036e848
The re-authentication of expired tokens assumed that the 401 would
always occur on the first HTTP at tempt. This fix changes that so that
re-auth is still only attempted once, but no longer has to be on the
first attempt.
Change-Id: I93a1187da3637287a803a59c146256d4f543c9d5
Fixes: bug #1131142
Allows optionally disabling SSL compression. This can significantly
improve HTTPS upload/download performance in some cases -- in particular
when the object is not compressible and you have very high network
bandwidth.
Implements blueprint ssl-compression.
Change-Id: I1260055f9c2e83cdabfeb51aed11b3899bed4d55
The bug is simple: whenever swift uploads to a Swift with SSL,
it uses 100% CPU. It happens because we use HTTPSConnection from
eventlet that loops like that, while holding the interpreter lock.
Now, it could be fixed in eventlet, but let's try something more
natural: drop the eventlet's HTTP client. We do not use green
threads in the client anymore, so it's not like we need it for that.
Note that in most cases clients do not use the BufferedHTTPConnection
either, because it's only installed on Swift server nodes, not on
workstations. Get rid of that too.
bug: 959221
Change-Id: I1eb932779d4171598b3efaa043f817b9c6c995c4
Some mechancical replacement of the deprecated except x,y:
construct with except x as y, which works with any Python
version >= 2.6
Change-Id: Ic245049dc7b408a5c89b9e27dfd2bd7c08acc5b5
If you use the API and supply only preauth values (preauthurl and
preauthtoken), and if either of these are incorrect, a non-descriptive
AttributeError will be thrown and uncaught:
'NoneType' object has no attribute 'find'
The _retry() will fail on the first pass (getting 401), then try
to reauthenticate with non-preauth values. If those are not given,
particularly the auth url, then the urlparse() call will be supplied
None for the url in http_connection() causing the exception above.
This change makes sure that we have an auth url, user and key before
retrying authentication. Given the situation above, a '401 Unauthorized'
ClientException will now be thrown instead of the AttributeError.
Change-Id: Ie1b5bde1e8ff321aa18c0f23dbd2960d6e482236
Also fixed bug with current large objects with segment listing prefixes.
Allow retry for object PUTs when possible.
Change-Id: I0edff127fd5d5c53da33aa7cb76a4f4dc85bf6e6
Changed documentation for chunk_size parameter to indicate
that it can be used only with file like objects.
Also added a UserWarning when using a string contents to inform
that chunk_size will be ignored.
Added a unit test to check whether the warning is working
correctly.
Fixes: bug #1147232
Change-Id: I618ec45520ba81905ce2ead4d61f192d21ae3489
client.py now prints a useful message when trying to use Auth version
2.0 and keystoneclient is not installed.
Fixes bug 1102322
Change-Id: I6ed83610fd6e8c79c2dc5cf05db377a843cab1d5
- Remove PYTHON_SWIFTCLIENT and use --debug making it more consistents
with other openstack clients libraries.
- Fix printing the curl command.
- Don't show the body of the GET objects it could get bad on large
objects and it's an iterator anyway.
- Use -I for showing HEADs (and not -X HEAD).
Change-Id: I954e7d3d795401fc3679725440dec36cdc80af87
Add support to specify a ca certificate bundle to verify
keystone TLS (https) certificates. This only verifies
certificates on the keystone connection, swift https
connections are unchanged.
Change-Id: I14351b405af4fd3d1970ba6656c1282a5d0a1082
If enable this option , swift CLI is allowed to access a keystone
server with self signed certificate.
Change-Id: I5e219fe875b246b68ac51a077e7ff15e95463adf
This patch forces swiftclient to encode to utf-8
all url and headers arguments, to avoid the
UnicodeDecodeError which is raised by '\r\n'.join([])
invoked in htplib.py.
Currently the affected projects are Horizon(upload file
with unicode name) and swiftclient CLI('swift post' with
unicode filename as header)
This is also a follow-up of this review:
https://review.openstack.org/#/c/14216/
I'd still want to hear what the Swift core devs
think of it. Is it better to create a new
AutoEncodingHTTPConnection? Or to handle the connection
creation and make sure there are no unicode and utf-8
string at the same time. If these unicode checks have to
be added in the calling code(Dashboard, CLI), there are
so many places to be added, and also in all new commands
that might be exposed from the API.
Fixes bug 1008940
Change-Id: Ice2aa29024429d3e6f569a88d5cf8b4202537827
Default the authurl/user/key constructor arguments for the
Connection class to None, as these are not required in the
preauthurl/preauthtoken case
Change-Id: I445a5d365212c365ecc691c0a670a226e2b7954a
Add --os-region-name (and OS_REGION_NAME env) to bin/swift
Add region_name to the os_options in Connection class.
bug 1019832
Change-Id: Id8515d97e5351638dce10581c7368f61518e1fa7
- This allows us to delegate all 2.0 authentication directly to the
library without reimplementing ourselves.
- Support reusing a token / storage-url without re-authenticating every
time via the switch os_storage_url os_auth_token.
- Allow auth via tenant_id instead of just tenant_name via the switch
os_tenant_id.
- Refactor a bit to make it easier in the future to add new OS features
(i.e: region).
- Implements blueprint use-keystoneclient-for-swiftclient.
- Fixes bug 1016641.
Change-Id: I532f38a68af884de25326aaac05a2050f5ffa1c7
We allow having the syntax tenant:user in user since this would make
things easier when switching from auth 1.0 to auth 2.0 and not having to
specify a tenant_name.
In the feature we should use the auth functions from keystoneclient and
be done with those changes, we could then auth by user/tenant-ID.
Change-Id: Ie49748105a678fb9369494e77d41d934d57a39a7