From b6b18489b0b1b200c40e060f6c830103070d90f5 Mon Sep 17 00:00:00 2001 From: Rajat Dhasmana Date: Mon, 7 Oct 2024 13:21:22 +0000 Subject: [PATCH] Fix volume backup show by name When we show a volume backup by name, it calls the get_backup method in SDK which is only used for getting a backup by ID. This patch modifies the approach to call find_backup method which first tries the find by ID and then find by name logic eventually returning the backup details. Story: 2011234 Task: 51127 Change-Id: I926d8de9810fcf2e5335bbe35aaab15e1e36a5cb --- openstackclient/tests/unit/volume/v2/test_volume_backup.py | 4 ++-- openstackclient/tests/unit/volume/v3/test_volume_backup.py | 4 ++-- openstackclient/volume/v2/volume_backup.py | 2 +- openstackclient/volume/v3/volume_backup.py | 2 +- .../notes/fix-show-backup-by-name-0759c55396be77a3.yaml | 5 +++++ 5 files changed, 11 insertions(+), 6 deletions(-) create mode 100644 releasenotes/notes/fix-show-backup-by-name-0759c55396be77a3.yaml diff --git a/openstackclient/tests/unit/volume/v2/test_volume_backup.py b/openstackclient/tests/unit/volume/v2/test_volume_backup.py index 483ca24de7..b63aa03415 100644 --- a/openstackclient/tests/unit/volume/v2/test_volume_backup.py +++ b/openstackclient/tests/unit/volume/v2/test_volume_backup.py @@ -544,7 +544,7 @@ class TestBackupShow(volume_fakes.TestVolume): def setUp(self): super().setUp() - self.volume_sdk_client.get_backup.return_value = self.backup + self.volume_sdk_client.find_backup.return_value = self.backup # Get the command object to test self.cmd = volume_backup.ShowVolumeBackup(self.app, None) @@ -554,7 +554,7 @@ class TestBackupShow(volume_fakes.TestVolume): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) - self.volume_sdk_client.get_backup.assert_called_with(self.backup.id) + self.volume_sdk_client.find_backup.assert_called_with(self.backup.id) self.assertEqual(self.columns, columns) self.assertEqual(self.data, data) diff --git a/openstackclient/tests/unit/volume/v3/test_volume_backup.py b/openstackclient/tests/unit/volume/v3/test_volume_backup.py index d4e7e79248..2a6ae17b86 100644 --- a/openstackclient/tests/unit/volume/v3/test_volume_backup.py +++ b/openstackclient/tests/unit/volume/v3/test_volume_backup.py @@ -876,7 +876,7 @@ class TestBackupShow(volume_fakes.TestVolume): def setUp(self): super().setUp() - self.volume_sdk_client.get_backup.return_value = self.backup + self.volume_sdk_client.find_backup.return_value = self.backup # Get the command object to test self.cmd = volume_backup.ShowVolumeBackup(self.app, None) @@ -886,7 +886,7 @@ class TestBackupShow(volume_fakes.TestVolume): parsed_args = self.check_parser(self.cmd, arglist, verifylist) columns, data = self.cmd.take_action(parsed_args) - self.volume_sdk_client.get_backup.assert_called_with(self.backup.id) + self.volume_sdk_client.find_backup.assert_called_with(self.backup.id) self.assertEqual(self.columns, columns) self.assertEqual(self.data, data) diff --git a/openstackclient/volume/v2/volume_backup.py b/openstackclient/volume/v2/volume_backup.py index fd59c0cefd..5295733ae2 100644 --- a/openstackclient/volume/v2/volume_backup.py +++ b/openstackclient/volume/v2/volume_backup.py @@ -439,7 +439,7 @@ class ShowVolumeBackup(command.ShowOne): def take_action(self, parsed_args): volume_client = self.app.client_manager.sdk_connection.volume - backup = volume_client.get_backup(parsed_args.backup) + backup = volume_client.find_backup(parsed_args.backup) columns = ( "availability_zone", "container", diff --git a/openstackclient/volume/v3/volume_backup.py b/openstackclient/volume/v3/volume_backup.py index 471b4cee14..3d2e743ecb 100644 --- a/openstackclient/volume/v3/volume_backup.py +++ b/openstackclient/volume/v3/volume_backup.py @@ -643,7 +643,7 @@ class ShowVolumeBackup(command.ShowOne): def take_action(self, parsed_args): volume_client = self.app.client_manager.sdk_connection.volume - backup = volume_client.get_backup(parsed_args.backup) + backup = volume_client.find_backup(parsed_args.backup) columns = ( "availability_zone", "container", diff --git a/releasenotes/notes/fix-show-backup-by-name-0759c55396be77a3.yaml b/releasenotes/notes/fix-show-backup-by-name-0759c55396be77a3.yaml new file mode 100644 index 0000000000..7ed9d72cc8 --- /dev/null +++ b/releasenotes/notes/fix-show-backup-by-name-0759c55396be77a3.yaml @@ -0,0 +1,5 @@ +--- +fixes: + - | + Fixed the ``openstack volume backup show`` command + to show a backup by name.