summaryrefslogtreecommitdiff
path: root/cinderclient/v3
diff options
context:
space:
mode:
authorZuul <zuul@review.openstack.org>2017-12-15 05:42:04 +0000
committerGerrit Code Review <review@openstack.org>2017-12-15 05:42:04 +0000
commit95e51505e1d2b1ae80d38afe21e9d1330cf0f3f7 (patch)
treee6a6ce6023f5bbda8b7beec743c0786058770239 /cinderclient/v3
parent2a478b3528e9acb59d65f4fda8ed647a749f6021 (diff)
parent9bfd6da08d615e56385df990b72cd0b891ed8868 (diff)
downloadpython-cinderclient-95e51505e1d2b1ae80d38afe21e9d1330cf0f3f7.tar.gz
Merge "Backup create is not available from 3.0 to 3.42"
Diffstat (limited to 'cinderclient/v3')
-rw-r--r--cinderclient/v3/shell.py28
-rw-r--r--cinderclient/v3/volume_backups.py27
2 files changed, 45 insertions, 10 deletions
diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py
index 922c3a1..3f94b9d 100644
--- a/cinderclient/v3/shell.py
+++ b/cinderclient/v3/shell.py
@@ -2220,7 +2220,7 @@ def do_service_get_log(cs, args):
columns = ('Binary', 'Host', 'Prefix', 'Level')
utils.print_list(log_levels, columns)
-@api_versions.wraps('3.43')
+
@utils.arg('volume', metavar='<volume>',
help='Name or ID of volume to backup.')
@utils.arg('--container', metavar='<container>',
@@ -2258,6 +2258,7 @@ def do_service_get_log(cs, args):
nargs='*',
metavar='<key=value>',
default=None,
+ start_version='3.43',
help='Metadata key and value pairs. Default=None.')
def do_backup_create(cs, args):
"""Creates a volume backup."""
@@ -2268,14 +2269,23 @@ def do_backup_create(cs, args):
args.description = args.display_description
volume = utils.find_volume(cs, args.volume)
- backup = cs.backups.create(volume.id,
- args.container,
- args.name,
- args.description,
- args.incremental,
- args.force,
- args.snapshot_id,
- args.metadata)
+ if hasattr(args, 'metadata') and args.metadata:
+ backup = cs.backups.create(volume.id,
+ args.container,
+ args.name,
+ args.description,
+ args.incremental,
+ args.force,
+ args.snapshot_id,
+ 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.update(backup._info)
diff --git a/cinderclient/v3/volume_backups.py b/cinderclient/v3/volume_backups.py
index 555ace8..323daff 100644
--- a/cinderclient/v3/volume_backups.py
+++ b/cinderclient/v3/volume_backups.py
@@ -39,7 +39,31 @@ class VolumeBackupManager(volume_backups.VolumeBackupManager):
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,
name=None, description=None,
incremental=False, force=False,
@@ -56,6 +80,7 @@ class VolumeBackupManager(volume_backups.VolumeBackupManager):
:param metadata: Key Value pairs
:rtype: :class:`VolumeBackup`
"""
+ # pylint: disable=function-redefined
body = {'backup': {'volume_id': volume_id,
'container': container,
'name': name,