98 Commits

Author SHA1 Message Date
Jenkins
4f794410f1 Merge "Replace functions 'Dict.get' and 'del' with 'Dict.pop'" 2016-08-30 02:58:10 +00:00
bhagyashris
0504354233 Replace functions 'Dict.get' and 'del' with 'Dict.pop'
Refactoring code: Making dicts to use single instruction: pop()
rather than two instructions: get() and del, giving the codes
a format that carries through.

TrivialFix

Change-Id: Ie404888ccf257978e0ac491165926dfde9a3e6d6
2016-08-29 11:35:02 +05:30
Rui Chen
639831b096 Fix NoneType error for cinderclient v1
Request-id log is recorded in SessionClient.request() method,
but None is used as logger, that causes all the v1 commands
to be broken. This patch fixes the issue and updates the related
unit tests.

Change-Id: I46b973f2baca8d7402a39e0d15dbd8da38f4e590
Closes-Bug: #1616070
2016-08-25 01:59:20 +00:00
Jenkins
762212f7fe Merge "Switch to keystoneauth" 2016-07-26 18:59:30 +00:00
Jenkins
3464a88a70 Merge "Make sure --bypass-url honored if specified" 2016-07-26 17:29:02 +00:00
Steve Martinelli
16f83c4a53 Switch to keystoneauth
move cinderclient to keystoneauth as keystoneclient's auth session,
plugins and adapter code has been deprecated.

Co-Authored-By: Paulo Ewerton <pauloewerton@lsd.ufcg.edu.br>
Co-Authored-By: Sean McGinnis <sean.mcginnis@gmail.com>
Co-Authored-By: Jamie Lennox <jamielennox@gmail.com>

Change-Id: Id4bf0e2088e8ad99e83cd4f9b8549c2aca1f65a2
2016-07-23 07:35:40 +10:00
scottda
09b51a294e Add api-version to get server versions
Mitaka Cinder added an API to return Versions from the base
endpoint URL:
http://<url>:8776/
This patch exposes that API for /v3 endpoint microversions 3.0 and
above with the command:
cinder api-version

Implements: blueprint add-get-server-versions

Change-Id: Ieb1a56b28188ec17946fe5564b28c165833ffc24
2016-07-11 10:44:12 -06:00
Yuriy Nesenenko
f8eef18297 Cinder client should retry with Retry-After value
If a request fails but the response contains a "Retry-After",
the cinder client should wait the amount of time and then retry.
Cinder client should report a warning to user and continue with
retry, so that user can cancel the operation if not interested
in retry. The value in "Retry-After" header will be in seconds
or GMT value, client should handle both the cases.

How many times client should retry will be controlled by user
through "--retries" argument to cinder api example,
$ cinder --retries 3 availability-zone-list

If request was not sucessful within the retries, client should
raise the exception.

Change-Id: I99af957bfbbe3a202b148dc2fcafdd20b5d7cda0
Partial-Bug: #1263069
2016-07-06 11:42:20 +03:00
Abhishek Kekane
679cdd2451 Log request-id for each api call
Added new private method to log request-id of each api call
for both SessionClient and HTTPClient. Already available
ks_logger and client_logger will be used for SessionClient
and HTTPClient respectively.

Change-Id: I679c57b96071ecd9bcd1ab2ed50692195586ca52
Implements: blueprint log-request-id
2016-06-28 08:44:23 +00:00
Qiu Yu
03e041a3cd Make sure --bypass-url honored if specified
Currently SessionClient ignored --bypass-url which is only used with
HTTPClient. This change force to use HTTPClient if bypass-url specified.

Change-Id: I03d1eec8cfda81efce409399b8d6ca91b779840b
Closes-Bug: #1467577
2016-06-06 08:41:37 -05:00
Victor Stinner
623cef2d5c Don't enable lazy translation when loading client
The change I9c8db9487b554b637a41620c858a7e7abf802879 introduced a
regression in nova and trove. Importing cinderclient.client now calls
_i18n.enable_lazy() which calls oslo_i18n.enable_lazy(). It's wrong to
modify a global variable (oslo_i18n._lazy.USE_LAZY) when a module is
imported.

This change removes the call to _i18n.enable_lazy() from client.py.

Closes-Bug: #1587071
Related-Bug: 1586976
Change-Id: I1512b86815e7248fa226c6969124ddc654145562
2016-05-30 17:14:15 +02:00
Eric Harney
dfefde11e1 Remove Python 2.5 compat shim
We don't support or test with Python 2.5.

Change-Id: Id29f0cee786205cc751d2d5bc031b3c105ae6aaa
2016-04-21 14:34:34 -04:00
scottda
3f75b48f06 Support api-microversions
Changes to cinderclient to use microversions.

Implements: blueprint api-microversion-support-for-cinderclient
api-microversion-support-for-cinderclient

Change-Id: I840a1162b88e8ff36fa3fc4e1d6b9317104df3e0
2016-04-19 11:19:45 -06:00
Jenkins
7d570540a4 Merge "Add /v3 endpoint support for cinderclient" 2016-04-19 15:20:11 +00:00
Jenkins
dd22e6cd6e Merge "Change extension module naming to a shorter one" 2016-04-19 14:20:20 +00:00
scottda
27e6f6f7f8 Add /v3 endpoint support for cinderclient
Add support for Cinder API /v3 endpoint.
A couple of unit tests for /v3 endpoint were added to v3/test_shell.py
to ensure that the v3 shell works, and to also test that modules work
with:
from cinderclient.v2.availability_zones import *
syntax.

Change-Id: I6ae0ada221bebb4ab1850d9c99b10fcbb585201f
Implements: https://blueprints.launchpad.net/python-cinderclient/+spec/add-v3-endpoint-support
2016-04-18 10:49:51 -06:00
Jenkins
471972a975 Merge "Graduate to oslo.i18n and cleanup incubator usage" 2016-04-12 16:04:55 +00:00
Jenkins
147a4312fe Merge "Fix wrong request url when retrieving multiple request" 2016-03-29 10:31:08 +00:00
zwei
8bc5a446f0 Fix wrong request url when retrieving multiple request
When the length of resource list is larger than osapi_max_limit.
Cinder will return a "maker url" which marks index of resources
already returned to client.
_cs_request() function fo HTTPClient will link the endpoint url of cinder
and this "marker url" together then use this wrong linked url to request
the server side, which cause a NotFound exception.

Closes-bug: #1560862
Change-Id: I416b63758373dc8ad29818d6952d1e9dd58d05f2
2016-03-25 23:52:31 +08:00
Ronald Bradford
74252d1abd Graduate to oslo.i18n and cleanup incubator usage
Graduate from Oslo Incubator to oslo.i18n library.
Cleanup of unused Oslo Incubator utils.
Added optional enable_lazy() usage.

Implements: blueprint graduate-oslo-i18n [1]
https://blueprints.launchpad.net/oslo-incubator/+spec/graduate-oslo-i18n

Change-Id: I9c8db9487b554b637a41620c858a7e7abf802879
2016-03-24 11:40:38 -04:00
Jenkins
635b14b058 Merge "Keep py3.X compatibility for urllib" 2016-03-17 17:30:43 +00:00
Jose Porrua
5efb5964f7 Avoid logging sensitive info in http requests.
This patch follows the same approach as other OpenStack python
clients, by adding a safe header method to hash sensitive information.

Change-Id: I980ea7411b1e7f6d47d0a75d58de87b0f944d0d9
Closes-bug: #1516689
2016-02-16 15:36:32 +00:00
LiuNanke
d4aaafbd9f Keep py3.X compatibility for urllib
Use six.moves.urllib.parse instead of urllib.
For urllib2 compatibility, it need to sync policy
module from oslo first. Then six.moves.urllib.request
can replace urllib2.

Change-Id: Ia351cd3088dd64fd8c8ce4ca8b9a5889c574888e
Partial-Bug: #1280105
2016-01-14 02:22:53 +08:00
Ivan Kolodyazhny
ef7485df77 Change extension module naming to a shorter one
This patch changes extension suffix from 'python_cinderclient_ext' to
'cinderclient_ext' to get more shorter module names.

Change-Id: Id78e05646d2bc4fda758710eb630dca5eefa457f
2016-01-13 15:09:01 +02:00
huangtianhua
aa06b2dd54 Make _discover_extensions public
Heat wants to use
`cinderclient.shell.OpenStackCinderShell._discover_extensions`
function (https://bugs.launchpad.net/heat/+bug/1527071),
which is private currently. It's better to change this method
to public for public use.
This change will do it as novaclient did.

Change-Id: Iaaa4cab530fd495877e15a372fff1354ddbeaa17
Closes-Bug: #1527169
2016-01-06 01:30:46 +00:00
Eric Harney
6fe9f20663 Use oslo_utils encodeutils and strutils
With oslo-incubator being deprecated, move
our use of strutils to oslo_utils.

This leaves in place the use of oslo-incubator's
strutils by other oslo-incubator modules for now.

Change-Id: Ic4e50060b42aeca9d1e54424a8a3a123140fbf2a
2015-11-23 10:44:12 -05:00
Jenkins
3ccd5b878a Merge "No longer ignores CINDER_SERVICE_NAME" 2015-10-03 04:21:23 +00:00
Derrick J. Wippler
e8274fa57d No longer ignores CINDER_SERVICE_NAME
Cinderclient now utilizes the CINDER_SERVICE_NAME when deciding what
endpoint to choose.

Closes-Bug: #1486256
Change-Id: I494a34afe5799e7832b1359b9c24c31ead68b6d1
UpgradeImpact: Existing configurations may select a different endpoint
after this patch.
2015-09-14 08:49:14 -05:00
Jenkins
19ba5e8cf9 Merge "Fix incorrect exception message in cinderclient" 2015-09-13 07:59:33 +00:00
Yusuke Hayashi
32f7dde401 Fix incorrect exception message in cinderclient
Incorrect exception message was output
from get_volume_api_from_url(url) in cinderclient.client.

Here is example:

<Invalid input>
"http://fakeurl/v9/tenants"

<Exception message>
cinderclient.exceptions.UnsupportedVersion:
Invalid client version 'v2'. must be one of: v1, v2

=> Although input does not include 'v2',
   exception message reports that invalid version v2 is included.

Change-Id: I73ff1581b1ce609b3c64a8a6d88d41a2cc2ed56f
Closes-Bug: #1482988
2015-09-09 10:52:16 -07:00
Lin Yang
c23586b73f Remove redundant statement and refactor
1. Remove redundant pass-statement in except-block.
2. Define "body = None" before if-block to get rid of body-statement both in
   except-block and else-case.
3. Acknowledge error occurred instead of silently squashing it.

Change-Id: I31e17827b40e7a15d88ecacf1fdb2abbbe2da5c0
Signed-off-by: Lin Yang <lin.a.yang@intel.com>
2015-07-08 11:42:59 +08:00
Jenkins
b7d62d0558 Merge "Add set_management_url to cinderclient.client" 2015-07-07 19:16:37 +00:00
Mike Perez
1f52746bcb Revert "Enable version discovery"
This reverts commit ae03d2a721bd9acb61805ce792a27fb7cf88e5cd.

Cases where a deployment is using a proxy, Cinder servers won't return
the expected publicURL, and instead gives an internal URL that the
client can't use.

Commit 2eb25ab8803214cb3beb5d8fe3efbf70a462c414 in Cinder introduces the
public_endpoint config option, but not everyone is expected to be
running that later of a version to take advantage of this.

Closes-Bug: #1464160
Change-Id: I61228c1e8630b958c792be077674b48fbdb83135
2015-07-02 11:57:33 -06:00
Michal Dulko
95899799da Add set_management_url to cinderclient.client
set_management_url was used in authenticate method but wasn't defined
in the HTTPClient. This commit implements missing method and adds
regression unit tests.

Change-Id: I605a5d1bcf6cc2dc5720820d8a8122dd17089ffa
Closes-Bug: 1418580
2015-06-25 11:50:26 +02:00
Mike Perez
4ea65b4409 Add version removal rule to stop discovery warning
Cinder recently added version discovery leveraging Keystone Client. For
cases where the service catalog still contains version numbers, this can
result in Keystone attempting to do discovery at the base url with the
version number and giving warnings. This will set a version removal rule
so Keystone can find the correct base url.

Change-Id: I71432468fea8bf1e50f180ab7f6dd69ee9aaa7e6
Closes-Bug: #1448244
2015-04-29 09:29:01 +10:00
Mike Perez
ae03d2a721 Enable version discovery
The service catalog can now have the cinder endpoint x.x.x.x:8776 with
service_type volume, without needing to specify a version in the
endpoint. Keystone will do discovery of the root / GET of the Cinder API
to discover the versions that can be talked to.

This also provides backwards compatibility for the previous solution of
having v1 enabled on service_type volume and v2 on service_type
volumev2.

Change-Id: Id0347f8370dbc8fd7fa8096cd5859e10b0c5d67c
2015-04-20 15:50:08 +00:00
tpatil
de36755657 Allow cinderclient to handle exception response
For all cinder commands, the error message returned by the cinder
service is gobbled by keystoneclient as raise_exc is enabled by
default and it doesn't have the knowledge of how to interpret
exception returned by the cinder service correctly.

Set raise_exc to False explicitly in request method of cinderclient
and pass it to the keystoneclient session request method so that
keystoneclient raises exception only when the exception is raised
by the keystone server else cinderclient should interpret the
exception returned by the cinder service.

Closes-Bug: 1431693
Closes-Bug: 1428764
Change-Id: I1160a2c998919b669c39a4b739e83f5bd9d8d235
2015-03-31 23:37:18 -07:00
Jenkins
eaedc41ddd Merge "Don't use sessions if third party plugin is used" 2015-02-03 15:25:09 +00:00
Aaron Rosen
0b38d75a44 Leverage openstack.common.importutils import_class
This patch drops the import_class method from utils and instead
leverages the one in openstack.common.importutils.

Change-Id: I9f740b9941d477776597c4c4ab88a65a39fb4fb8
Closes-bug: 1365273
2015-01-12 22:58:00 +00:00
Jenkins
9c1ec1d19c Merge "Fix incorrect variable name" 2015-01-06 19:52:00 +00:00
Robert Myers
7783767f23 Don't use sessions if third party plugin is used
If an auth_plugin is used do not try to load the session
from the default keystone providers.

Change-Id: If2a87e23cabde006833de70e5c7aa066d95dbf50
Closes-Bug: #1380729
2014-12-09 11:41:27 -06:00
Jenkins
3398e424bf Merge "client HTTPClient __init__ fails if auth_url None" 2014-12-02 09:48:02 +00:00
Jenkins
b2b0489283 Merge "Use newer features from keystoneclient" 2014-12-02 01:16:14 +00:00
Vincent Hou
7a50182fbe Add the parameter bypass_url to the cinder client
If the bypass_url is specified in the http client, there is no need
to get it from Keystone.

Change-Id: I891849f77ad2ba98a83c993b401121216c8cfff6
closes-bug: #1350702
2014-12-01 02:43:52 +00:00
Jamie Lennox
a68ba9417b Use newer features from keystoneclient
There are a number of functions that were implemented in keystoneclient
in response to needs from cinder and other clients.

Now that these were released in 0.11 cinderclient should make use of
them rather than keep its own versions.

Change-Id: I6444fc5bfd2d0505f9a7eb2c6068ab945ae5bb9b
2014-12-01 02:16:44 +00:00
Jamie Lennox
384b8825b4 Fix incorrect variable name
valid_versions does not exist here, it is obviously supposed to mean
_VALID_VERSIONS.

Closes-Bug: #1386232
Change-Id: I477baa7642feba72f80d884d6183512185b02cf1
2014-10-27 14:41:54 +00:00
Christine Wang
a6b434ee05 cinderclient does not retry with TimeoutException
Added retry support when encounter requests.exceptions.Timeout
during HTTP request.

Closes-Bug: #1379505

Change-Id: I6253a109c3a76dd2f15c96a349da68936f9bfff4
2014-10-24 11:57:42 -04:00
Boris Pavlovic
6f5fd37ee9 Add profiling support to cinderclient
To be able to create profiling traces for Cinder, client should be
able to send special HTTP header that contains trace info.

This patch is as well important to be able to make cross project
traces. (Typical case nova calls cinder via python client, if
profiler is initialized in nova, cinder client will add extra
header, that will be parsed by special osprofiler middleware in cinder
api)

Don't worry no security issue here, trace information is signed by HMAC
key that is setted in api-paste.ini. So only person that knows HMAC key
is able to send proper header.

Main patch (in Cinder) is:
https://review.openstack.org/#/c/103415/

Change-Id: I53bb1b92e62841a02f941bdafaed7f8ed5db7ce1
2014-10-08 19:30:10 +04:00
Bill Arnold
f7d391e5cb client HTTPClient __init__ fails if auth_url None
The initializer for the python-cinderclient HTTPClient class
fails if passed a None for an auth_url.
This patch modifies the inializer to not call rstrip
if auth_url is None, matching the initalizers in
python-novaclient and python-neutronclient

Change-Id: I19dd6911816639a0e0d6175ba910e9777a4b5981
Closes-bug: #1358926
2014-09-09 18:40:31 +00:00
Jamie Lennox
84af49ce97 Use adapter from keystoneclient
The keystoneclient provides an adapter which maintains the client state
around the session. We should re-use this rather than copy it and it
also means we will get new adapter functions and parameters as they
become available.

Change-Id: I05c0d650dcdd69f7e77a06563d735efe521a41ae
2014-09-02 12:38:03 +10:00