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
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
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
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
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
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
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
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
Changes to cinderclient to use microversions.
Implements: blueprint api-microversion-support-for-cinderclient
api-microversion-support-for-cinderclient
Change-Id: I840a1162b88e8ff36fa3fc4e1d6b9317104df3e0
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
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
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
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
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
This patch changes extension suffix from 'python_cinderclient_ext' to
'cinderclient_ext' to get more shorter module names.
Change-Id: Id78e05646d2bc4fda758710eb630dca5eefa457f
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
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
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.
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
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>
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
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
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
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
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
This patch drops the import_class method from utils and instead
leverages the one in openstack.common.importutils.
Change-Id: I9f740b9941d477776597c4c4ab88a65a39fb4fb8
Closes-bug: 1365273
If an auth_plugin is used do not try to load the session
from the default keystone providers.
Change-Id: If2a87e23cabde006833de70e5c7aa066d95dbf50
Closes-Bug: #1380729
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
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
valid_versions does not exist here, it is obviously supposed to mean
_VALID_VERSIONS.
Closes-Bug: #1386232
Change-Id: I477baa7642feba72f80d884d6183512185b02cf1
Added retry support when encounter requests.exceptions.Timeout
during HTTP request.
Closes-Bug: #1379505
Change-Id: I6253a109c3a76dd2f15c96a349da68936f9bfff4
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
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
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