summaryrefslogtreecommitdiff
path: root/cinderclient
diff options
context:
space:
mode:
authorEllen Leahy <ellen.mar.leahy@hpe.com>2016-08-09 09:32:36 +0100
committerEllen Leahy <ellen.mar.leahy@hpe.com>2016-08-25 15:48:43 +0100
commit4f833eeaff3a5a1bf43e8cb4ebf40d5115bd8b4f (patch)
tree252fcc471d737ee9840d5c48a050857d575eb512 /cinderclient
parentcb24088fea21049d9b0b039d5a6d695db310bcdb (diff)
downloadpython-cinderclient-4f833eeaff3a5a1bf43e8cb4ebf40d5115bd8b4f.tar.gz
Changed backup-restore to accept backup name
Beckup-restore does not currently accept the name of the backup, however other backup actions do and according to its description backup-restore should as well. Change-Id: I26d8d2f1fe6cf7362d23d9b9668936dbb0509251 Closes-Bug: #1604892
Diffstat (limited to 'cinderclient')
-rw-r--r--cinderclient/tests/unit/v2/test_shell.py10
-rw-r--r--cinderclient/v3/shell.py2
2 files changed, 8 insertions, 4 deletions
diff --git a/cinderclient/tests/unit/v2/test_shell.py b/cinderclient/tests/unit/v2/test_shell.py
index e1257e2..bc33a2b 100644
--- a/cinderclient/tests/unit/v2/test_shell.py
+++ b/cinderclient/tests/unit/v2/test_shell.py
@@ -15,6 +15,7 @@
import fixtures
import mock
+import ddt
from requests_mock.contrib import fixture as requests_mock_fixture
from six.moves.urllib import parse
@@ -29,6 +30,7 @@ from cinderclient.tests.unit.v2 import fakes
from cinderclient.tests.unit.fixture_data import keystone_client
+@ddt.ddt
@mock.patch.object(client, 'Client', fakes.FakeClient)
class ShellTest(utils.TestCase):
@@ -446,10 +448,12 @@ class ShellTest(utils.TestCase):
'backup-restore 1234 --volume fake_vol --name '
'restore_vol')
+ @ddt.data('backup_name', '1234')
@mock.patch('cinderclient.v3.shell._find_backup')
@mock.patch('cinderclient.utils.print_dict')
@mock.patch('cinderclient.utils.find_volume')
- def test_do_backup_restore(self,
+ def test_do_backup_restore_with_name(self,
+ value,
mock_find_volume,
mock_print_dict,
mock_find_backup):
@@ -457,7 +461,7 @@ class ShellTest(utils.TestCase):
volume_id = '5678'
name = None
input = {
- 'backup': backup_id,
+ 'backup': value,
'volume': volume_id,
'name': None
}
@@ -475,7 +479,7 @@ class ShellTest(utils.TestCase):
test_shell.do_backup_restore(self.cs, args)
mock_find_backup.assert_called_once_with(
self.cs,
- backup_id)
+ value)
mocked_restore.assert_called_once_with(
backup_id,
volume_id,
diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py
index 173d92e..4affed2 100644
--- a/cinderclient/v3/shell.py
+++ b/cinderclient/v3/shell.py
@@ -1541,7 +1541,7 @@ def do_backup_restore(cs, args):
volume_id = None
backup = _find_backup(cs, args.backup)
- restore = cs.restores.restore(args.backup, volume_id, args.name)
+ restore = cs.restores.restore(backup.id, volume_id, args.name)
info = {"backup_id": backup.id}
info.update(restore._info)