diff --git a/troveclient/tests/test_backups.py b/troveclient/tests/test_backups.py index d72ba894..912400a1 100644 --- a/troveclient/tests/test_backups.py +++ b/troveclient/tests/test_backups.py @@ -66,6 +66,14 @@ class BackupManagerTest(testtools.TestCase): self.backups.create(**args) create_mock.assert_called_with('/backups', body, 'backup') + def test_create_incremental(self): + create_mock = mock.Mock() + self.backups._create = create_mock + args = {'name': 'test_backup', 'instance': '1', 'parent_id': 'foo'} + body = {'backup': args} + self.backups.create(**args) + create_mock.assert_called_with('/backups', body, 'backup') + def test_list(self): page_mock = mock.Mock() self.backups._paginated = page_mock diff --git a/troveclient/v1/backups.py b/troveclient/v1/backups.py index 0b23e346..bf2c8ea1 100644 --- a/troveclient/v1/backups.py +++ b/troveclient/v1/backups.py @@ -53,7 +53,7 @@ class Backups(base.ManagerWithFind): """ return self._paginated("/backups", "backups", limit, marker) - def create(self, name, instance, description=None): + def create(self, name, instance, description=None, parent_id=None): """ Create a new backup from the given instance. """ @@ -65,6 +65,8 @@ class Backups(base.ManagerWithFind): } if description: body['backup']['description'] = description + if parent_id: + body['backup']['parent_id'] = parent_id return self._create("/backups", body, "backup") def delete(self, backup_id): diff --git a/troveclient/v1/shell.py b/troveclient/v1/shell.py index 21b82f29..028ce4bf 100644 --- a/troveclient/v1/shell.py +++ b/troveclient/v1/shell.py @@ -264,7 +264,8 @@ def do_backup_list_instance(cs, args): while wrapper.next and not args.limit: wrapper = cs.instances.backups(args.instance, marker=wrapper.next) backups += wrapper.items - utils.print_list(backups, ['id', 'name', 'status', 'updated'], + utils.print_list(backups, ['id', 'name', 'status', + 'parent_id', 'updated'], order_by='updated') @@ -280,7 +281,7 @@ def do_backup_list(cs, args): wrapper = cs.backups.list(marker=wrapper.next) backups += wrapper.items utils.print_list(backups, ['id', 'instance_id', 'name', - 'status', 'updated'], + 'status', 'parent_id', 'updated'], order_by='updated') @@ -296,11 +297,15 @@ def do_backup_delete(cs, args): @utils.arg('--description', metavar='<description>', default=None, help='An optional description for the backup.') +@utils.arg('--parent', metavar='<parent>', default=None, + help='Optional UUID of the parent backup to preform an' + ' incremental backup from.') @utils.service_type('database') def do_backup_create(cs, args): """Creates a backup.""" backup = cs.backups.create(args.name, args.instance, - description=args.description) + description=args.description, + parent_id=args.parent) _print_instance(backup)