151 Commits

Author SHA1 Message Date
Eric Harney
59677fb2e5 remove simplejson requirement
The json lib has been included in CPython for
ages, so the ImportError case never happens.

Change-Id: I669bc397323a0e83d4a9768b124a7d99bafaf38a
2023-01-26 14:30:35 +00:00
zack chen
1f3b663485 Fix extension loading from python path
Commit 3502a5591a654ae57741c6738994ffa9d8457696 broke extension loading
from pythonpath. Incompatible on python3.6.8, python3.8, python3.9. Put
it back.

Closes-Bug: #1980184
Change-Id: I5b67c93e3c789252d9bd35ee69dddbe1b556dec4
2022-06-29 14:38:18 +08:00
Zuul
8561be23f1 Merge "client: Stop logging request-id twice in DEBUG" 2021-08-30 15:39:24 +00:00
Brian Rosmaita
3502a5591a Remove v2 support from the shell
Also removes the v2 support from the generic client and restores a
skipped test.

Additionally, the cinderclient.tests.v2.test_availablity_zone module
depends on the v2.shell class, so move that module to v3, update the
v3 AvailablityZone class, and make appropriate adjustments to the
tests and test fixtures.

Change-Id: I7a3cca15f5944141d510a75af6684221c297963b
2021-07-12 23:04:09 -04:00
Lee Yarwood
0439a44707 client: Stop logging request-id twice in DEBUG
This is already logged by http_log_resp in DEBUG along with the other
response headers so drop the duplicate logging in _log_request_id.

Change-Id: I3c5ad2b480d80611ecb10449068d836c4bbe7bdb
2021-03-10 16:31:49 +00:00
sri harsha mekala
9c2e8df948 Support passing client certificates for server version requests
Using the cinderclient to fetch server versions will fail with error
`OpenSSL.SSL.Error: [sslv3 alert handshake failure]` when the server
requires client certificates to be passed with these requests.

Added the optional parameter `cert` to both get_server_version
get_highest_client_server_version and methods so that users can have
the option to pass client certificates while fetching server versions.

Also support passing mTLS certificate/key to HTTPClient

Closes-Bug: #1915996
Change-Id: I57c665dd9d4b8c32e5f10994d891d1e0f5315548
Signed-off-by: sri harsha mekala <smekala@oath.com>
2021-03-09 09:16:31 -08:00
haixin
cea1f674ae Remove all usage of six library
Replace six with Python 3 style code.

Change-Id: I4b97e040f3e790ac114dcd43c68e6b67b1079adf
2021-03-04 16:03:35 +08:00
Zuul
9bd87c5ce9 Merge "Add commands for default type overrides" 2020-09-16 15:16:48 +00:00
whoami-rajat
7ee7d376a1 Add commands for default type overrides
This patch adds command for set,get and delete default volume types
for projects.

This patch adds 3 commands :

1) Set
Set a default volume type for a project
cinder --os-volume-api-version 3.62 default-type-set <vol-type-id> <project-id>

2) Get
Get the default volume type for a project
cinder --os-volume-api-version 3.62 default-type-list --project-id <project-id>
Get all default types
cinder --os-volume-api-version 3.62 default-type-list

3) Unset
Unset default volume type for a project
cinder --os-volume-api-version 3.62 default-type-unset <project-id>

Implements: Blueprint multiple-default-volume-types

Change-Id: Id2fb00c218edbb98df3193577dba6a897c6e73f6
2020-09-16 12:31:54 +00:00
Zuul
d0f10e3350 Merge "Use importlib to take place of imp module" 2020-09-09 18:07:18 +00:00
zhoulinhui
aebb6011e6 Use importlib to take place of imp module
The imp module is deprecated[1] since version 3.4, use importlib to
instead

[1]: https://docs.python.org/3/library/imp.html

Change-Id: Ie250592bc183e8db1758b6cfa4681a45f4c489ab
2020-09-02 15:59:36 +00:00
Ghanshyam Mann
f85896af2b [goal] Migrate python-cinderclient jobs to focal
As per victoria cycle testing runtime and community goal[1]
we need to migrate upstream CI/CD to Ubuntu Focal(20.04).

Fixing:
- bug#1886298
Bump the lower constraints for required deps which added python3.8 support
in their later version.
- pep8 error
- Set bionic nodeset for py36 and py37 job.


[1] https://governance.openstack.org/tc/goals/selected/victoria/migrate-ci-cd-jobs-to-ubuntu-fo$

Story: #2007865
Task: #40179

Change-Id: Ibab96807a7747738282732fe0069b9bc197da0ee
2020-08-17 14:14:46 +00:00
Zuul
578744aca3 Merge "Stop to use the __future__ module." 2020-08-05 08:31:00 +00:00
Eric Harney
1dc592a6fd Bump hacking to 3.1.0
pycodestyle does not know about "importutils.try_import"
calls, so we have to either
  a) put them inside a "try" block
or
  b) add "# noqa: E402" to each import after the
     try_import call

Change-Id: Ia545bb689cfdfb57962d74e3957dfb372fd3782b
2020-07-16 10:51:55 -04:00
Hervé Beraud
b649d7f4f4 Stop to use the __future__ module.
The __future__ module [1] was used in this context to ensure compatibility
between python 2 and python 3.

We previously dropped the support of python 2.7 [2] and now we only support
python 3 so we don't need to continue to use this module and the imports
listed below.

Imports commonly used and their related PEPs:
- `division` is related to PEP 238 [3]
- `print_function` is related to PEP 3105 [4]
- `unicode_literals` is related to PEP 3112 [5]
- `with_statement` is related to PEP 343 [6]
- `absolute_import` is related to PEP 328 [7]

[1] https://docs.python.org/3/library/__future__.html
[2] https://governance.openstack.org/tc/goals/selected/ussuri/drop-py27.html
[3] https://www.python.org/dev/peps/pep-0238
[4] https://www.python.org/dev/peps/pep-3105
[5] https://www.python.org/dev/peps/pep-3112
[6] https://www.python.org/dev/peps/pep-0343
[7] https://www.python.org/dev/peps/pep-0328

Change-Id: Id785793c36b3a6819a7522525252c3fef15ebe2b
2020-06-02 20:46:48 +02:00
Ian Wienand
d41d7155c0 Replace bypass_url with os_endpoint
The --bypass-url argument was removed with
I3b951cc4eb3adff23f3d2cbe674971816261ef56 so this name does not make
sense now.  Replace with os_endpoint.

Change-Id: Ifa889cc2e885e9c621c8494995b2020195b696ca
2020-03-25 06:08:35 +11:00
Ian Wienand
9c5a850f5a Remove --bypass-url documentation
This was removed with I3b951cc4eb3adff23f3d2cbe674971816261ef56;
cleanup old references.

Change-Id: I71e6da99dff04d86b9dd67a754764b1e742d366a
2020-03-24 18:41:21 +11:00
Ian Wienand
38a44e7ebe Pass os_endpoint to keystone session
The os_endpoint should be passed to the keystone session as the
endpoint_override argument.

This is particularly imprtant for talking to Rackspace, who seem to
have an odd situation where the endpoint is V2 compatible [1], but the
API is still at /v1/ [2] (i think?).

To use the RAX API you need to find your account number, then
something like:

 OS_USERNAME=xyz
 OS_PASSWORD=abc
 OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/
 OS_VOLUME_API_VERSION=2
 CINDER_ENDPOINT=https://dfw.blockstorage.api.rackspacecloud.com/v1/<account#>
 cinder volume list

Should work

Honestly I'm not 100% what's up with the unit test.  I think endpoint
override was not being processed previously, and now it is so it drops
the "admin"?

Story: #2007459
Task: #39138

[1] https://developer.rackspace.com/docs/cloud-block-storage/v1/general-api-info/cbsv1-methods-vs-cinderv2-methods/
[2] https://developer.rackspace.com/docs/cloud-block-storage/v1/general-api-info/service-access/

Change-Id: I6b9a1f088c84676ddf9894cf9524d3239f3cf3a9
2020-03-24 18:39:11 +11:00
Sean McGinnis
ced267b1d5
Raise hacking version to 2.0.0
We've kept hacking capped for a long time now. This raises the hacking
package version to the latest release and fixes the issues that it
found.

Change-Id: I69e41a340c815090f25677607e971a8e75791f6d
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2019-12-21 03:27:48 -06:00
Zuul
5b811d96d0 Merge "Drop support for Cinder v1 API" 2019-09-08 05:27:59 +00:00
Ivan Kolodyazhny
4a3a2c3c9a Add custom CA support for get_server_version
get_server_version fails when self-signed CA cert is used. This patch
adds:
* insecure option to ignore SSL certificate validation
* cacert to add ability to provide a custom SSL certificate

Change-Id: Ib1d34a5a6b595c53473ddd3acb182ab5a39cbba5
Related-Bug: 1744670
2019-08-28 17:28:38 +00:00
Sean McGinnis
2189e5702b Drop support for Cinder v1 API
This drops compatibility with Cinder services with the V1 API.

Change-Id: Ic7c6bd05a3991c3afce3dec80b29501932c5aac9
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2019-04-18 10:33:06 -05:00
Sean McGinnis
ffccfc0eca Handle auth redirects
Our checking for keystone v2 and v3 was causing v2 tests to go down the
v1 code path. Fixing this surfaced a couple of long standing issues with
our v2/v3 handling of redirects and getting auth info.

This fixes our version identification, fixes extracting redirect
location for response headers, and returning the auth_url to calling
code.

Change-Id: I939ff027bf43e513e338bff1e99ca41fa52637b6
Closes-bug: #1825372
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2019-04-18 10:31:58 -05:00
Sean McGinnis
e5217d901d
Fix endpoint identification for api-version query
The api-version query is a GET against the root endpoint of cinder.
Determining this root endpoint had a flaw with the newer wsgi deployment
URLs that would cause it to find the root endpoint of the web server and
not cinder.

This updates the logic to work with legacy, wsgi, and custom URLs for
the Cinder endpoint.

Change-Id: Iaeba1f8d50ee8cc9410cc9f638770a56796871fb
Closes-bug: #1785594
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2018-08-06 10:26:33 -05:00
Sean McGinnis
258586fb18
Update pylint to work with python 3
The pylint job was switched over to run under python 3, but
the job is not voting and it was apparently missed that the
conversion was causing it to fail.

This updates the version of pylint to one that is actually
supported by python 3 and makes tweaks to our script to
for the minor changes between versions.

Single character change to get rid of the more strict py3
regex string escape character format.

Change-Id: I93124b62c5ee177815457b32f55f5453fc3d387e
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2018-07-23 14:05:13 -05:00
Eric Fried
571e5d8c4d Let keystoneauth set the microversion header
Constructing the Adapter with the default_microversion kwarg causes the
Adapter to handle setting the appropriate Openstack-API-Version header.
With this change set, SessionClient now uses the api_version kwarg to
set default_microversion instead of setting the header explicitly.

Change-Id: I5de721fa373f5d3adb42ddb4b5598f19aabfff3b
2017-09-28 20:53:27 +00:00
Jenkins
b372fe6927 Merge "Unsupported 'message' Exception attribute in PY3" 2017-08-29 02:32:01 +00:00
liuyamin
7b601bdb2f Unsupported 'message' Exception attribute in PY3
The 'message' attribute has been deprecated and removed from Python3.
Use six.text_type(e) instead of e.message. For more details, please
check [1]:

[1] https://www.python.org/dev/peps/pep-0352/

Change-Id: Ibd4e7f5fefa6b1dfb6258c5eacfa53cd3485d22c
2017-08-28 02:35:45 +00:00
Jenkins
fd0a11e7d7 Merge "Enable H306" 2017-08-22 14:34:25 +00:00
Ivan Kolodyazhny
19bb7cdf4f Fix get_highest_client_server_version with Cinder API + uWSGI
get_highest_client_server_version should work with any endpoint type:
cinder-api with eventlet, uWSGI, etc.

This patch is based on python-novaclient patch [1]. In a future, we can
deprecate get_highest_client_server_version in flavor of keystoneauth
descovery feature.

[1] Icba858b496855e2ffd71b35168e8057b28236119

Closes-Bug: #1708188
Change-Id: I9acf6dc84c32b25bfe3254eb0f97248736498d32
2017-08-04 17:05:13 +03:00
Eric Harney
60d00b0a03 Enable H306
Enforce ordering of imports with H306.

For tests, this is mostly done by grouping test
imports after other cinderclient imports.

Change-Id: Ie40fda014d1aedb057e5b4ea1f27f999c84e6373
2017-08-01 16:23:49 -04:00
j-griffith
7547e55bbe cinderclient might not return version for V2 API
The get_server_version call in cidnerclient/client.py relies on
either finding v 3.x or encountering an exception to revert back
to v 2.0.  It's not clear that this call will always raise if
a non V3 capable Cinder is called, so just to be safe make sure
we return a 2.0 response if there's no V3 reported back.

Change-Id: I3b5fb895cad4b85d5f4ea286fb33f7dd0929e691
Closes-Bug: #1694729
2017-07-26 11:49:03 -06:00
Chaynika Saikia
0cb09cc560 Add cinder create --poll
Usage: It adds an optional argument --poll to the cinder
create command which waits while the creation of the volume
is completed and the volume goes to available state. In case
there is an error in volume creation, it throws an error message
and exits with a non zero status. The error message printed here
is the async error message in case it generates one.

Depends-On: Ic3ab32b95abd29e995bc071adc11b1e481b32516

Change-Id: I1a4d361d48a44a0daa830491f415be64f2e356e3
2017-07-24 09:06:28 -04:00
Gorka Eguileor
52cc5c6cb3 Fix highest version supported by client and server
Current code mistakenly thinks that 3.40 is older than 3.27, because
it's treating 3.40 as 3.4, thus returning the wrong maximum supported
version by both server and client.

It is also returning a 3.40 version as 3.4 because it's returning it as
a float.

This patch fixes both issues by not using float conversion but using the
APIVersion object to do the comparison and by changing returned type to
a string so it can be used to instantiate a client.

Change-Id: Ica4d718b3de31c31da047f07c5154b242e122596
Closes-Bug: #1705093
2017-07-19 14:45:13 +02:00
Sean Dague
57c50f0bd1 Remove explicit global_request_id from keystoneauth subclass
We've embedded global_request_id into keystoneauth1 now, so the
special handling for the subclass is not needed.

Change-Id: Id45afb9130197887518a8732e046f61396308d58
2017-06-14 11:05:34 +00:00
Sean Dague
5075eb268e support global_request_id in constructor
This allows a global_request_id to be created in the constructor which
will be passed on all subsequent calls to support cross service
request tracking.

oslo spec I65de8261746b25d45e105394f4eeb95b9cb3bd42

Change-Id: Ib271ac01c2a4a36e611ae9181ae93305f2318680
2017-05-25 06:08:30 -04:00
Jenkins
d4347392dc Merge "Remove log translations" 2017-04-11 04:31:37 +00:00
Ivan Kolodyazhny
60f92db704 Fix noauth support
This patch includes several improvements:
1. Use keystoneauth1 plugin mechanism for auth plugins.
2. Implements CinderNoAuthPlugin.
3. Deletes non-working cinderclient.auth_plugin module.
4. Deprecates --bypass-url in flavor of --os-endpoint to be consistent
with keystoneauth1 plugins.
5. Deprecates in --os-auth-system in falvor of --os-auth-type to be
consistent with keystoneauth1 plugins.

Both bypass_url and os_auth_system params are not changed for client
objects to not break backward compatibility for Python API.

How to use noauth with cinderclient CLI:
OS_USER_ID=userid OS_PROJECT_ID=projectis cinder --os-auth-type noauth
--os-endpoint=http://localhost:8776/v2 list

Change-Id: I3be59a5a39235acbc3334e0a0b797081507a5c88
Closes-Bug: #1657156
2017-03-24 13:24:50 +02:00
wanghao
7b213a9a8b Remove log translations
Log messages are no longer being translated.
This removes all use of the _LE, _LI, and _LW
translation markers to simplify logging and to
avoid confusion with new contributions.

See:
http://lists.openstack.org/pipermail/openstack-i18n/2016-November/002574.html
http://lists.openstack.org/pipermail/openstack-dev/2017-March/113365.html

Change-Id: I92f0729448255cec09263eccea4724c0cf9e8b61
Closes-Bug: #1674550
2017-03-21 13:07:01 +08:00
Gorka Eguileor
c022b73faf Fix pep8 errors
There are some PEP8 errors that are not caught by our gate because of
the pep8 package version installed by hacking.

This patch fixes E402, W503, and F999 erors from our codebase.

Change-Id: I0b86730b1493f161645a87c3daa91ec3d774d3b1
2017-03-15 13:42:49 +01:00
John Griffith
a127c2f82d Remove duplicate get_highest_client_server_version
The client method get_highest_client_server_version
was so nice, we added it twice.  Turns out it's not so
nice and one is more than enough.

This patch removes the duplicate.

Change-Id: Ic5ad022e7cd0322c319bfb412e3113c121848fe0
2017-03-10 16:59:09 +00:00
Jenkins
5badc3ef31 Merge "Fix discover_version" 2017-03-10 14:26:31 +00:00
scottda
3220566e46 Fix discover_version
discover_version needs to find the proper module for server_api_version
method, and it needs to properly parse a list of versions.
Do some refactor to clean things up.
Add unit tests.

Co-Authored-By: waj334 <justin.wilson@intel.com>
Change-Id: I742bc33074cc55fe5f9682b8b97a82573c51183f
Closes-Bug: #1632872
2017-03-09 21:42:28 +00:00
Gábor Antal
84346b5dba Handle log message interpolation by the logger
According to OpenStack Guideline[1], logged string message should be
interpolated by the logger.

[1]: http://docs.openstack.org/developer/oslo.i18n/guidelines.html#adding-variables-to-log-messages

Change-Id: Ib5f86d1f0846e292457813c893b73c6999e554a5
Closes-Bug: #1596829
2017-02-07 16:22:27 +01:00
scottda
d10b467af4 static method to get_highest_client_server_version
This method takes a url for the cinder server endpoint and queries
the server for version info. It then returns the min of the server's
highest supported version and the cinderclients MAX_VERSION.

Change-Id: Ifb3478f1dba660a5d75d243dc2aaf6b421940752
2017-01-31 09:29:17 -07:00
Jenkins
fc976390e2 Merge "static method to get_server_version" 2017-01-26 23:57:36 +00:00
scottda
4f22510ccf static method to get_server_version
This is a static method that takes a url for the cinder endpoint
and returns the server's min and max api version as APIVersion objects.

Change-Id: I33fa9d0883ad7377c480c9e230412dfa487ccbc9
2017-01-26 13:18:21 -07:00
Abhishek Kekane
6962056c67 x-openstack-request-id logged twice in logs
In the recent release of keystoneauth1 2.18.0 provision is made to log
x-openstack-request-id for session client. Once this new library is synced
in openstack projects, the x-openstack-request-id will be logged twice
on the console if session client is used.

For example,
$ cinder --debug list

DEBUG:keystoneauth:GET call to volumev2 for
http://10.232.48.204:8776/v2/61da9e4b59cf4920acc5e78438f93223/volumes/detail
used request id req-dcc22730-021e-468a-8b12-da7d58b573a7

DEBUG:cinderclient.client:GET call to volumev2 for
http://10.232.48.204:8776/v2/61da9e4b59cf4920acc5e78438f93223/volumes/detail
used request id req-dcc22730-021e-468a-8b12-da7d58b573a7

Above log will be logged twice on the console.

Removed logging of x-openstack-request-id in case of SessionClient as it
is already logged in keystoneauth1. x-openstack-request-id will only be
logged once on console if HTTPClient is used.

Depends-On: Id0693a9958d26162b7a2a40173ca28de2d3e4f62
Closes-Bug: #1657351

Change-Id: I0861212a38466d0e65cf3389c7d2757cff86ea0d
2017-01-23 11:53:13 +05:30
Jenkins
93d09ebc06 Merge "Support Keystone V3 with HttpClient" 2017-01-18 13:05:18 +00:00
zhangchenchen
690d6ea8c8 modify the wrong comment of the Client class
modify comment which is misleading under Client
class(/cinderclient/client.py).
change the third parameter PROJECT_ID to PROJECT_NAME.

Change-Id: I3f39f54a23b3182f2136ae5a14e3c30096f3f2c8
Fixes:bug #1654957
2017-01-09 17:16:14 +08:00