summaryrefslogtreecommitdiff
path: root/swiftclient/client.py
Commit message (Collapse)AuthorAgeFilesLines
* Fix bug with some OS options not being passed to clientAlistair Coles2014-09-241-11/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes a regression that is preventing swiftclient from authenticating using keystone v3 options. swiftclient/shell.py processes the dict of command line options to set up a child dict ('os_options') of keystone auth specific options (line 960). The processing includes stripping --os- prefixes from the command line options before adding keys to os_options. A recent patch https://review.openstack.org/#/c/85453/ introduced a duplication of this option processing in service.py (line 79) which replaces the os_options created in shell.py, but omits keystone v3 related options. Consequently the keystone v3 options are not being passed to the client get_auth() method. This patch adds the keystone v3 related options to the option processing in service.py. For pragmatic reasons (i.e. fixing the bug quickly) the option processing code has not been removed from parse_args in shell.py. It is likely that the code in parse_args is now redundant, but all code paths between parse_args and process_options should be inspected and test coverage added before removing that code. Unit tests have been added in test_shell.py to verify that command line options are correctly passed to the client get_auth method. The MockHttpTest class is re-used in test_shell.py, so it is moved from test_swiftclient.py to tests/unit/utils.py Closes-bug: #1372465 Change-Id: I4fed013cdb8936509609d06093337cc147ade0d6
* Add keystone v3 auth supportanc2014-07-231-24/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enables swiftclient to authenticate using the keystone v3 API, allowing user id's, user domains and tenant/project domains to be specified. Since swiftclient imports keystoneclient, the main changes in swiftclient/client.py are to selectively import the correct keystoneclient library version and pass a number of new options to it via the get_auth() function. In addition the get_keystoneclient_2_0 method has been renamed get_auth_keystone to better reflect its purpose since it now deals with both v2 and v3 use cases. In swiftclient/shell.py the new options are added to the parser. To make the default help message shorter, help for all the --os-* options (including the existing v2 options) is only displayed when explicitly requested usng a new --os-help option. A new set of unit tests is added to test_shell.py to verify the parser. A comment in tests/sample.conf explains how to configure the existing functional tests to run using keystone v3 API. Note that to use keystone v3 with swift you will need to set auth_version = v3.0 in the auth_token middleware config section of proxy-server.conf. Change-Id: Ifda0b3263eb919a8c6a1b204ba0a1215ed6f642f
* Merge "replace string format arguments with function parameters"Jenkins2014-07-111-2/+2
|\
| * replace string format arguments with function parametersChristian Berendt2014-06-031-2/+2
| | | | | | | | | | | | | | | | There are files containing string format arguments inside logging messages. Using logging function parameters should be preferred. Change-Id: I90270908d27f0a57c184d5a547bb1af9b1381c95
* | Relax requirement for tenant_name in get_auth()anc2014-06-051-1/+1
|/ | | | | | | | | | | get_auth() in client.py raises an exception if tenant_name is not included in the os_options dict. This is overly constrained since tenant_id is equally sufficient. This patch modifies get_auth to require either tenant_name or tenant_id. Change-Id: Ibbcda1704637eb887efa5895579d260a1e072327
* Merge "fixed several pep8 issues"Jenkins2014-05-241-3/+3
|\
| * fixed several pep8 issuesChristian Berendt2014-05-211-3/+3
| | | | | | | | | | | | | | | | | | | | | | * E111 indentation is not a multiple of four * E128 continuation line under-indented for visual indent * E265 block comment should start with '# ' * E713 test for membership should be 'not in' Tested with pep8 version 1.5.6 (2014-04-14). Change-Id: I7f85c143d463c501a0df20724362ad5c0f2d4dde
* | Fix Python3 bugs2.1.0Christian Schwede2014-05-211-7/+10
|/ | | | | | | | | | | | | | | | | | | | This patch fixes three issues that were found running functional tests with Python 3: 1. python-requests sets 'application/x-www-form-urlencoded' as content-type if the input is not a string object and no content-type is given. 2. Encoding of the headers is now only done if required. This prevents comparisons between unencoded headers and encoded prefixes and avoids unnecessary forloop-iterations. One unittest was extended to ensure it works for unencoded and encoded headers with or without the prefix. 3. Functional tests recently switched to using byte data for testing, thus the comparison needs to be a byte object as well. Change-Id: I035f8b4b9c9ccdc79820b907770a48f86d0343b4
* fixed typos found by RETF rulesChristian Berendt2014-05-121-3/+3
| | | | | | rules are avaialble at https://en.wikipedia.org/wiki/Wikipedia:AutoWikiBrowser/Typos Change-Id: I98b6e46cb84962ffdac02e9007b5ad3b30bc2817
* Only encode metadata for user customed headersChmouel Boudjnah2014-05-071-2/+16
| | | | | | | | | | Don't encode standard headers keys but just the x-*-meta- ones. That fixes py3 to not have them casted as bytes and not properly passed to the requests kwargs. Other trivial py3 fixes along the way. Change-Id: I91b95f32fb2aec9b20892a5bb95fd1bc65d002f3
* Removed a duplicate word in a dostringAlex Gaynor2014-04-251-1/+1
| | | | Change-Id: I38e41a7ce9f91b5b1785491c6cd10dbbba9562a2
* Don't utf8 encode urls.Chmouel Boudjnah2014-04-241-2/+2
| | | | | | | | This is not needed since already done by requests. (and it was buggy with py3). Change-Id: I9505c56be2f53eb8071aea3d5fb9d8caa9508e34
* Remove validate_headersChmouel Boudjnah2014-04-171-14/+1
| | | | | | It wasn't used anymore since moved up to requests (and it fails in py3). Change-Id: Ic8a80ae09ca6445696a9cf34ffb503c5ff51bc79
* Makes use of requests.SessionTristan Cacqueray2014-04-161-1/+2
| | | | | | This allows better connection pooling and may improve performances. Change-Id: I69e986b7387dd3ac281731b8355a3eec34a537f8
* Fix swiftclient.client.quote() for Python 3Victor Stinner2014-04-071-1/+4
| | | | | | | | | On Python 3, urllib.parse.quote() accepts bytes and str (unicode) types and always return str (unicode). Add also more tests with non-ASCII characters. Change-Id: I8e0f19da7240e874392327d0da074ed4abb7d213
* Merge "don't use mutable defaults in kwargs"Jenkins2014-04-011-2/+4
|\
| * don't use mutable defaults in kwargsJohn Dickinson2014-03-301-2/+4
| | | | | | | | Change-Id: I3ae71259ccc49a5d8a852388784c3dfd577df50a
* | Merge "set user-agent header"Jenkins2014-04-011-2/+16
|\ \ | |/
| * set user-agent headerJohn Dickinson2014-03-301-2/+16
| | | | | | | | Change-Id: Ia67807667b4b5177d83cce9fcf16d98dc5024fbc
* | Merge "Decode HTTP responses, fixes bug #1282861"Jenkins2014-04-011-1/+3
|\ \
| * | Decode HTTP responses, fixes bug #1282861groqez2014-03-181-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | By default, the HTTPConnection class expose the raw.read urllib3 function which doesn't do any decoding on the http response. We can fix this by passing decode_content=True to raw.read(). Change-Id: I7d42d31ae516705d1bde2769e642931308116c7a
* | | Merge "Python 3: Get compatible types from six"Jenkins2014-03-301-2/+3
|\ \ \
| * | | Python 3: Get compatible types from sixVictor Stinner2014-03-281-2/+3
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | * Replace unicode with six.text_type * Replace basestring with six.string_types * The long type doesn't exist in Python 3 anymore: replace 1L with long(1) and only test this type with Python 2 * Fix quote(): quote the URL if the string is a byte string. Use "bytes" type instead of "str" to be Python 3 compatible. Change-Id: I1df5aa85e4e7d07191fb5c654d52fc4bd8b9f440
* | | Python 3: Fix module names in importVictor Stinner2014-03-281-2/+2
|/ / | | | | | | | | | | Use six.moves to fix imports on Python 3. Change-Id: I35b9405690e9f0607b24d79aa7c00830df954c41
* | Replace dict.iteritems() with dict.items()Victor Stinner2014-03-271-3/+3
|/ | | | | | | | | | dict.iteritems() has been removed in Python 3. In Python 2, dict.items() creates a temporary list, but Samuel Merritt wrote: "The size of the data is small enough that we don't need to worry about the memory consumption; it's all just HTTP headers." Change-Id: Iac427b8bbd032e4a1efb2bdc84a3968217eb6ddf
* Merge "TCP port is appended two time in ClientException"Jenkins2014-03-121-37/+29
|\
| * TCP port is appended two time in ClientExceptionFabien Boucher2014-03-061-37/+29
| | | | | | | | | | | | | | | | urlparse netloc contains the TCP port if presents. There is no need to provide conn.port when building CLientException. Change-Id: Id3e4fa8c4f4ab2ad693b0e8702ab69ed7c291830
* | Add LengthWrapper in put_object to honor content_length paramClay Gerrard2014-02-251-5/+3
| | | | | | | | | | | | Closes-Bug:#1284360 Change-Id: Iec63a3fde77bb8195bfe46c764403b367999ff43
* | Merge "Remove useless statement"Jenkins2014-02-191-1/+0
|\ \ | |/
| * Remove useless statementFabien Boucher2014-02-191-1/+0
| | | | | | | | Change-Id: Ide74b417ede6a4976c33fc835d366ed472033fd0
* | Remove multipart/form-data file upload2.0.2Tristan Cacqueray2014-02-141-1/+6
|/ | | | | | | | | | | | | | | | The requests 'files' parameter adds this 'Content-Type: multipart/form-data' HTTP header and the whole multipart body data get stored with the object. This also create a memory hog issue because files are loaded in memory before being actually sent. This patch removes this behavior and restores what was done before, ie: direct uploading. This patches also fixes an issue in requests, when used with glance CooperativeReader it mis-calculates content-length leading to chunked encoding for raw upload. Change-Id: Ie5b0a1078bedd33f09c6157f48b5f88116c589fa Closes-Bug: #1280072 Closes-Bug: #1280275
* Fix --insecure option on auth2.0.1John Dickinson2014-02-131-7/+9
| | | | Change-Id: Ibe76d98d6075b84cbdb370b48f3498ab848142ad
* Merge "Port to python-requests"2.0Jenkins2014-02-141-90/+114
|\
| * Port to python-requestsTristan Cacqueray2014-02-121-90/+114
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, httplib implementation does not support SSL certificate verification. This patch fixes this. Note that ssl compression parameter and 100-continue thing is still missing from requests, though those are lower priority. Requests now takes care of: * proxy configuration (get_environ_proxies), * chunked encoding (with data generator), * bulk uploading (with files dictionary), * SSL certificate verification (with 'insecure' and 'cacert' parameter). This patch have been tested with requests 1.1.0 (CentOS 6) and requests 2.2.1 (current version). Change-Id: Ib5de962f4102d57c71ad85fd81a615362ef175dc Closes-Bug: #1199783 DocImpact SecurityImpact
* | changed things because reasonsSergio Cazzolato2014-02-061-2/+5
|/ | | | | | | Dictionaries added in texts to improve readability in case there are 2 params Change-Id: I064cceeaa56b232504c6f0b6c215c9c5dbb7fcef
* Merge "Add capabilities option"Jenkins2014-01-311-0/+32
|\
| * Add capabilities optionFabien Boucher2014-01-171-0/+32
| | | | | | | | | | | | | | | | This patch adds a capabilities option on swiftclient. This option uses the new /info endpoint to request the remote capabilities and nicely display it. Change-Id: Ie34b454511d5527e402e66e1fdb72120f427f2fd
* | retry on ratelimitJohn Dickinson2013-12-231-1/+9
|/ | | | | | | | | Added a retry_on_ratelimit parameter to the Connection class so that ratelimited requests can be retried. DocImpact Change-Id: I2817a7ea0ed2d69a7659e80111fbd2c91a75d530
* Merge "Enable usage of proxies defined in environment (http(s)_proxy)."Jenkins2013-12-141-2/+8
|\
| * Enable usage of proxies defined in environment (http(s)_proxy).Davide Guerri2013-12-101-2/+8
| | | | | | | | | | | | | | | | | | As far as proxies usage is concerned, keystone-client API and swift-client API behave differently because the former uses python Request library while the latter uses raw httplib. As a result, Keystone authentication honors environment variables http_proxy, https_proxy and no_proxy while Swift doesn't. This patch, which code is mainly borrowed from Python Requests, makes Swift data connections and Swift authentication connections behaving homogeneously. Change-Id: Ic8a0089c35c458d7ed96e572e22429014298fe4c
* | Merge "Fixes python-swiftclient debugging message"Jenkins2013-12-121-1/+2
|\ \
| * | Fixes python-swiftclient debugging messageFlorent Flament2013-10-111-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge "Skip sniffing and reseting if retry is disabled"Jenkins2013-12-101-9/+8
|\ \ \
| * | | Skip sniffing and reseting if retry is disabledYuan Zhou2013-09-291-9/+8
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | Bypass sniffing entirely if retries has been disabled. Fix bug #1216981 Change-Id: I593bdc56ca139af5a7f2ca2783ef2de2a96c94fb Signed-off-by: Yuan Zhou <yuan.zhou@intel.com>
* | | Merge "Don't crash when header is value of None"Jenkins2013-12-071-1/+3
|\ \ \
| * | | Don't crash when header is value of NoneChmouel Boudjnah2013-12-061-1/+3
| | |/ | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before commit 7d88d14d (http://git.io/hhJWdQ) swifclient used to accept header value with the type None : {'Headers': None} It would just be happy with it with those None headers and not process them, reinstate the old behavior. Closes-Bug: 1256441 Change-Id: Ic7f80c38ef2ce9ef1687ed0d6d65521f2e754905
* | | Merge "Fix download bandwidth for swift command."Jenkins2013-12-031-1/+3
|\ \ \
| * | | Fix download bandwidth for swift command.jola-mirecka2013-11-281-1/+3
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | | Merge "Add close to swiftclient.client.Connection"Jenkins2013-11-291-0/+8
|\ \ \ | |/ / |/| |
| * | Add close to swiftclient.client.ConnectionFeng Liu2013-10-231-0/+8
| | | | | | | | | | | | Change-Id: I2f5fa9c46886607a9ba99e8915ea84ac4975d004