Support create backup with storage drivers
Story: 2010956 Task: 49198 Change-Id: I3083783df1a9a6682f076ecac9530b0ee2e6f576
This commit is contained in:
@@ -287,6 +287,13 @@ class CreateDatabaseBackup(command.ShowOne):
|
|||||||
'--restore-size', type=float,
|
'--restore-size', type=float,
|
||||||
help=_('The original backup size.')
|
help=_('The original backup size.')
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--storage-driver',
|
||||||
|
help=_('The storage driver used to save backup data. '
|
||||||
|
'Current valid values are: swift, cinder. '
|
||||||
|
'It depends on Trove support. '
|
||||||
|
'May conflict with other options.')
|
||||||
|
)
|
||||||
return parser
|
return parser
|
||||||
|
|
||||||
def take_action(self, parsed_args):
|
def take_action(self, parsed_args):
|
||||||
@@ -310,8 +317,9 @@ class CreateDatabaseBackup(command.ShowOne):
|
|||||||
parsed_args.instance)
|
parsed_args.instance)
|
||||||
params.update({
|
params.update({
|
||||||
'description': parsed_args.description,
|
'description': parsed_args.description,
|
||||||
'parent_id': parsed_args.parent,
|
|
||||||
'incremental': parsed_args.incremental,
|
'incremental': parsed_args.incremental,
|
||||||
|
'parent_id': parsed_args.parent,
|
||||||
|
'storage_driver': parsed_args.storage_driver,
|
||||||
'swift_container': parsed_args.swift_container
|
'swift_container': parsed_args.swift_container
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@@ -288,6 +288,7 @@ class TestBackupCreate(TestBackups):
|
|||||||
description=None,
|
description=None,
|
||||||
parent_id=None,
|
parent_id=None,
|
||||||
incremental=False,
|
incremental=False,
|
||||||
|
storage_driver=None,
|
||||||
swift_container=None)
|
swift_container=None)
|
||||||
|
|
||||||
@mock.patch('troveclient.utils.get_resource_id_by_name')
|
@mock.patch('troveclient.utils.get_resource_id_by_name')
|
||||||
@@ -304,6 +305,7 @@ class TestBackupCreate(TestBackups):
|
|||||||
description='backup 1234',
|
description='backup 1234',
|
||||||
parent_id='1234-1',
|
parent_id='1234-1',
|
||||||
incremental=True,
|
incremental=True,
|
||||||
|
storage_driver=None,
|
||||||
swift_container=None)
|
swift_container=None)
|
||||||
|
|
||||||
def test_create_from_data_location(self):
|
def test_create_from_data_location(self):
|
||||||
|
@@ -26,6 +26,7 @@ from troveclient import common
|
|||||||
|
|
||||||
class Backup(base.Resource):
|
class Backup(base.Resource):
|
||||||
"""Backup is a resource used to hold backup information."""
|
"""Backup is a resource used to hold backup information."""
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Backup: %s>" % self.name
|
return "<Backup: %s>" % self.name
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ class Backup(base.Resource):
|
|||||||
class Schedule(base.Resource):
|
class Schedule(base.Resource):
|
||||||
"""Schedule is a resource used to hold information about scheduled backups.
|
"""Schedule is a resource used to hold information about scheduled backups.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Schedule: %s>" % self.name
|
return "<Schedule: %s>" % self.name
|
||||||
|
|
||||||
@@ -41,6 +43,7 @@ class ScheduleExecution(base.Resource):
|
|||||||
"""ScheduleExecution is a resource used to hold information about
|
"""ScheduleExecution is a resource used to hold information about
|
||||||
the execution of a scheduled backup.
|
the execution of a scheduled backup.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return "<Execution: %s>" % self.name
|
return "<Execution: %s>" % self.name
|
||||||
|
|
||||||
@@ -75,8 +78,9 @@ class Backups(base.ManagerWithFind):
|
|||||||
query_strings)
|
query_strings)
|
||||||
|
|
||||||
def create(self, name, instance, description=None,
|
def create(self, name, instance, description=None,
|
||||||
parent_id=None, incremental=False, swift_container=None,
|
parent_id=None, incremental=False, storage_driver=None,
|
||||||
restore_from=None, restore_ds_version=None, restore_size=None):
|
swift_container=None, restore_from=None,
|
||||||
|
restore_ds_version=None, restore_size=None):
|
||||||
"""Create or restore a new backup.
|
"""Create or restore a new backup.
|
||||||
|
|
||||||
:param name: name for backup.
|
:param name: name for backup.
|
||||||
@@ -85,6 +89,7 @@ class Backups(base.ManagerWithFind):
|
|||||||
:param parent_id: base for incremental backup (optional).
|
:param parent_id: base for incremental backup (optional).
|
||||||
:param incremental: flag to indicate incremental backup based on
|
:param incremental: flag to indicate incremental backup based on
|
||||||
last backup
|
last backup
|
||||||
|
:param storage_driver: The storage driver used to create the backup.
|
||||||
:param swift_container: Swift container name.
|
:param swift_container: Swift container name.
|
||||||
:param restore_from: The original backup data location, typically this
|
:param restore_from: The original backup data location, typically this
|
||||||
is a Swift object URL.
|
is a Swift object URL.
|
||||||
@@ -115,6 +120,8 @@ class Backups(base.ManagerWithFind):
|
|||||||
body['backup']['description'] = description
|
body['backup']['description'] = description
|
||||||
if parent_id:
|
if parent_id:
|
||||||
body['backup']['parent_id'] = parent_id
|
body['backup']['parent_id'] = parent_id
|
||||||
|
if storage_driver:
|
||||||
|
body['backup']['storage_driver'] = storage_driver
|
||||||
if swift_container:
|
if swift_container:
|
||||||
body['backup']['swift_container'] = swift_container
|
body['backup']['swift_container'] = swift_container
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user