diff --git a/cinderclient/tests/unit/v2/test_shell.py b/cinderclient/tests/unit/v2/test_shell.py index fa36f10..1cfc005 100644 --- a/cinderclient/tests/unit/v2/test_shell.py +++ b/cinderclient/tests/unit/v2/test_shell.py @@ -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') diff --git a/cinderclient/tests/unit/v2/test_volume_backups.py b/cinderclient/tests/unit/v2/test_volume_backups.py index 296305f..7f72c63 100644 --- a/cinderclient/tests/unit/v2/test_volume_backups.py +++ b/cinderclient/tests/unit/v2/test_volume_backups.py @@ -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) diff --git a/cinderclient/v2/shell.py b/cinderclient/v2/shell.py index 6b3a4f2..ea2abd8 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -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='', + 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) diff --git a/cinderclient/v2/volume_backups.py b/cinderclient/v2/volume_backups.py index d97d846..fc653c8 100644 --- a/cinderclient/v2/volume_backups.py +++ b/cinderclient/v2/volume_backups.py @@ -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):