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
This commit is contained in:
Rajat Dhasmana 2024-10-07 13:21:22 +00:00
parent 8979c00150
commit b6b18489b0
5 changed files with 11 additions and 6 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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",

View File

@ -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",

View File

@ -0,0 +1,5 @@
---
fixes:
- |
Fixed the ``openstack volume backup show`` command
to show a backup by name.