Support location metadata for volume backups

The python-openstackclient package was upversioned from v6.2.0 to v6.6.0
[1]. The newer version of python-openstackclient replaced the
python-cinderclient by the python-openstacksdk to handle volume
operations.

This change adds the backup location parameter to the metadata field
officially supported by both python-cinderclient, python-openstacksdk
and Cinder API since the microversion 3.43.

[1]https://review.opendev.org/c/starlingx/openstack-armada-app/+/941975

Test Plan:
PASS - build stx-o packages
PASS - build and upload stx-openstackclient image to a running system
PASS - create a volume using the openstack cli
PASS - create a volume backup using the openstack cli and passing the
       location parameter "--location ceph"

Story: 2011303
Task: 51788

Change-Id: Icd92de147426c94ea6627daf076dd479d9da5309
Signed-off-by: Alex Figueiredo <alex.fernandesfigueiredo@windriver.com>
Co-authored-by: jchialun <johnny.chialung@windriver.com>
This commit is contained in:
Alex Figueiredoandjchialun committed 2025-03-13 18:11:59 -03:00
1 parent 8a40e8dccd
commit 934d2b3c2e
2 files changed
+63

No files matched your search

@@ -0,0 +1,62 @@
From 1b6d47f6426d36675df1b47b03f1845a83811e3c Mon Sep 17 00:00:00 2001
From: Alex Figueiredo <alex.fernandesfigueiredo@windriver.com>
Date: Thu, 13 Mar 2025 15:12:44 -0300
Subject: [PATCH] Support location metadata for volume backups
The python-openstackclient package was upversioned from v6.2.0 to v6.6.0
[1]. The newer version of python-openstackclient replaced the
python-cinderclient by the python-openstacksdk to handle volume
operations.
This change adds the backup location parameter to the metadata field
officially supported by both python-cinderclient, python-openstacksdk
and Cinder API since the microversion 3.43.
[1]https://review.opendev.org/c/starlingx/openstack-armada-app/+/941975
Test Plan:
PASS - build stx-o packages
PASS - build and upload stx-openstackclient image to a running system
PASS - create a volume using the openstack cli
PASS - create a volume backup using the openstack cli and passing the
location parameter "--location ceph"
Story: 2011303
Task: 51788
Signed-off-by: Alex Figueiredo <alex.fernandesfigueiredo@windriver.com>
Co-authored-by: jchialun <johnny.chialung@windriver.com>
---
openstackclient/volume/v2/volume_backup.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/openstackclient/volume/v2/volume_backup.py b/openstackclient/volume/v2/volume_backup.py
index 57909e0d..c453c4c8 100644
--- a/openstackclient/volume/v2/volume_backup.py
+++ b/openstackclient/volume/v2/volume_backup.py
@@ -90,6 +90,7 @@ class CreateVolumeBackup(command.ShowOne):
parser.add_argument(
"--location",
metavar="<location>",
+ default=None,
help=_("Optional backup location")
)
parser.add_argument(
@@ -157,6 +158,14 @@ class CreateVolumeBackup(command.ShowOne):
kwargs['metadata'] = parsed_args.properties
+ if not parsed_args.location and parsed_args.properties:
+ parsed_args.location = parsed_args.properties.get("location", None)
+ elif sdk_utils.supports_microversion(volume_client, '3.43'):
+ if kwargs.get('metadata', None):
+ kwargs['metadata']['location'] = parsed_args.location
+ else:
+ kwargs['metadata'] = {'location': parsed_args.location}
+
if parsed_args.availability_zone:
if not sdk_utils.supports_microversion(volume_client, '3.51'):
msg = _(
--
2.34.1
@@ -1,3 +1,4 @@
0001-Add-plugin-entry-point-sorting-mechanism.patch
0002-Add-location-parameter-for-volume-backup-creation.patch
0003-Fix-output-for-openstack-volume-backup-restore.patch
0004-Support-location-metadata-for-volume-backups.patch