671 Commits

Author SHA1 Message Date
Joel Wright
3a5a25fe98 Add new doc structure and contents for swiftclient
As a result of the Hackathon we have produced a new
documentation structure for the python-swiftclient.
This patch introduces the new structure and adds the
required content.

The intention is to document the CLI, the SwiftService
and Connection API. Importantly, we also provide
guidance on important considerations when using a swift
object store, such as which aspect of the python-swiftclient
to use for various use cases, common authentication patterns
and some useful examples.

Co-Authored-By: Alexandra Settle <alexandra.settle@rackspace.com>
Co-Authored-By: Mohit Motiani <mohit.motiani@intel.com>
Co-Authored-By: Hisashi Osanai <osanai.hisashi@jp.fujitsu.com>

Change-Id: I9eb41f8e9137efa66cead67dc264a76a3c03fbda
2016-04-29 19:21:36 +01:00
Tim Burke
f86b2d8138 Clean up some unnecessary variables
Change-Id: Iac93ced6344d4a6fee7e6390e891fde765814c03
2016-03-24 13:06:42 -07:00
Marek Kaleta
51a8a5a7ae Fix SwiftPostObject options usage in SwiftService
SwiftService().post(cont, [SwiftPostObject(obj, options]) currently
ignores options['header'], raises exception when options['headers']
is set and make malformed metadata when options['meta'] is set.

Fix tipos in code, add unittest for SwiftService().post
Closes-Bug: #1560052

Change-Id: Ie460f753492e9b73836b4adfc7c9c0f2130a8a91
2016-03-23 15:38:10 +01:00
Jenkins
8db46ddce3 Merge "Move python-keystoneclient to "extras"" 2016-03-21 16:41:25 +00:00
Jenkins
a879e46cb7 Merge "Removes redundant "to"" 2016-03-18 11:40:40 +00:00
Jenkins
39e017d807 Merge "Initialize delete_object mock *before* creating all the threads" 2016-03-18 10:43:09 +00:00
Nguyen Hung Phuong
67db1646a3 Removes redundant "to"
This patch removes "to" in swift guide.

Change-Id: I4104bd3651947e341e1ed06c76b3f8f66f565c3f
2016-03-18 16:18:12 +07:00
Tim Burke
d2bd2f0859 Initialize delete_object mock *before* creating all the threads
Previously, we'd occasionally get spurious failures like

    FAIL: test_delete_account (tests.unit.test_shell.TestShell)
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File ".../mock/mock.py", line 1721, in _inner
        return f(*args, **kw)
      File ".../mock/mock.py", line 1305, in patched
        return func(*args, **keywargs)
      File ".../tests/unit/test_shell.py", line 788, in test_delete_account
        response_dict={})], any_order=True)
      File ".../mock/mock.py", line 983, in assert_has_calls
        ), cause)
      File ".../six.py", line 718, in raise_from
        raise value
    AssertionError: (call(u'container', u'object', query_string=None,
                          response_dict={}),)
    not all found in call list

Related-Bug: #1539536
Related-Bug: #1480223
Change-Id: I810894545ca74d3b2f2dbde2d0388eb69c2ba710
2016-03-17 15:43:45 -07:00
Jenkins
c4ce65f2d2 Merge "Include response headers in ClientExceptions" 2016-03-17 22:20:35 +00:00
Jenkins
985c038209 Merge "Check threads number options validation" 2016-03-17 22:10:01 +00:00
Tim Burke
52eab61e7e Move python-keystoneclient to "extras"
This should make it more clear to users that they may want to install
it.

Change-Id: I8bb4f3eba1fc6d2b7b23c3bd51663678e755a69e
2016-03-07 11:21:33 -08:00
Min Min Ren
965fd4d3fc Initialise delete_object mock before it's called
Fix the linked bug. delete_object mock should be before it's
called by swiftclient.shell.main function.
Related: https://review.openstack.org/221219

Change-Id: I52143a93c129764c02bba05267f3563c824e82cb
Partial-Bug: #1480223
2016-03-05 03:05:23 +08:00
Jenkins
b65d994937 Merge "Drop *.dbm* before running tests" 2016-03-04 17:40:37 +00:00
Tim Burke
9b8ab67a78 Include response headers in ClientExceptions
Now, client applications can get to things like transaction IDs for
failures without needing to turn on all of logging.

While we're at it, add a from_response factory method for
ClientException.

Co-Authored-By: Alexander Corwin <ancorwin@gmail.com>
Change-Id: Ib46d5f8fc7f36f651f5908bb9d900316fdaebce3
2016-03-03 17:16:33 +00:00
Jenkins
343ecbcfa2 Merge "Drop py33 support" 2016-03-03 04:38:28 +00:00
Pete Zaitcev
f179c36aea Drop *.dbm* before running tests
See change I74fb5122e80a223aaa70afaeec7a7c585aa33577 for the
previous discussion. But basically, if you run tox -e py27
then tox -e py34, the latter fails with "db type could not
be determined", because of stuck .testrepository/times.dbm.

This patch fixes it by clearing the *.dbm*. Should be safe
as long as periods aren't used commonly in stable file names.

Change-Id: I617eca308261f291c510c8cbd432779f1c00b182
2016-03-02 08:59:59 -07:00
John Dickinson
e4d0cc7419 bumped version at request of release team
Change-Id: I81eb6575ef5de8ecc75e781f07ad090024589cec
2016-03-02 12:00:05 +00:00
Jenkins
c023893dd3 Merge "download method shouldn't download all object" 2016-03-02 11:15:11 +00:00
Jenkins
cd3a4dbf0a Merge "Drop testtools from test-requirements.txt" 2016-03-01 17:51:32 +00:00
Jenkins
d70b8266cb Merge "Minor edits to the api page" 2016-02-29 20:03:49 +00:00
Hu Bing
b7d20b8a18 download method shouldn't download all object
in python-swiftclient/swiftclient/service.py,
there is a method
def download(self, container=None, objects=None, options=None):

if container is specified but objects not, it download all
objects in specified container.
if both container and objects are specified, it download all
specified objects in the container.

when it comes to the case that, objects argument is specified,
but it turned out to be empty array [ ], the download method
download all the objects under specified container.
this may be not reasonable.

for example,
the objects was not empty when it came from command line,
but it's filtered, maybe by --prefix argument.
at last, it turned out to be empty array.

when calling download method with objects arguments
being empty array, we should download nothing instead of
all the objects under the specified container.

Change-Id: I81aab935533a50b40679c8b3575f298c285233a8
Closes-bug: #1549881
2016-03-01 03:10:34 +08:00
Jenkins
b040ce4e1a Merge "Fix wrong args for get_container with full listing" 2016-02-29 16:26:58 +00:00
Jenkins
9460a94624 Merge "Have tox manage LANG environmental var" 2016-02-29 13:58:25 +00:00
Alexandra
671d6febb2 Minor edits to the api page
Change-Id: Ie65f73532e53a858ee9ab4b4634dcfcaf8a93c3b
2016-02-29 13:50:10 +00:00
Jenkins
1d94f9262d Merge "authors/changelog updates for 2.8 release" 2016-02-27 11:17:04 +00:00
Jenkins
ba2ff4a6ea Merge "Force header keys/values to bytes/unicode before coercing to unicode" 2016-02-27 01:44:38 +00:00
Tim Burke
aa0edd0096 Force header keys/values to bytes/unicode before coercing to unicode
Previously, parse_header_string was only called with data coming out of
requests, which would be either bytes or unicode. Now that we're sending
it request headers as well (see related change), we need to be more
defensive.

If the value given is neither bytes nor unicode, convert it to a native
string. This will allow developers using the client API to continue
sending header dicts like

  {'X-Delete-After': 2}

...as in Swift's test/probe/test_object_expirer.py

Change-Id: Ie57a93274507b184af5cad4260f244359a585f09
Related-Change: I43dd7254f7281d4db59b286aa2145643c64e1705
2016-02-26 11:25:10 -08:00
John Dickinson
62b09844b6 authors/changelog updates for 2.8 release
Change-Id: I335c30fd7d0a0120c87fa60c5c142b8ed95c56bf
2016-02-26 09:09:47 -08:00
Joel Wright
46d8178280 Fix test for redacting sensitive data in client.http_log()
The test should have included utf8 encoded unicode data to
test that encoded unicode data stored in headers was parsed
correctly.

Also fixes the docstring for swiftclient.safe_value()

Change-Id: Id0def0b3af7a364f1257cc22f67b71c0cc5d8479
2016-02-26 11:36:45 +00:00
Jenkins
ee905477ac Merge "Follow-up to patch 282363" 2016-02-26 10:56:07 +00:00
Thiago da Silva
85b4d65f3b adding .manpages script to swift client
this is the same script as in swift core

Change-Id: Ib9ea882cf7c1ba1d663254d38c7ac163b55e45da
2016-02-25 16:07:28 -05:00
Tim Burke
c3f0641704 Follow-up to patch 282363
* Improve some formatting
* Be more explicit about how much will be revealed when
* Rename redact_sensitive_tokens to redact_sensitive_headers, as it
  affects more than tokens.

Change-Id: I02b375d914e9f0a210d038ecb31188d09a8ffce3
2016-02-25 10:06:48 -08:00
Jenkins
0f60cf05f4 Merge "Do not reveal auth token in swiftclient log messages by default" 2016-02-25 01:49:06 +00:00
Paul Belanger
adc3177d1f Have tox manage LANG environmental var
We need to do this because some of the py34 testing that
python-swiftclient uses depends on this variable.  The reason we don't
see the issue in the gate, is because current bare-trusty images have
this set on the jenkins shell user.

When we move to just using DIBs, the variable won't be setup by
default and python3 tests will fail.

For more information:
  https://review.openstack.org/282898

Change-Id: Id9017f31b0543bccac9c07b83237b909e2bd2b0c
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
2016-02-24 14:45:16 -05:00
Min Min Ren
00de6cfa63 Check threads number options validation
Add checking object-threads, container-threads and segment-threads options validation
The values should be a positive integer

Change-Id: Iaf98e33dae4b9a7f82e33f7cc2e5a0b293a1c76f
Close-Bug: #1546973
2016-02-24 20:19:43 +08:00
Jenkins
4244b99b02 Merge "Update api docs title to make ToC better" 2016-02-24 03:26:39 +00:00
shu-mutou
f95de16875 Drop py33 support
"Python 3.3 support is being dropped since OpenStack Liberty."
written in following URL.
https://wiki.openstack.org/wiki/Python3

And already the infra team and the oslo team are dropping py33
support from their projects.

Since we rely on oslo for a lot of our work, and depend on infra
for our CI, we should drop py33 support too.

Change-Id: Ia8f2b26e446175b0d892a11952ef3dc11dcdc73c
Closes-Bug: #1526170
2016-02-23 00:19:56 +00:00
Jenkins
689ce4738d Merge "New python swiftclient doc" 2016-02-22 20:31:15 +00:00
John Dickinson
011d730c9b Update api docs title to make ToC better
Change-Id: Ie8eeb3dd8eddf1868f0fa99911c459ae9f7b0091
2016-02-22 10:32:28 -08:00
Joel Wright
4d44dcf360 Do not reveal auth token in swiftclient log messages by default
Currently the swiftclient logs sensitive info in headers when logging
HTTP requests. This patch hides sensitive info in headers such as
'X-Auth-Token' in a similar way to swift itself (we add a
'reveal_sensitive_prefix' configuration to the client).

With this patch, tokens are truncated by removing the specified number
of characters, after which '...' is appended to the logged token to
indicate that it has been redacted.

Co-Authored-By: Li Cheng <shcli@cn.ibm.com>
Co-Authored-By: Zack M. Davis <zdavis@swiftstack.com>
Change-Id: I43dd7254f7281d4db59b286aa2145643c64e1705
Closes-bug: #1516692
2016-02-22 17:55:51 +00:00
Alistair Coles
67f5468ee4 Fix wrong args for get_container with full listing
In client get_container(), when full_listing is true,
the calls back to get_container() pass service_token
as a positional arg which maps its value to the
full_listing arg. It should use a keyword.

Change-Id: Iac2af45df124ff33fcb7fbaf1ba959ef06c96378
Closes-Bug: #1496093
2016-02-22 15:22:44 +00:00
Jenkins
da0aa24f28 Merge "_RetryBody doesn't need to take explicit etag/content-length" 2016-02-18 23:40:51 +00:00
Jenkins
45583d6af7 Merge "Use "# noqa" instead of "#flake8: noqa"" 2016-02-18 00:14:49 +00:00
Jenkins
f95c03cc40 Merge "Display proper name when failing to create segments container" 2016-02-17 17:16:42 +00:00
Tim Burke
bed6bbd5ef Drop testtools from test-requirements.txt
My understanding is that it was mainly being used so we could have sane
testing on py26.  With py26 support being dropped, we no longer need it.

Also drop discover from test-requirements.txt, as we don't seem to
actually use it.

Change-Id: Iee04c42890596d3b483c1473169480a3ae19aac8
Related-Change: I37116731db11449d0c374a6a83a3a43789a19d5f
2016-02-12 09:57:58 -08:00
Jenkins
a6f171437d Merge "Add test for --debug taking precedence over --info" 2016-02-11 20:22:24 +00:00
Jenkins
2b391d47f0 Merge "Fix debug and info option parsing" 2016-02-11 20:22:09 +00:00
Alistair Coles
28558c7e0a Add test for --debug taking precedence over --info
Change-Id: Ibf0903817852edb36389028383a35e0d65f88a26
2016-02-11 15:02:09 +00:00
Jenkins
d4090d555d Merge "Support --os-identity-api-version option" 2016-02-11 05:28:17 +00:00
Tim Burke
30ca247426 Display proper name when failing to create segments container
Previously, we displayed the base container's name.

Change-Id: I70f1949a44ba61158e31178e4536f229c37aab47
2016-02-10 13:25:38 -08:00