562 Commits

Author SHA1 Message Date
Min Min Ren
61880c6f98 Fix the http request headers being overwritten in logging
Fix the http request headers in put_object being overwritten in logging

Change-Id: Id0d1e36561a61ed1ce30d93c801ec32f058a6fa4
Closes-bug: #1501292
2016-01-14 15:45:22 +00:00
Jenkins
a564eb0e4c Merge "Unification of manpages and docstrings" 2015-12-01 13:03:05 +00:00
Jenkins
20731f4687 Merge "improve readme contents" 2015-12-01 02:13:17 +00:00
Jenkins
e675e1e938 Merge "Suppress iso8601 logging from --debug output" 2015-12-01 00:31:54 +00:00
Alistair Coles
562f386e93 Update mailmap
Change-Id: I0531928b531694008520298bea7d37b73216787e
2015-11-24 16:31:44 +00:00
Jenkins
2b42fefdbf Merge "Add py35 to default tox environments" 2015-11-23 18:46:45 +00:00
ricolin
7f304337a0 improve readme contents
Add more information in README.rst

Change-Id: I9fb9bea648fb1d1e26b0db4b590f72ffc85b7a33
2015-11-19 16:26:14 +08:00
Peter Lisák
3b1f4fda72 Unification of manpages and docstrings
* adding missing options
* unification of help

Change-Id: I2365e66433b63de8fd4da205611d9c1bf3bb6730
2015-11-13 17:32:12 +01:00
Jenkins
50978ddf63 Merge "Centralize header parsing" 2015-11-12 02:53:20 +00:00
Peter Lisák
3e1a457db0 Add content-type in list of container content
Change-Id: Ie0787d5ffbee0a7d2429cb285fa6ecdf722e4ae1
2015-11-11 12:21:40 +01:00
Jenkins
ad5656020c Merge "Add tests and param definitions for headers parameter" 2015-11-04 01:11:37 +00:00
Jenkins
1c649cc0d8 Merge "enable autodocumentation for utils module; docstring fixes" 2015-10-29 06:09:46 +00:00
Lisak, Peter
df1f4f3e39 swiftclient content-type header
According to help `swift upload -h` you can add a customized request header 'Content-Type'.
But actually it is ignored (cleared and default is used) if subcommand is upload.

Subcommand post works as expected in help.

Bug fix: Use 'Content-Type' from the customized request headers also if
uploading.

Change-Id: If0d1354b6214b909527341078fe1769aa6587457
2015-10-22 08:54:13 +00:00
Tim Burke
9fed7ed5e1 Miscellaneous (mostly test) cleanup
* Always use testtools.TestCase, since we're relying on testtools
 * Always use mock (as opposed to unittest.mock) since we're relying on
   mock
 * Add note about when a missing logging handler was added
 * Stop %-formatting the giant usage string that doesn't actually need
   any formatting
 * Prefer assertIs, assertIn, assertIsInstance over assertTrue
 * Use else-self.fail instead of sentinel values
 * Check resp.get('error') is None before checking resp['success'] is
   True, so test failures actually tell you something useful
 * Tighten some isinstance assertions
 * Import MockHttpTest from correct location
 * Only populate clean_os_environ once
 * Use setUp for setup, not __init__
 * Replace assertIn(key, dict) and assertEqual(foo, dict[key]) with
   assertEqual(foo, dict.get(key)) when key is a literal and foo is not
   None
 * Use mock.patch.object instead of manually patching for tests
 * Use six.binary_type instead of type(''.encode('utf-8'))
 * Stop shadowing builtin bytes
 * Reclaim some margin
 * Stop checking the return-type of encode_utf8; we already know it's
   bytes

Change-Id: I2138ea553378ce88810b7353147c8645a8f8c90e
2015-10-07 22:33:42 -07:00
Tim Burke
1b0567b6c7 Add py35 to default tox environments
Change-Id: Ib10eab87b791da561b82c9522ba2686d24966c2d
2015-10-01 12:31:12 -07:00
Alistair Coles
328d6a8d45 Add tests and param definitions for headers parameter
Cleanups for change I35c3b266b3c733f6b1629de4c683ea7d40128032

Add missing param definitions to client get_container
and head_object docstrings.

For consistency, add headers parameter to the Connection class
head_object and head_container wrapper methods.

Add tests to verify that the headers parameter of Connection
get_container, head_container and head_object methods is passed to the
module functions.

Change-Id: Ib40d5b626b2793840727c58cffbf725bea55651f
2015-09-23 12:21:45 +01:00
Alistair Coles
43b2c6bfe5 Make more assertions in client unit tests
Some tests rely on the fake connection checking expected request
parameters, but that assumes that the fake ocnnection is even called,
which is not being checked. Add more explicit assertions that requests
are in fact made.

Change-Id: Id1c48235d7d97fd1b0feec6c19ed59a87bebdf89
2015-09-23 09:55:10 +01:00
Tim Burke
305cd6253f Actually make assertions when testing get_account and get_container
Change-Id: Ibb1301b00d1bc99ec089ead02f944aa94972120a
2015-09-22 12:14:18 -07:00
Jenkins
c90547b5d4 Merge "Add headers parameter" 2015-09-22 11:43:28 +00:00
Monty Taylor
ccc3aa49ee Change ignore-errors to ignore_errors
Needed for coverage 4.0

Change-Id: I2789541f67d6adbdc8454183753832488fe2bbe2
2015-09-21 14:54:40 +00:00
Mahati
7cb99d3157 Add headers parameter
Headers parameter is required when passing client key for encryption.
It is missing for get_container and head_object.

Change-Id: I35c3b266b3c733f6b1629de4c683ea7d40128032
2015-09-16 21:55:56 +05:30
Qiu Yu
f65641c44d Suppress iso8601 logging from --debug output
This change silences logging from iso8601 when --debug option set

Change-Id: Ib8b8423012d43ef78d7138609fa98f40d46e7d4b
Closes-bug: #1324470
2015-09-12 03:10:15 +08:00
Zack M. Davis
6b3638ecec enable autodocumentation for utils module; docstring fixes
This commit adds the utils module to those for which Sphinx
automatically generates documentation from docstrings. (Many of the
functions here may be of little interest to users, but
`generate_temp_url`, at least, definitely deserves to be in the
documentation; in this way, this commit can be seen as a spiritual
companion to ca70dd9e.)

Also, a few markup errors and perceived infelicities in existing
docstrings are amended.

Change-Id: I8c66a23cb359d7dd9302a16459fad9825fedb690
2015-09-10 15:19:26 -07:00
Jenkins
26d29f5ce0 Merge "make ClientException.http_status default to None rather than 0" 2015-09-10 21:47:43 +00:00
Doug Hellmann
a2c84e0c93 Add links for release notes tool
The automated release note tool expects to find links to the bug
tracker, documentation, and source using a specific regex. This change
adds the links using the expected format so they are found and included
in the release announcements.

Change-Id: I5fa24f60c7d705593996194b865ffb2c47870808
2015-09-08 09:40:36 -07:00
Alistair Coles
1841bd6010 Initialise delete_object mock before it is called
Attempt to fix the linked bug by initialising the mock instance for
Connection.delete_object before calling the SwiftService upload
method, so that the delete_object mock already exists before the
delete_segments jobs that run in multiple threads call it.  Otherwise
there is a risk that the delete_segment job threads could race while
creating either the delete_object mock or the
delete_object.return_value mock, resulting in each thread getting a
different instance. That would explain the intermittent test failures
reported in the bug.

Change-Id: Ia82697c093529076b0bbcc6bccd577afdf0839e1
Partial-Bug: #1480223
2015-09-08 10:22:32 +01:00
John Dickinson
7cd2a01cda updated changelog for 2.6.0 release
Instead of a 2.5.1 release, add in the absolute tempurl option to the release and bump it to 2.6.0

Change-Id: Ie8335a737aac3211a240c25d88501f8f5dbccbea
2.6.0
2015-09-07 08:20:14 -07:00
Jenkins
fa7ffdd292 Merge "absolute expiry option for tempURL generation" 2015-09-05 20:16:38 +00:00
Zack M. Davis
5ae4b42392 make ClientException.http_status default to None rather than 0
The extant default of zero is a bit counterintuitive;
insufficiently-careful programmers using swiftclient in their
application might, without carefully reading the source or
documentation, write buggy code based on the assumption that the
`http_status` attribute is absent or defaults to None if ClientException
is raised for reasons other than to indicate an unsuccessful HTTP
request. (However improbable this scenario may seem, the present author
can sadly attest to it having actually happened at least once.)

Just changing the default would break some tests on Python 3, due to the
`500 <= err.http_status <= 599` comparison in Connection's _retry
method (NoneType and int are not orderable in the Python 3.x series);
thus, the case where http_status is None is explicitly folded into a
code branch that logs and reraises (whereas previously it would have
fallen through to an `else` branch where it would be logged and reraised
just the same).

While we're here, we might as well make ClientException's __init__ use
super() (although admittedly the kinds of multiple-inheritance scenarios
in which `super` truly shines seem unlikely to occur here).

Change-Id: I8c02bfb4a0ef059e781be5e08fcde13fb1be5b88
2015-09-04 16:24:54 -07:00
Zack M. Davis
52d39bebc1 absolute expiry option for tempURL generation
The `tempurl` subcommand's second positional argument is called
`seconds` and has heretofore interpreted as the number of seconds for
which the tempURL should be valid, counting from the moment of running
the command. This is indeed a common, if not the most common,
use-case. But some users, occasionally, might want to generate a tempURL
that expires at some particular ("absolute") time, rather than a
particular amount of time relative to the moment of happening to run the
command. (One might make an analogy to the way in which Swift's expiring
object support supports an `X-Delete-At` header in addition to
`X-Delete-After`—and it's the former that must be regarded as
ontologically prior.) Thus, this commit adds an `--absolute` optional
argument to the `tempurl` subcommand; if present, the `seconds` argument
will be interpreted as a Unix timestamp of when the tempURL should be
expire, rather than a duration for which the tempURL should be valid
starting from "now".

Change-Id: If9ded96f2799800958d5063127f3de812f50ef06
2015-09-04 14:57:30 -07:00
John Dickinson
9ef4c97de2 do hand-curated authors/changelog files
Change-Id: I1a264c9ce1d137b18a6dc62623a282e4a2fe839c
2015-09-04 18:29:30 +01:00
Jenkins
93666bb84a Merge "Log and report trace on service operation fails" 2015-09-04 01:46:18 +00:00
Tim Burke
ce569f4651 Centralize header parsing
All response headers are now exposed as unicode objects. Any
url-encoding is interpretted as UTF-8; if that causes decoding to fail,
the url-encoded form is returned.

As a result, deleting DLOs with unicode characters will no longer raise
UnicodeEncodeErrors under Python 2.

Related-Bug: #1431866
Change-Id: Idb111c5bf3ac1f5ccfa724b3f4ede8f37d5bfac4
2015-09-03 13:46:03 -07:00
Jenkins
ff073ab34a Merge "Increase httplib._MAXHEADERS to 256." 2015-09-03 08:37:00 +00:00
Jenkins
996f672955 Merge "Cleanup and improve tests for download" 2015-09-03 07:43:56 +00:00
Jenkins
8cbbbeb7a8 Merge "Drop flake8 ignores for already-passing tests" 2015-09-03 02:19:09 +00:00
Jenkins
e0ce24dd43 Merge "Stop Connection class modifying os_options parameter" 2015-09-03 01:18:10 +00:00
Alistair Coles
d5eb818228 Cleanup and improve tests for download
Some improvements to the tests for staggered download
that were added in [1].

[1] Ie737cbb7f8b1fa8a79bbb88914730b05aa7f2906

Change-Id: Ib999bc7bd198c1d9c217c57501f751e854d4c6ad
2015-09-02 13:06:13 +01:00
Joel Wright
3c0289844f Log and report trace on service operation fails
This patch adds exception logging to the swift service API. Each
operation that results in failure of any operation will now log
the exception as well as report a timestamp and full stack trace
in the results returned by the service API calls.

Change-Id: I7336b28354e7740ea7d048bdf355e3c1a1b4436c
2015-08-31 22:03:26 +01:00
Jenkins
e52df5d8a5 Merge "Reduce memory usage for download/delete and add --no-shuffle option to st_download" 2015-08-28 00:48:52 +00:00
Charles Hsu
4b627327c9 Increase httplib._MAXHEADERS to 256.
By default Swift increase the number of max metadata count to 90
and extra header count to 32. That mean we can put 90 metadata to
Account/Container/Object by default, when user put 90 metadata to a
Account, the Account header count is close or more than 100. The
swift client unable to access Account and get an error likes,

('Connection aborted.', HTTPException('got more than 100 headers',))

So the default _MAXHEADERS(100) won't enough.

Change-Id: I5ffc4eb5d3e1ebc3dbdd7dc69376919ae3e1c5a8
2015-08-27 00:01:22 +08:00
Alistair Coles
4b310083df Stop Connection class modifying os_options parameter
When a caller passes an os_options dict to the Connection class
constructor, the constructor may modify the os_options dict,
which can surprise the caller if they re-use the os_options
dict. Specifically the os_options tenant_name and object_storage_url
may be modified, and the changed values would then leak through to a
subsequent Connection constructed using the same os_options dict.

This fix simply constructs a new dict from the supplied os_options.
The patch also adds a test that covers this and also verifies that
a preauth_url passed as a keyword arg to Connection() will take
precedence over any object_storage_url in an os_options parameter.

Closes-Bug: 1488070
Change-Id: Ic6b5cf3ac68c505de155619f2610be9529e15432
2015-08-25 09:47:09 +01:00
Jenkins
b4b9254bc3 Merge "Add minimal working service token support." 2015-08-25 02:02:51 +00:00
Stuart McLaren
1789c2654d Add minimal working service token support.
Add client changes to allow accessing alternative
reseller_prefixes via a service token.

ie client changes for this server side spec:
 https://review.openstack.org/#/c/105228

We assume that the service storage url has been passed in
as a preauthurl.

We rely on get_auth preserving this url.

Change-Id: I1cfda178f0b6c8add46cfebd6bf38440caae2036
2015-08-24 10:54:15 +01:00
Tim Burke
91d82aff25 Drop flake8 ignores for already-passing tests
Change-Id: I5fb349b2f7808a3f97d95fc7db6b5cf5842a9f7c
2015-08-19 14:54:03 -07:00
Hiroshi Miura
38a82e9035 flake8 ignores same hacks as swift
- blacklisted flake8 hacking
- fix against E122 continuation line missing
  indentation or outdented

Closes-bug: #1475516

Change-Id: I708d0a3466a1f85c84e478873e142821ce0774cb
Signed-off-by: Hiroshi Miura <miurahr@nttdata.co.jp>
2015-08-18 19:19:22 -07:00
Jenkins
3c65652354 Merge "Update mock to get away from env markers" 2015-08-14 01:36:36 +00:00
Jenkins
e9147ca0e0 Merge "change deprecated assertEquals to assertEqual" 2015-08-11 15:19:07 +00:00
Jenkins
4f9e0891d8 Merge "make Connection.get_auth set url and token attributes on self" 2015-08-06 23:14:50 +00:00
Christian Schwede
7c7f46a33d Update mock to get away from env markers
Closes-Bug: 1476585

Bug has been reproduced on a fresh installed SAIO using
https://github.com/swiftstack/vagrant-swift-all-in-one.

Change-Id: I0300319baf7e2d8c27d1c19957894396505caeb8
2015-08-06 14:51:10 -07:00