Merge "Backup create is not available from 3.0 to 3.42"
This commit is contained in:
@@ -1035,13 +1035,31 @@ class ShellTest(utils.TestCase):
|
|||||||
mock_time.sleep.call_args_list)
|
mock_time.sleep.call_args_list)
|
||||||
self.assertEqual([mock.call(some_id)] * 2, poll_fn.call_args_list)
|
self.assertEqual([mock.call(some_id)] * 2, poll_fn.call_args_list)
|
||||||
|
|
||||||
|
def test_backup(self):
|
||||||
|
self.run_command('--os-volume-api-version 3.42 backup-create '
|
||||||
|
'--name 1234 1234')
|
||||||
|
expected = {'backup': {'volume_id': 1234,
|
||||||
|
'container': None,
|
||||||
|
'name': '1234',
|
||||||
|
'description': None,
|
||||||
|
'incremental': False,
|
||||||
|
'force': False,
|
||||||
|
'snapshot_id': None,
|
||||||
|
}}
|
||||||
|
self.assert_called('POST', '/backups', body=expected)
|
||||||
|
|
||||||
def test_backup_with_metadata(self):
|
def test_backup_with_metadata(self):
|
||||||
cmd = '--os-volume-api-version 3.43 '
|
self.run_command('--os-volume-api-version 3.43 backup-create '
|
||||||
cmd += 'backup-create '
|
'--metadata foo=bar --name 1234 1234')
|
||||||
cmd += '--metadata foo=bar '
|
expected = {'backup': {'volume_id': 1234,
|
||||||
cmd += '1234'
|
'container': None,
|
||||||
self.run_command(cmd)
|
'name': '1234',
|
||||||
self.assert_called('POST', '/backups')
|
'description': None,
|
||||||
|
'incremental': False,
|
||||||
|
'force': False,
|
||||||
|
'snapshot_id': None,
|
||||||
|
'metadata': {'foo': 'bar'}, }}
|
||||||
|
self.assert_called('POST', '/backups', body=expected)
|
||||||
|
|
||||||
@mock.patch("cinderclient.utils.print_list")
|
@mock.patch("cinderclient.utils.print_list")
|
||||||
def test_snapshot_list_with_userid(self, mock_print_list):
|
def test_snapshot_list_with_userid(self, mock_print_list):
|
||||||
|
@@ -2220,7 +2220,7 @@ def do_service_get_log(cs, args):
|
|||||||
columns = ('Binary', 'Host', 'Prefix', 'Level')
|
columns = ('Binary', 'Host', 'Prefix', 'Level')
|
||||||
utils.print_list(log_levels, columns)
|
utils.print_list(log_levels, columns)
|
||||||
|
|
||||||
@api_versions.wraps('3.43')
|
|
||||||
@utils.arg('volume', metavar='<volume>',
|
@utils.arg('volume', metavar='<volume>',
|
||||||
help='Name or ID of volume to backup.')
|
help='Name or ID of volume to backup.')
|
||||||
@utils.arg('--container', metavar='<container>',
|
@utils.arg('--container', metavar='<container>',
|
||||||
@@ -2258,6 +2258,7 @@ def do_service_get_log(cs, args):
|
|||||||
nargs='*',
|
nargs='*',
|
||||||
metavar='<key=value>',
|
metavar='<key=value>',
|
||||||
default=None,
|
default=None,
|
||||||
|
start_version='3.43',
|
||||||
help='Metadata key and value pairs. Default=None.')
|
help='Metadata key and value pairs. Default=None.')
|
||||||
def do_backup_create(cs, args):
|
def do_backup_create(cs, args):
|
||||||
"""Creates a volume backup."""
|
"""Creates a volume backup."""
|
||||||
@@ -2268,6 +2269,7 @@ def do_backup_create(cs, args):
|
|||||||
args.description = args.display_description
|
args.description = args.display_description
|
||||||
|
|
||||||
volume = utils.find_volume(cs, args.volume)
|
volume = utils.find_volume(cs, args.volume)
|
||||||
|
if hasattr(args, 'metadata') and args.metadata:
|
||||||
backup = cs.backups.create(volume.id,
|
backup = cs.backups.create(volume.id,
|
||||||
args.container,
|
args.container,
|
||||||
args.name,
|
args.name,
|
||||||
@@ -2275,7 +2277,15 @@ def do_backup_create(cs, args):
|
|||||||
args.incremental,
|
args.incremental,
|
||||||
args.force,
|
args.force,
|
||||||
args.snapshot_id,
|
args.snapshot_id,
|
||||||
args.metadata)
|
shell_utils.extract_metadata(args))
|
||||||
|
else:
|
||||||
|
backup = cs.backups.create(volume.id,
|
||||||
|
args.container,
|
||||||
|
args.name,
|
||||||
|
args.description,
|
||||||
|
args.incremental,
|
||||||
|
args.force,
|
||||||
|
args.snapshot_id)
|
||||||
|
|
||||||
info = {"volume_id": volume.id}
|
info = {"volume_id": volume.id}
|
||||||
info.update(backup._info)
|
info.update(backup._info)
|
||||||
|
@@ -39,7 +39,31 @@ class VolumeBackupManager(volume_backups.VolumeBackupManager):
|
|||||||
|
|
||||||
return self._update("/backups/%s" % base.getid(backup), body)
|
return self._update("/backups/%s" % base.getid(backup), body)
|
||||||
|
|
||||||
@api_versions.wraps("3.43")
|
@api_versions.wraps("3.0")
|
||||||
|
def create(self, volume_id, container=None,
|
||||||
|
name=None, description=None,
|
||||||
|
incremental=False, force=False,
|
||||||
|
snapshot_id=None):
|
||||||
|
"""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.
|
||||||
|
:param force: If True, allows an in-use volume to be backed up.
|
||||||
|
:rtype: :class:`VolumeBackup`
|
||||||
|
"""
|
||||||
|
body = {'backup': {'volume_id': volume_id,
|
||||||
|
'container': container,
|
||||||
|
'name': name,
|
||||||
|
'description': description,
|
||||||
|
'incremental': incremental,
|
||||||
|
'force': force,
|
||||||
|
'snapshot_id': snapshot_id, }}
|
||||||
|
return self._create('/backups', body, 'backup')
|
||||||
|
|
||||||
|
@api_versions.wraps("3.43") # noqa: F811
|
||||||
def create(self, volume_id, container=None,
|
def create(self, volume_id, container=None,
|
||||||
name=None, description=None,
|
name=None, description=None,
|
||||||
incremental=False, force=False,
|
incremental=False, force=False,
|
||||||
@@ -56,6 +80,7 @@ class VolumeBackupManager(volume_backups.VolumeBackupManager):
|
|||||||
:param metadata: Key Value pairs
|
:param metadata: Key Value pairs
|
||||||
:rtype: :class:`VolumeBackup`
|
:rtype: :class:`VolumeBackup`
|
||||||
"""
|
"""
|
||||||
|
# pylint: disable=function-redefined
|
||||||
body = {'backup': {'volume_id': volume_id,
|
body = {'backup': {'volume_id': volume_id,
|
||||||
'container': container,
|
'container': container,
|
||||||
'name': name,
|
'name': name,
|
||||||
|
Reference in New Issue
Block a user