1221 Commits

Author SHA1 Message Date
whoami-rajat
12075cb710 Add volume reimage command
A new reimage API will be introduced on cinder API side with
change in depends on. This patch provides the CLI support for
the same by adding a reimage command.

Implements: blueprint add-volume-re-image-api

Change-Id: I37c254d4caf2f416e456ff6a78b5a4df4e08a176
2022-02-24 23:13:19 +05:30
whoami-rajat
e268778d3e Improve help text of volume create command
This patch adds information about whichever default type is set for
API will be used during volume creation if we don't provide a
volume type in volume create command.
This patch also improves the help text of `cinder type-default` command.

Change-Id: I0c437b2c4f02c12d17c04719cbeff8521647ae15
2021-11-08 09:46:59 -05:00
Brian Rosmaita
c3c15f6cb2 Support Block Storage API mv 3.66
Block Storage API mv 3.66 enables snapshots of in-use volumes
without requiring a 'force' flag.  For backward compatibility,
the API silently accepts force=true, even though the 'force' flag
is considered invalid for that call.  That behavior is replicated
in the client, where --force with a true value is silently accepted.
The --force option is not advertised in the shell and an option
value that doesn't evaluate to true raises an UnsupportedAttribute
error.  Similar behavior from the v3 Snapshot class, except it
raises a ValueError under similar circumstances.

Change-Id: I7408d0e3a5ed7f4cbcaf65cf3434ad60aaed511d
2021-09-02 18:48:28 -04:00
Zuul
0a685a7937 Merge "Fix list resources when use limit and with-count" 2021-08-30 15:58:38 +00:00
Zuul
8561be23f1 Merge "client: Stop logging request-id twice in DEBUG" 2021-08-30 15:39:24 +00:00
Gorka Eguileor
f94908008e Add consumes quota field support
Cinder microversion v3.65 adds consumes_quota key to volume and
snapshots as a way to differentiate between use generated resources and
temporary ones.

This patch adds support for this microversion and presents the
consumes_quota field when the server sends it (which only happens when
we request this microversion).

Change-Id: I524490aa988fa4d654bfa8050d89cf99ce50bb4b
Depends-On: I655a47fc75ddc11caf1defe984d9a66a9ad5a2e7
Implements: blueprint temp-resources
2021-08-25 17:17:46 -04:00
Zuul
e03111dea3 Merge "Make instance_uuid optional in attachment create" 2021-07-20 17:06:47 +00:00
Brian Rosmaita
cb5235250c Remove v2 classes
Remove all cinderclient.v2 classes, mostly incorporating them into
their v3 counterparts and updating the tests and test fixtures.

Depends-on: https://review.opendev.org/c/openstack/horizon/+/800814

Change-Id: I335db5c1799edb2273bf8bfc9e1bc9de404a4ba5
2021-07-14 14:28:44 -04:00
Rajat Dhasmana
d714249ca9 Make instance_uuid optional in attachment create
Cinder and cinderclient assumes an attachment create request will
always contain instance_uuid. This is not true when glance calls
cinder for attachment in glance cinder configuration.
This patch (along with the cinder patch) make the instance_uuid
optional and allow glance to do attachments without passing
instance_uuid.

Change-Id: Ifbaca4aa87d890bc5130069638d42665b914b378
2021-07-14 11:20:28 -04: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
Zuul
c559f090ff Merge "Support passing client certificates for server version requests" 2021-04-20 21:50:38 +00:00
Zuul
e87be61edb Merge "Add flake8-import-order extension" 2021-03-11 17:43:10 +00:00
tushargite96
d9213138b1 Dropping explicit unicode literal
In python 3, all strings are considered as unicode string.

This patch drops the explicit unicode literal (u'...')
or (u"..") appearances from the unicode strings.

Change-Id: I9902966892a1dc4f85d449dfe580fb128647487b
2021-03-11 08:32:54 -05:00
Zuul
36e22faddd Merge "Bump API max version to 3.64" 2021-03-10 22:04:12 +00:00
Sean McGinnis
82f0ceb724 Add flake8-import-order extension
This adds the import order extension to match what we have in the cinder
repo. This is a linting extension that will check that imports are in
the correct order and the correct grouping so they automatically get
flagged, and it won't be whether reviewers notice and decide to do
anything or not.

Cinder change was Ic13ba238a4a45c6219f4de131cfe0366219d722f for a little
more wordy reasoning.

Also includes updates for noqa tags. Newer version of the linters appear
to want these on the function definition line, not on the decorator
line.

Change-Id: Ibf3f3afbf3bb6ec6613b35f91d4a353c6a391f41
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2021-03-10 15:04:27 -05:00
Zuul
5e4e663619 Merge "Remove more python2 compat code" 2021-03-10 18:01:33 +00: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
Alan Bishop
da7a49f679 Bump API max version to 3.64
Bump MAX_VERSION to 3.64 to support including the encryption_key_id
attribute in volume and backup details.

Implements: blueprint include-encryption-key-id-in-details
Depends-On: I16f54e6722cdbcbad4af1eb0d30264b0039412fd
Change-Id: I6e1f3ff62d4b7b9b8299f7bd73071c3c7856f6df
2021-03-09 16:36:55 -08:00
Zuul
617fdb9ca6 Merge "Add MV 3.63 to the max supported version" 2021-03-10 00:21:59 +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
Zuul
8e804292db Merge "Remove all usage of six library" 2021-03-08 16:02:59 +00:00
Eric Harney
23e7f0cb34 Remove more python2 compat code
Remove code still adjusting for Python 2
behavior based on version checks.

Change-Id: I29576a824278611d80991dce2501f14f1b262c76
2021-03-08 09:06:14 -05: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
Rafael Weingärtner
070307d2b4 Add MV 3.63 to the max supported version
During the implementation on [1], it was requested to extend the Cinder
client to support the newly created microversion (MV). Therefore, this
patch is doing exactly that.

We do not need to do any other work forward bcause the list volumes
will display whatever we have in the response. I mean, the default is
``['ID', 'Status', 'Name', 'Size', 'Volume Type', 'Bootable',
'Attached to']``, but one can customize these fields using ``--fields``

[1] https://review.opendev.org/c/openstack/cinder/+/666886

Closes-Bug: https://bugs.launchpad.net/python-cinderclient/+bug/1913474
Depends-on: https://review.opendev.org/c/openstack/cinder/+/666886

Change-Id: I0815570a50e9b38fe18733c727acd52a406bfc1e
2021-01-27 17:48:06 -03:00
Alan Bishop
7e3566ed04 Support backup-restore to a specific volume type or AZ
Enhance the 'backup-restore' shell command to support restoring a
backup to a newly created volume of a specific volume type and/or in a
different AZ. New '--volume-type' and '--availability-zone' arguments
leverage the existing cinder API's ability to create a volume from a
backup, which was added in microversion v3.47.

The shell code is a new v3 implementation, and it drops support for the
v2 command's deprecated '--volume-id' argument.

Change-Id: Ic6645d3b973f8487903c5f57e936ba3b4b3bf005
2021-01-11 13:05:11 -08:00
zhu.boxiang
14bc1360e0 Fix list resources when use limit and with-count
When we use with-count query param, we will get the
count of resources. While the _list function return
two different result, one is just list, another is
tuple with list and int.

So we must to handle the items which return from _list
function.

Closes-bug: #1908474
Change-Id: If8e31a637cf098cca60d8a10e9835ef66a3e66bc
2020-12-17 16:16:48 +08:00
Eduardo Santos
d92f15a09e Fix undesirable raw Python error
Using the cinderclient without a subcommand while
passing an optional argument triggers the raw Python
error `ERROR: 'Namespace' object has no attribute
'func'`. This bug can be reproduced by issuing the
command `cinder --os-volume-api-version 3.40`.
Added a default value to `func` and an empty value to
`command` as placeholders so that a help message is
shown instead of the Python error.

Change-Id: Idb51e8635b97f0da2976f3268d5e19100ec77203
Closes-Bug: #1867061
2020-10-29 15:09:26 +00: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
Zuul
76f2b91d9a Merge "[goal] Migrate python-cinderclient jobs to focal" 2020-09-04 02:45:47 +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
Zuul
12a6dc2ea5 Merge "Add support for Cinder API mv3.61" 2020-09-02 15:50:21 +00:00
Zuul
9a6c4253d6 Merge "Clean up some old v1 API references" 2020-08-21 14:40:55 +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
20cfe02dc1 Merge "use stevedore to load util plugins" 2020-08-05 09:16:42 +00:00
Zuul
578744aca3 Merge "Stop to use the __future__ module." 2020-08-05 08:31:00 +00:00
Ivan Kolodyazhny
a9e9b762fd Add support for Cinder API mv3.61
Microversion 3.61 adds cluster_name attribute to volume details output
for admin users.

Change-Id: I13f85c8ddd4cb238a245c263151123fd271a9927
Depends-On: https://review.opendev.org/742991
2020-07-24 23:31:52 +03: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
Doug Hellmann
37f6a30794 use stevedore to load util plugins
Importing pkg_resources has a side-effect of scanning all of the
installed python modules looking for entrypoints to build an in-memory
cache. Stevedore will be adding an on-disk cache to speed that process
up, which should provide significant performance benefits for client
applications such as python-openstackclient. This change introduces
stevedore to replace pkg_resources.

Change-Id: I66decf6d5a4f79ddaa6617737e9334a56dbbbad4
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
2020-07-05 15:51:53 -04:00
Zuul
b6b308ed23 Merge "Use unittest.mock instead of third party mock" 2020-06-22 22:34:30 +00:00
Luigi Toscano
718474a092 Fix typo: dow -> down
Closes-Bug: #1883674
Change-Id: I4f4468b23d04ecf74fb6347bfb518377127b563d
2020-06-16 11:04:08 +02:00
Sean McGinnis
4e24fd614b Use unittest.mock instead of third party mock
Now that we no longer support py27, we can use the standard library
unittest.mock module instead of the third party mock lib.

Change-Id: Ia41326a601dfd72750bd81c3ebee9ec5884ad91b
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-06-05 09:52:09 -05:00
Sean McGinnis
1021aee31f Add directive to document CLI
Our CLI docs are very out of date. These used to be generated by the
docs team with some tooling they had. Since the docs moved in-repo, that
tooling has gone away, and for the most part no one has done any updates
to the CLI docs.

This adds a sphinx directive that will generate these docs every time
the docs are built. This way, whenever someone makes a CLI change, they
do not need to have to know to also edit a documentation file to match
their change. Any code changes will automatically be picked up and
reflected in the docs.

Change-Id: I4406872ab6e9335e338b710e492171580df74fa5
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-06-03 22:19:10 -05:00
Sean McGinnis
2d3bcebf7f Clean up some old v1 API references
This removes some code that was still pointing to the V1 API. No need to
add release note or additional announcements since this was all removed
long ago, and if anyone would have gone down this code path it would
have just blown up trying to import the v1 code that is no longer there.

Change-Id: I7d239d3fe3d879e4c391e83cae1e394cf1f5e6eb
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
2020-06-02 17:35:53 -05: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
Zuul
1dfe4ce093 Merge "Replace bypass_url with os_endpoint" 2020-04-07 17:18:59 +00:00
Zuul
9d72ca21b0 Merge "Add support for Block Storage API mv 3.60" 2020-04-06 17:26:09 +00:00
wanghao
26a55de681 Add support for Block Storage API mv 3.60
Change I1f43c37c2266e43146637beadc027ccf6dec017e adds time-comparison
filtering to the volume list calls (summary and detail) in the Block
Storage API microversion 3.60.  The current cinderclient filter
support will pass these filters correctly, so the only change needed
on the client side is to bump the MAX_VERSION so that the client
can make calls to mv 3.60.

Co-authored-by: Brian Rosmaita <rosmaita.fossdev@gmail.com>
Change-Id: Ib4b7cbc7e527c0524336e139e127f19accfb7568
Partially-Implements: bp support-to-query-cinder-resources-filter-by-time-comparison-operators
2020-04-06 10:19:39 -04: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