Merge "CLI for backup snapshots"

This commit is contained in:
Jenkins 2016-02-03 16:12:01 +00:00 committed by Gerrit Code Review
commit bdeab3af0e
4 changed files with 20 additions and 3 deletions

View File

@ -403,6 +403,10 @@ class ShellTest(utils.TestCase):
self.run_command('backup-create 1234 --force')
self.assert_called('POST', '/backups')
def test_backup_snapshot(self):
self.run_command('backup-create 1234 --snapshot-id 4321')
self.assert_called('POST', '/backups')
def test_restore(self):
self.run_command('backup-restore 1234')
self.assert_called('POST', '/backups/1234/restore')

View File

@ -42,6 +42,12 @@ class VolumeBackupsTest(utils.TestCase):
None, None, False, True)
cs.assert_called('POST', '/backups')
def test_create_snapshot(self):
cs.backups.create('2b695faf-b963-40c8-8464-274008fbcef4',
None, None, False, False,
'3c706gbg-c074-51d9-9575-385119gcdfg5')
cs.assert_called('POST', '/backups')
def test_get(self):
backup_id = '76a17945-3c6f-435c-975b-b5685db10b62'
cs.backups.get(backup_id)

View File

@ -1358,6 +1358,10 @@ def do_retype(cs, args):
'of an "in-use" volume means your data is crash '
'consistent. Default=False.',
default=False)
@utils.arg('--snapshot-id',
metavar='<snapshot-id>',
default=None,
help='ID of snapshot to backup. Default=None.')
@utils.service_type('volumev2')
def do_backup_create(cs, args):
"""Creates a volume backup."""
@ -1373,7 +1377,8 @@ def do_backup_create(cs, args):
args.name,
args.description,
args.incremental,
args.force)
args.force,
args.snapshot_id)
info = {"volume_id": volume.id}
info.update(backup._info)

View File

@ -39,7 +39,8 @@ class VolumeBackupManager(base.ManagerWithFind):
def create(self, volume_id, container=None,
name=None, description=None,
incremental=False, force=False):
incremental=False, force=False,
snapshot_id=None):
"""Creates a volume backup.
:param volume_id: The ID of the volume to backup.
@ -55,7 +56,8 @@ class VolumeBackupManager(base.ManagerWithFind):
'name': name,
'description': description,
'incremental': incremental,
'force': force, }}
'force': force,
'snapshot_id': snapshot_id, }}
return self._create('/backups', body, 'backup')
def get(self, backup_id):