Fix output for "openstack volume backup restore"

Previously, on Openstack Pike, an issue [1] was reported that the
`openstack volume backup restore` command was not able to parse the
output correctly, even though the restore operation succeeds. This was
fixed by [2], for the Stein release (and cherry-picked to both Rocky
and Queens). The issue was that cliff expects a list with two tuples to
display the results, whereas the restore function was returning a
VolumeBackupsRestore object. The solution was to use the `_info` field
from the VolumeBackupsRetore object, instead of the whole object.

This was done not only for the VolumeBackupsRetore object, but also for
the VolumeBackup one, as can be seen on [3] and [4]. However, the
commit [5] removed this essential parsing, and caused the previously
fixed issue to reappear.

[1] https://bugs.launchpad.net/python-openstackclient/+bug/1733315
[2] https://review.opendev.org/c/openstack/python-openstackclient/+/624860
[3] https://opendev.org/openstack/python-openstackclient/src/branch/stable/2023.1/openstackclient/volume/v2/volume_backup.py#L174
[4] https://opendev.org/openstack/python-openstackclient/src/branch/stable/2023.1/openstackclient/volume/v2/volume_backup.py#L619
[5] https://review.opendev.org/c/openstack/python-openstackclient/+/353931

Test Plan:
PASS: Build python-openstackclient package
PASS: Build wheels
PASS: Build stx-openstackclients image
PASS: Manually upload built image to the system's registry and perform
      helm-override to use it in the clients containers
PASS: Create a backup from a volume
PASS: Issue the `openstack volume backup restore` command and verify
      that the output is returned without any errors.

Closes-Bug: 2045183

Change-Id: I18752635d29e0b74b30b0d63b6194c28d947d5a0
Signed-off-by: Lucas de Ataides <lucas.deataidesbarreto@windriver.com>
This commit is contained in:
Lucas de Ataides 2023-11-29 18:41:28 -03:00 committed by Lucas de Ataides Barreto
parent a515f0dc54
commit a64cf9a045
2 changed files with 52 additions and 0 deletions

View File

@ -0,0 +1,51 @@
From a3591cdd38b46cc360bbd579c02a0a82224d91f1 Mon Sep 17 00:00:00 2001
From: Lucas de Ataides <lucas.deataidesbarreto@windriver.com>
Date: Wed, 29 Nov 2023 17:12:09 -0300
Subject: [PATCH] Fix output for "openstack volume backup restore"
Previously, on Openstack Pike, an issue [1] was reported that the
`openstack volume backup restore` command was not able to parse the
output correctly, even though the restore operation succeeds. This was
fixed by [2], for the Stein release (and cherry-picked to both Rocky and
Queens). The issue was that cliff expects a list with two tuples to
display the results, whereas the restore function was returning a
VolumeBackupsRestore object. The solution was to use the `_info` field
from the VolumeBackupsRetore object, instead of the whole object.
This was done not only for the VolumeBackupsRetore object, but also for
the VolumeBackup one, as can be seen on [3] and [4]. However, the commit
[5] removed this essential parsing, and caused the previously fixed
issue to reappear.
[1] https://bugs.launchpad.net/python-openstackclient/+bug/1733315
[2] https://review.opendev.org/c/openstack/python-openstackclient/+/624860
[3] https://opendev.org/openstack/python-openstackclient/src/branch/stable/2023.1/openstackclient/volume/v2/volume_backup.py#L174
[4] https://opendev.org/openstack/python-openstackclient/src/branch/stable/2023.1/openstackclient/volume/v2/volume_backup.py#L619
[5] https://review.opendev.org/c/openstack/python-openstackclient/+/353931
Signed-off-by: Lucas de Ataides <lucas.deataidesbarreto@windriver.com>
---
openstackclient/volume/v2/volume_backup.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/openstackclient/volume/v2/volume_backup.py b/openstackclient/volume/v2/volume_backup.py
index eac6167d..c1bb0b2c 100644
--- a/openstackclient/volume/v2/volume_backup.py
+++ b/openstackclient/volume/v2/volume_backup.py
@@ -410,9 +410,12 @@ class RestoreVolumeBackup(command.ShowOne):
) % parsed_args.volume
raise exceptions.CommandError(msg)
- return volume_client.restores.restore(
+ backup_restore = volume_client.restores.restore(
backup.id, volume_id, volume_name,
)
+ return zip(*sorted(backup_restore._info.items()))
+
+
class SetVolumeBackup(command.Command):
--
2.25.1

View File

@ -1,2 +1,3 @@
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