diff --git a/cinderclient/tests/unit/v2/test_shell.py b/cinderclient/tests/unit/v2/test_shell.py index f7dbab68f..2004ae5b1 100644 --- a/cinderclient/tests/unit/v2/test_shell.py +++ b/cinderclient/tests/unit/v2/test_shell.py @@ -347,6 +347,10 @@ class ShellTest(utils.TestCase): self.run_command('backup-create 1234') self.assert_called('POST', '/backups') + def test_backup_incremental(self): + self.run_command('backup-create 1234 --incremental') + 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 106b828ec..1b77b9ca8 100644 --- a/cinderclient/tests/unit/v2/test_volume_backups.py +++ b/cinderclient/tests/unit/v2/test_volume_backups.py @@ -26,6 +26,16 @@ class VolumeBackupsTest(utils.TestCase): cs.backups.create('2b695faf-b963-40c8-8464-274008fbcef4') cs.assert_called('POST', '/backups') + def test_create_full(self): + cs.backups.create('2b695faf-b963-40c8-8464-274008fbcef4', + None, None, False) + cs.assert_called('POST', '/backups') + + def test_create_incremental(self): + cs.backups.create('2b695faf-b963-40c8-8464-274008fbcef4', + None, None, True) + 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 c7ace8009..f9efb7fc0 100644 --- a/cinderclient/v2/shell.py +++ b/cinderclient/v2/shell.py @@ -1150,6 +1150,10 @@ def do_retype(cs, args): metavar='', default=None, help='Backup description. Default=None.') +@utils.arg('--incremental', + action='store_true', + help='Incremental backup. Default=False.', + default=False) @utils.service_type('volumev2') def do_backup_create(cs, args): """Creates a volume backup.""" @@ -1163,7 +1167,8 @@ def do_backup_create(cs, args): backup = cs.backups.create(volume.id, args.container, args.name, - args.description) + args.description, + args.incremental) info = {"volume_id": volume.id} info.update(backup._info) diff --git a/cinderclient/v2/volume_backups.py b/cinderclient/v2/volume_backups.py index a948b5ee0..faee6b177 100644 --- a/cinderclient/v2/volume_backups.py +++ b/cinderclient/v2/volume_backups.py @@ -35,19 +35,22 @@ class VolumeBackupManager(base.ManagerWithFind): resource_class = VolumeBackup def create(self, volume_id, container=None, - name=None, description=None): + name=None, description=None, + incremental=False): """Creates a volume backup. :param volume_id: The ID of the volume to backup. :param container: The name of the backup service container. :param name: The name of the backup. :param description: The description of the backup. + :param incremental: Incremental backup. :rtype: :class:`VolumeBackup` """ body = {'backup': {'volume_id': volume_id, 'container': container, 'name': name, - 'description': description}} + 'description': description, + 'incremental': incremental}} return self._create('/backups', body, 'backup') def get(self, backup_id):