Adding support for incremental backups

* Adds a parent argument to backup-create.
* Adds parent_id to the backup create body if present.

Implements: blueprint incremental-backups

Change-Id: I76f720ae4eadf2a1977c4c2cbf286db4db079b63
This commit is contained in:
Robert Myers 2013-12-19 11:26:46 -06:00
parent 11c45de9e0
commit b23b9fbd87
3 changed files with 19 additions and 4 deletions

@ -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

@ -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):

@ -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)