Fixes broken v1 and v2 api backup-restore

Also adds unit tests.

Change-Id: I741889d49cffe46bf9165b266a62f2b328354e01
Fixes: bug 1240151
This commit is contained in:
Edward Hope-Morley 2013-10-15 18:09:42 +01:00
parent 873bed99a8
commit c4ae3dd7a5
6 changed files with 28 additions and 4 deletions

@ -533,6 +533,10 @@ class FakeHTTPClient(base_client.HTTPClient):
return (200, {},
{'restore': _stub_restore()})
def post_backups_1234_restore(self, **kw):
return (200, {},
{'restore': _stub_restore()})
#
# QoSSpecs
#

@ -117,6 +117,14 @@ class ShellTest(utils.TestCase):
self.run_command('delete 1234')
self.assert_called('DELETE', '/volumes/1234')
def test_backup(self):
self.run_command('backup-create 1234')
self.assert_called('POST', '/backups')
def test_restore(self):
self.run_command('backup-restore 1234')
self.assert_called('POST', '/backups/1234/restore')
def test_snapshot_list_filter_volume_id(self):
self.run_command('snapshot-list --volume-id=1234')
self.assert_called('GET', '/snapshots/detail?volume_id=1234')

@ -540,6 +540,10 @@ class FakeHTTPClient(base_client.HTTPClient):
return (200, {},
{'restore': _stub_restore()})
def post_backups_1234_restore(self, **kw):
return (200, {},
{'restore': _stub_restore()})
#
# QoSSpecs
#

@ -95,6 +95,14 @@ class ShellTest(utils.TestCase):
self.run_command('delete 1234')
self.assert_called('DELETE', '/volumes/1234')
def test_backup(self):
self.run_command('backup-create 1234')
self.assert_called('POST', '/backups')
def test_restore(self):
self.run_command('backup-restore 1234')
self.assert_called('POST', '/backups/1234/restore')
def test_snapshot_list_filter_volume_id(self):
self.run_command('snapshot-list --volume-id=1234')
self.assert_called('GET', '/snapshots/detail?volume_id=1234')

@ -812,8 +812,8 @@ def do_backup_delete(cs, args):
@utils.service_type('volume')
def do_backup_restore(cs, args):
"""Restore a backup."""
if args.volume:
volume_id = utils.find_volume(cs, args.volume).id
if args.volume_id:
volume_id = utils.find_volume(cs, args.volume_id).id
else:
volume_id = None
cs.restores.restore(args.backup, volume_id)

@ -903,8 +903,8 @@ def do_backup_delete(cs, args):
@utils.service_type('volumev2')
def do_backup_restore(cs, args):
"""Restore a backup."""
if args.volume:
volume_id = utils.find_volume(cs, args.volume).id
if args.volume_id:
volume_id = utils.find_volume(cs, args.volume_id).id
else:
volume_id = None
cs.restores.restore(args.backup, volume_id)