summaryrefslogtreecommitdiff
path: root/cinderclient/tests/unit
Commit message (Collapse)AuthorAgeFilesLines
* Merge "Add test coverage for shell snapshot-create w/ metadata"Zuul2023-02-131-0/+18
|\
| * Add test coverage for shell snapshot-create w/ metadataEric Harney2022-11-171-0/+18
| | | | | | | | | | | | This path is not currently unit tested. Change-Id: If38c6352f5e1f0a50e4a0d29fbdd5263ccba3b29
* | Merge "Move print operations to shell_utils"Zuul2023-01-263-16/+16
|\ \
| * | Move print operations to shell_utilsEric Harney2022-11-153-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move more code to shell_utils that is only used for shell operations. The benefit of this is that the cinderclient library becomes lighter-weight, because users of the lib no longer have to import prettytable and extra code. Change-Id: I7bf6bd91ee5746d1ad4bd4504f3a056d03ae86a9
* | | Python3.11: fix crashes in ShellTestCyril Roelandt2022-12-211-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Python3.11, global flags must be placed right at the start of a regular expression. The following regex: r'.*?(?m)^Lists all volumes.', must become: r'(?m).*?^Lists all volumes.', However, since we are using re.MULTILINE, we actually do not need to use a global flag. This commit fixes the following tests in Python3.11: - cinderclient.tests.unit.test_shell.ShellTest.test_help_arg_no_subcommand - cinderclient.tests.unit.test_shell.ShellTest.test_help - cinderclient.tests.unit.test_shell.ShellTest.test_help_on_subcommand - cinderclient.tests.unit.test_shell.ShellTest.test_help_on_subcommand_mv Closes-Bug: #1983047 Change-Id: If20abef109ddd7107c83b5886beb666a6550a640
* | | Merge "Python3.11: Fix argparse-related test failures"Zuul2022-12-121-4/+13
|\ \ \ | |_|/ |/| |
| * | Python3.11: Fix argparse-related test failuresCyril Roelandt2022-07-281-4/+13
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Python3.11, the following code crashes: $ cat test.py import argparse parser = argparse.ArgumentParser(description='Short sample app') subparsers = parser.add_subparsers() subparsers.add_parser('foo') subparsers.add_parser('foo') $ python3.11 test.py Traceback (most recent call last): File "/tmp/arg.py", line 6, in <module> subparsers.add_parser('foo') File "/usr/lib/python3.11/argparse.py", line 1197, in add_parser raise ArgumentError(self, _('conflicting subparser: %s') % name) argparse.ArgumentError: argument {foo}: conflicting subparser: foo It is now forbidden to use add_parser() multiple times with the same arguments, which is exactly what we do in the following tests: - cinderclient.tests.unit.test_shell.TestLoadVersionedActions.test_load_versioned_actions - cinderclient.tests.unit.test_shell.TestLoadVersionedActions.test_load_actions_with_versioned_args In order to fix the tests failures, we make sure to reset the parser and subparsers before calling add_parser(). While not strictly necessary, we split those tests into two functions, for readability purposes. Closes-Bug: #1983054 Change-Id: I2d4cb81a394f3c10e5f01945d894746a904fb5df
* | Handle downgraded client for snapshot-create9.2.0Brian Rosmaita2022-11-081-0/+76
|/ | | | | | | | | | | | | | | | | | | When a CLI user specifies --os-volume api-version 3.66, the shell will execute the appropriate shell code, but if the server only supports < 3.66, the client is automatically downgraded and correctly uses the pre-3.66 SnapshotManager.create() method. In that case, the 'force' parameter, which is technically not allowed in mv 3.66 (but which silently accepts a True value for backward compatibility), will have a value of None, which the pre-3.66 code happily passes to cinder as '"force": null' in the request body, and which then fails the Block Storage API request-schema check. Handle this situation by detecting a None 'force' value and setting it to its pre-3.66 default value of False. Change-Id: I3ad8283c2a9aaac58c8d2b50fa7ac86b617e5dd3 Closes-bug: #1995883
* Add volume reimage commandwhoami-rajat2022-02-244-0/+31
| | | | | | | | | | 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
* Support Block Storage API mv 3.66Brian Rosmaita2021-09-021-0/+61
| | | | | | | | | | | | | | 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
* Add consumes quota field supportGorka Eguileor2021-08-251-4/+6
| | | | | | | | | | | | | | 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
* Merge "Make instance_uuid optional in attachment create"8.0.0Zuul2021-07-203-1/+64
|\
| * Make instance_uuid optional in attachment createRajat Dhasmana2021-07-143-1/+64
| | | | | | | | | | | | | | | | | | | | | | 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
* | Remove v2 classesBrian Rosmaita2021-07-1430-263/+181
| | | | | | | | | | | | | | | | | | 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
* | Remove v2 support from the shellBrian Rosmaita2021-07-127-1393/+87
| | | | | | | | | | | | | | | | | | | | | | | | 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
* | Merge "Support passing client certificates for server version requests"Zuul2021-04-202-2/+27
|\ \ | |/ |/|
| * Support passing client certificates for server version requestssri harsha mekala2021-03-092-2/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Merge "Add flake8-import-order extension"Zuul2021-03-1114-29/+18
|\ \
| * | Add flake8-import-order extensionSean McGinnis2021-03-1014-29/+18
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | Dropping explicit unicode literaltushargite962021-03-111-7/+7
|/ | | | | | | | | 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
* Merge "Remove all usage of six library"Zuul2021-03-0812-65/+28
|\
| * Remove all usage of six libraryhaixin2021-03-0412-65/+28
| | | | | | | | | | | | Replace six with Python 3 style code. Change-Id: I4b97e040f3e790ac114dcd43c68e6b67b1079adf
* | Support backup-restore to a specific volume type or AZAlan Bishop2021-01-111-0/+157
|/ | | | | | | | | | | | | 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
* Fix undesirable raw Python errorEduardo Santos2020-10-291-0/+12
| | | | | | | | | | | | | | 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
* Add commands for default type overrideswhoami-rajat2020-09-163-0/+126
| | | | | | | | | | | | | | | | | | | | | | | | | 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
* [goal] Migrate python-cinderclient jobs to focalGhanshyam Mann2020-08-172-2/+2
| | | | | | | | | | | | | | | | | | | | 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
* Merge "Stop to use the __future__ module."Zuul2020-08-051-2/+0
|\
| * Stop to use the __future__ module.Hervé Beraud2020-06-021-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Bump hacking to 3.1.0Eric Harney2020-07-161-2/+2
| | | | | | | | | | | | | | | | | | | | | | 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
* | Use unittest.mock instead of third party mockSean McGinnis2020-06-0512-33/+32
|/ | | | | | | | 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>
* Merge "Replace bypass_url with os_endpoint"Zuul2020-04-072-4/+4
|\
| * Replace bypass_url with os_endpointIan Wienand2020-03-252-4/+4
| | | | | | | | | | | | | | | | The --bypass-url argument was removed with I3b951cc4eb3adff23f3d2cbe674971816261ef56 so this name does not make sense now. Replace with os_endpoint. Change-Id: Ifa889cc2e885e9c621c8494995b2020195b696ca
* | Merge "Add support for Block Storage API mv 3.60"Zuul2020-04-061-0/+18
|\ \ | |/ |/|
| * Add support for Block Storage API mv 3.60wanghao2020-04-061-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* | Pass os_endpoint to keystone sessionIan Wienand2020-03-241-1/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Add filters support for volume transferRajat Dhasmana2020-02-121-0/+32
| | | | | | | | | | | | | | | | | | Currently ``id`` and ``volume_id`` filters are working correctly for transfer-list command. support for filtering by ``name`` is handled in patch provided in Depends-On. Since filtering by all parameters is supported by API, we can happily add the filters option on the client for volume transfers. Also adds functional test for transfers. Related-Bug: #1860100 Depends-On: https://review.opendev.org/#/c/703658/ Change-Id: I2fd3a6a7b9add65a9a21388df44efb6747065a74
* Merge "Raise hacking version to 2.0.0"Zuul2020-02-122-50/+51
|\
| * Raise hacking version to 2.0.0Sean McGinnis2019-12-212-50/+51
| | | | | | | | | | | | | | | | | | 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>
* | Merge "Add test for subcommands"Zuul2020-02-121-0/+118
|\ \
| * | Add test for subcommandsEric Harney2019-11-121-0/+118
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This tests that the expected subcommands register in the shell client, by looking at the output that would show up in "cinder help". The purpose of this is to help prevent us from accidentally deleting some commands when refactoring shell code. TODO: cover commands post-3.0 Change-Id: Ifcbc08ae9184fa33049b18f8ad7ef5d92003a7b8
* | | Merge "Fix: --poll inconsistency"Zuul2020-02-121-1/+0
|\ \ \ | |_|/ |/| |
| * | Fix: --poll inconsistencywhoami-rajat2019-12-051-1/+0
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we use `--poll` parameter with cinder create command, it waits for the volume to become available but doesn't update the data displayed to the user. Due to this, there are inconsistency between several parameters in the output after 'poll' and 'cinder show' command. Eg: cinder create 1 --image <image-id> --poll shows 'bootable' flag as false whereas, cinder show <vol-id> shows 'bootable' as true Change-Id: I1502e88f1cd84d225b75c07313e4eb252cc2d645 Closes-Bug: #1855224
* | Merge "Update hacking version"Zuul2019-12-121-2/+2
|\ \ | |/ |/|
| * Update hacking versionjacky062019-10-301-2/+2
| | | | | | | | | | | | Use latest release 1.1.0 and compatible changes w.r.t pep8 Change-Id: I1ae708f0753249226ceb47610a1a4d0b558c1d0e
* | Merge "Drop support for --sort_key and --sort_dir"5.0.0Zuul2019-09-113-70/+2
|\ \ | |/ |/|
| * Drop support for --sort_key and --sort_dirSean McGinnis2019-09-113-70/+2
| | | | | | | | | | | | | | | | | | These arguments were deprecated in the kilo release in favor of a combined --sort argument. This drops support for the deprecated arguments. Change-Id: If8f8ac44cc81f553009a15ca67257e86cb925b6f Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* | Merge "Drop support for --allow-multiattach"Zuul2019-09-115-9/+5
|\ \ | |/
| * Drop support for --allow-multiattachSean McGinnis2019-09-115-9/+5
| | | | | | | | | | | | | | | | | | | | The ability to enable multiattach on the command line was deprecated in Queens with the full implementation of multiattach enabling it through volume type extra specs. This removes the command line arg and handling for specifying it with volume creation. Change-Id: Ifc0c874657f959266050cd1a7a40e6ecccc8c114 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
* | Merge "Optional filters parameters should be passed only once"Zuul2019-09-112-1/+41
|\ \ | |/ |/|
| * Optional filters parameters should be passed only oncewhoami-rajat2019-09-052-1/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch does the following : 1) Errors out if similar type of filters args are passed Eg : cinder list --name abc --name xyz cinder list --name abc --filters name=xyz 2) Allows multiple filter parameters of different type cinder list --filters name=abc --filters size=1 Change-Id: I2f8662555f830b0821147324849d04e7a29d0580