Commit graph

380 commits

Author SHA1 Message Date
Rajat Dhasmana
205bac3caf Fix: incremental volume backup
The incremental volume backup stopped working after we moved from
cinderclient to SDK[1]. This happened because SDK accepts the
``is_incremental`` parameter[2] rather than the ``incremental`` parameter
which is actually passed in the API request and was previously a valid
parameter for cinderclient.

This patch fixes the issue by passing the ``is_incremental`` field instead
of ``incremental`` from the OSC side which adds the ``incremental`` parameter
in the API request.

Request body after the fix:

'{"backup": {"name": null, "description": null, "volume_id": "<vol-id>",
"force": false, "container": null, "incremental": true}}'

[1] https://review.opendev.org/c/openstack/python-openstackclient/+/889748
[2] 10e5e20fc0/openstack/block_storage/v2/backup.py (L126-L134)

Closes-Bug: #2070080
Change-Id: I89bd3d2751267ec39f4dbd664b7873ab87a9ac6c
2024-07-01 21:11:46 +05:30
Rajat Dhasmana
ca81b1acf0 Add cluster to volume service list
This patch adds the ``Cluster`` and ``Backend State`` columns to
the ``openstack volume service list`` command. Note that you need
to provide the appropriate microversion to show these columns.

Cluster: openstack --os-volume-api-version 3.7 volume service list
Backend State: openstack --os-volume-api-version 3.49 volume service list

Change-Id: Ie7727d0001307b5d5a40d7ea0348bdb9626f9e03
2024-06-27 19:37:15 +05:30
Rajat Dhasmana
fdc2763ac2 Add support for volume unmanage
This patch adds support for unmanaging a volume with the
``openstack volume delete --remote`` command.

Change-Id: Id71681e817f6e56b4ef553079f0bcfac8252d3cf
2024-06-10 20:48:30 +05:30
Rajat Dhasmana
00af14b3f2 Add DeleteVolume class to v3
This is done to support the volume unmanage command.

Change-Id: Ib59b1f599be152a25c4b6a31988c28079f552ba9
2024-05-15 11:55:50 +05:30
Rajat Dhasmana
cc7773f53b Add support for managing volumes
This patch adds support for the cinder manage command to
bring a volume under OpenStack management.

Change-Id: I12b63bfc4f0c9bc29cf9d4efd9a5cd038ec00af3
2024-05-15 11:53:27 +05:30
Rajat Dhasmana
0d9ace6425 Add CreateVolume class to v3
This patch acts as a base framework to add the parameters needed
for manage volume support.
This includes 2 changes:
1. Move get_parser and take_action code to common methods which
can be utilized by both v2 and v3
2. Make _check_size_arg as a static method and move it inside
CreateVolume class since it's not used by other classes.

[2] was initially thought to be a follow up change but since we
are implementing changes into the _check_size_arg method for v3,
it makes sense to just include it in CreateVolume class to avoid
adding a new additional method. Similar changes are done for v2
as well.

Change-Id: I9315e457ebd6c5ba4cc67452f92c9dc8c139ee3c
2024-05-15 11:46:12 +05:30
Stephen Finucane
c5b772db76 trivial: Prepare for pyupgrade pre-commit hook
This change is entirely automated save for the update of some mocks from
'io.open' to '__builtins__.open').

We are keeping this change separate from addition of the actual hook so
that we can ignore the commit later.

Change-Id: I0a9d8736632084473b57b57b693322447d7be519
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-04-23 12:24:23 +01:00
Stephen Finucane
0646f9b4e4 tox: Remove bandit skips, run via pre-commit
Most of these skips were unnecessary. The few that did generate warnings
could be skipped.

We also set 'skip_install' since there's no reason to build the package
for linting purposes.

Change-Id: I9644e5c19720b9c41c60e0a5882b7cd7f6a71f7b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-04-26 13:17:15 +01:00
Zuul
9467b404c7 Merge "volume: Deprecate '--retype-policy' in favor of '--migration-policy'" 2024-04-08 12:36:54 +00:00
Zuul
1a38af53eb Merge "volume list: Don't call nova if no volume is attached" 2024-04-08 11:40:41 +00:00
Rajat Dhasmana
5a18f995a8 volume: Deprecate '--retype-policy' in favor of '--migration-policy'
The '--retype-policy' option is used in the 'volume set' command to
specify the migration policy during the retype operation. The
'--retype-policy' option does not convey the correct meaning of its
usage. The migration policy determines whether we are going to perform
the migration in the retype operation or not and is not related to the
actual retype which just changes the volume type of the volume.

Change-Id: I2ea8fd3f5277bb3422ccae915d05e8ad44ff1912
2024-04-08 11:37:42 +01:00
Stephen Finucane
c128ae1969 trivial: Don't ignore missing resources
An openstacksdk 'find_foo' proxy method will return None by default if a
resource is not found. You can change this behavior by setting
'ignore_missing=False'. We were doing this in most, but not all cases:
correct the issue.

In the event of calling 'image delete' with multiple images, it will no
longer fail on the first missing image and will instead attempt to
delete remaining images before failing.

Change-Id: I1e01d3c096dcaab731c28e496a182dd911229227
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2024-02-13 16:33:56 +00:00
Rajat Dhasmana
c657047d7e volume list: Don't call nova if no volume is attached
Currently 'openstack volume list' calls nova to resolve server UUIDs
to server names. This is not required if:
1. no volume is attached to an instance
2. no volume exists in deployment

This patch fixes this by checking volume statuses and, if any volume has
status 'in-use', we will call nova to resolve server names.
Note that we don't check for 'reserved', 'attaching', 'detaching'
states since those are transition states and doesn't guarantee that
the volume is actually attached to the instance.

Change-Id: Ic4d89db69244d3fba44d4b69c79b3e7632ee3d53
2023-12-06 17:39:03 +05:30
Rajesh Tailor
71839eb5fa [codespell] fix typos in doc,tests and help messages
Change-Id: I4823782daa1af3872bc22603147e3073152cc777
2023-11-21 11:31:07 +05:30
Zuul
0b78dfe30b Merge "Add pagination helpers" 2023-11-07 08:47:24 +00:00
Stephen Finucane
c7e3529dea Add pagination helpers
Add some pagination helpers to configure pagination parameters for
various commands. Two pagination schemes are supported, based on what we
currently support across OSC commands: marker-based pagination and
offset-based pagination.

Change-Id: I551bb4c3ff0568c6df5244a1d0f0669497bee58f
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-11-03 23:16:18 +00:00
Zuul
dfcb8b0ee7 Merge "trivial: Make better use of argparse" 2023-10-31 15:00:24 +00:00
Zuul
5883bcecd4 Merge "volume: Add alias for volume type AZs" 2023-10-31 15:00:20 +00:00
Zuul
e13f948ae5 Merge "volume: Add aliases for common volume type props" 2023-10-31 15:00:18 +00:00
Zuul
456c66ff63 Merge "volume: Allow filtering volume types by properties" 2023-10-31 14:53:36 +00:00
Zuul
d735b6cc07 Merge "volume: Support same_host, different_host hint as list" 2023-10-31 14:53:35 +00:00
Johannes Kulik
60a0e379a4 volume: Support same_host, different_host hint as list
When creating a volume, the scheduler hints can be supplied as strings.
The "same_host" and "different_host" hints can also be supplied as a
list if affinity/anti-affinity to multiple volumes is requested [0]

The previously-used `KeyValueAction` only supplies strings as values - the
last one if multiple --hint contain the same key. An alternative already
used in `CreateServer` would be `KeyValueAppendAction`, but only a subset of
the scheduler hints accept lists, so we cannot use that in general.

Therefore, we create `KeyValueHintAction`. It contains both a
`KeyValueAction` and a `KeyValueAppendAction` object and calls the
appropriate action based on the beginning of the given values as defined
in `APPEND_KEYS`.

[0] d96b705774/cinder/api/schemas/scheduler_hints.py (L31-L65)

Change-Id: Ida7f4662dc9fea24510758541fd4f2622b73bf31
2023-10-31 09:22:25 +01:00
Rajat Dhasmana
ae10851a68 Migrate resource filter commands to SDK
This patch migrates ``block storage resource filter list`` and
``block storage resource filter show`` commands to SDK.

Change-Id: Ibc50963954418aab0be35e120f8dcfadbe4020b8
2023-10-30 12:06:14 +05:30
Stephen Finucane
2a2a6e1781 trivial: Make better use of argparse
Change-Id: Ib76c0d18bf5e44bfb4dcd9d729d9a1c5635cdba7
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-10-27 17:58:36 +01:00
Stephen Finucane
a3410cd4f7 volume: Add alias for volume type AZs
Another quality of life improvements. The key for this one is weird and
the whole thing is a little more involved, hence why it's kept separate.

Change-Id: I75aa85f27905104dc84fffe823c01b4c90a6a822
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-10-27 17:58:13 +01:00
Stephen Finucane
e0c7cef434 volume: Add aliases for common volume type props
Add aliases for the enabling multiattach, caching and replication via
extra spec properties. These are useful since the syntax for setting
each of them is a bit weird and frankly not very discoverable.

Change-Id: I08b51224c66a34a9dcfcffc95847e61d9aac0e7e
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-10-27 17:57:39 +01:00
Stephen Finucane
67bec7785c volume: Allow filtering volume types by properties
Starting in volume API microversion 3.52, it is possible to filter
volume types by extra specs (a.k.a. properties). Even non-admins can do
this for so-called "user visible" extra specs. Make it possible to do
this.

While we're here, the test file is renamed to match the name of the
module under test.

Change-Id: Ia9acc06c0c615bf24e12b63146ea97ac2505f596
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-10-27 16:37:15 +01:00
Rajat Dhasmana
39a084f91c Migrate volume backend commands to SDK
This patch migrates following volume backend commands to SDK:

volume backend capability show
volume backend pool list

Change-Id: Idded38a5f87d51574426c4ac10c806af52984b7c
2023-10-12 01:14:35 +05:30
Christian Rohmann
98b949646c Add is_incremental to ListVolumeBackup
It's of interest which backups are incremental or full. Returning this
information as a column to the list of backups.

Change-Id: I766330228634d5db678df11c23877077a3635372
2023-09-19 22:10:04 +02:00
Stephen Finucane
8735b862c5 volume: Deprecate '--detailed' options
We use flags, not options with boolean-like values, for boolean
parameters. The affected commands were only introduced recently so this
should have minimal fallout.

Change-Id: I700733e750bff539806af167c9d47cec769c3343
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-09-11 11:02:55 +01:00
Zuul
6ae38b2888 Merge "tests: Use consistent shortcut to fake image client" 2023-09-06 12:26:00 +00:00
Zuul
94caaa487d Merge "Migrate backup commands to SDK" 2023-09-01 02:45:27 +00:00
Stephen Finucane
28b1267921 tests: Use consistent shortcut to fake image client
This removes the need for a number of base test case subclasses. We use
'image_client' rather than 'client' to avoid conflicts with clients for
other services.

Note that this highlights a minor bug with the 'volume create' command
when using the v1 block storage API and creating a volume from an image.
This is corrected, though it can be assumed that no one is actually
using this code path to say it hasn't been reported in the few years
since the bug was introduced in Ussuri.

Change-Id: I571be27f68bb7669dcb883f3b4799731b4a35479
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-08-28 13:52:23 +01:00
Stephen Finucane
564e4f76fb volume: Migrate 'volume group snapshot' commands to SDK
Change-Id: Ie49e1f4b63de8b3bc699f7a9ef6eaa72801b9d05
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/892974
2023-08-25 15:09:00 +01:00
Zuul
d10185380b Merge "volume: Make better use of argparse" 2023-08-25 12:08:16 +00:00
Zuul
356bc2566e Merge "volume: Add 'volume type set --private/--public'" 2023-08-25 12:08:10 +00:00
whoami-rajat
bfd6170b03 Migrate backup commands to SDK
This patch migrates the following backup commands to SDK:

* Create Backup
* Show Backup
* List Backup
* Restore Backup
* Delete Backup

Change-Id: Icfadd65b92f4cd343bc327d33e29767bc9b969f9
2023-08-17 11:04:46 +05:30
whoami-rajat
4dfbc5011e Migrate 'volume summary' command to SDK
This patch modifies the existing volume summary call from
cinderclient to SDK.

Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/884397
Change-Id: I364211a597b6ec155b154fa9d3c67239e750b5ad
2023-07-05 10:04:01 +00:00
Zuul
4a62c73992 Merge "volume: Add 'volume qos set --no-property' option" 2023-05-17 23:20:28 +00:00
Stephen Finucane
629eb33c4d volume: Add 'volume qos set --no-property' option
Supporting "--no-property" option will apply user a convenient way to
clean all properties of volume qos in a short command. The patch adds
"--no-property" option in "volume qos set" command and update related
test cases and docs.

Change-Id: I1fb5b4f0a923bbf557a3af3f63809bde9e84ffd4
2023-05-17 16:50:16 +01:00
Stephen Finucane
6dcef7c3ec volume: Make better use of argparse
Change-Id: Ifeab60aaf18a9163465d4968c53e3ed66dad769b
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
2023-05-17 16:38:56 +01:00
Takashi Kajinami
83f5c8033f volume: Add 'volume type set --private/--public'
We also rename the test file and fixup some of the tests.

Change-Id: I3731255648dc91c023a1390c3b37e68b6608f850
Co-authored-by: Stephen Finucane <stephenfin@redhat.com>
Story: 2008478
Task: 41518
2023-05-17 16:38:38 +01:00
whoami-rajat
aaeda25e28 Migrate 'volume revert' command to SDK
This patch modifies the existing revert volume to snapshot call
from cinderclient to SDK.

Change-Id: Iaa9708ebae5d6ab3dfc73e4e2376af32ed098688
2023-05-16 17:38:10 +05:30
Stephen Finucane
35ba1d8f13 Blacken openstackclient.volume
Black used with the '-l 79 -S' flags.

A future change will ignore this commit in git-blame history by adding a
'git-blame-ignore-revs' file.

Change-Id: Ic318617c67ab7ce6527f9016b759a1d4b0b80802
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-05-10 10:51:30 +01:00
Zuul
cfd728108c Merge "Wait for volume being available to set bootable or readonly" 2023-02-22 12:32:20 +00:00
Zuul
14dff075ff Merge "Fix really long help strings" 2023-02-22 12:32:16 +00:00
Zuul
3478873cff Merge "volume: Remove duplication from 'consistency group create' opts" 2023-02-22 12:32:11 +00:00
matbu
5c9c1c77a0 Wait for volume being available to set bootable or readonly
This patch add a check to be sure that the volume created is in a
available state before trying to set bootable or readonly flag.

Story: 2002158
Change-Id: I8db71fd8cf5bd14eb67880f76d2e9135edeb3ed2
2023-02-22 09:52:43 +00:00
Stephen Finucane
0d57f3f367 Deprecate positional args for 'volume group create'
There are now many ways to create a new volume group, thus the
positional arguments don't make sense. Deprecate them.

Change-Id: Id0b212426861719db1812b7d07b82613cf591de4
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
2023-02-17 13:50:50 +00:00
whoami-rajat
ec01268ea9 Add options to create volume group from source
This patch adds ``--source-group`` and ``--group-snapshot`` options
to the ``volume group create`` command to allow creating group from
a source group or a group snapshot.

Change-Id: I87482a5dd43c519dfdcf981635aa879914a70a5c
2023-02-17 12:17:22 +00:00