summaryrefslogtreecommitdiff
path: root/cinderclient/v3
diff options
context:
space:
mode:
authorTommyLike <tommylikehu@gmail.com>2017-10-30 10:42:16 +0800
committerTommyLike <tommylikehu@gmail.com>2017-12-07 11:31:39 +0800
commit7aedf4c898dff8e69d73da45668ec3d909f63a44 (patch)
treeb3e403839d77e02fbe2627d0d96f52ea47653a2b /cinderclient/v3
parent91fb5b07d109c7d16dde64dffe99a63084b76dce (diff)
downloadpython-cinderclient-7aedf4c898dff8e69d73da45668ec3d909f63a44.tar.gz
Support create volume from backup in client
This patch adds create volume from backup support in cinderclient. Change-Id: I01dbcf6b113d88732c174b848be2127ee7242b3c Implements: blueprint support-create-volume-from-backup Depends-On: 58d0fb327f9fc980e0c8b84dcd9f64c093285d13
Diffstat (limited to 'cinderclient/v3')
-rw-r--r--cinderclient/v3/shell.py10
-rw-r--r--cinderclient/v3/volumes.py4
2 files changed, 12 insertions, 2 deletions
diff --git a/cinderclient/v3/shell.py b/cinderclient/v3/shell.py
index b5c0ed6..edead62 100644
--- a/cinderclient/v3/shell.py
+++ b/cinderclient/v3/shell.py
@@ -498,6 +498,11 @@ def do_reset_state(cs, args):
metavar='<image>',
default=None,
help='Creates a volume from image (ID or name). Default=None.')
+@utils.arg('--backup-id',
+ metavar='<backup-id>',
+ default=None,
+ start_version='3.47',
+ help='Creates a volume from backup ID. Default=None.')
@utils.arg('--image_ref',
help=argparse.SUPPRESS)
@utils.arg('--name',
@@ -585,6 +590,8 @@ def do_create(cs, args):
except AttributeError:
group_id = None
+ backup_id = args.backup_id if hasattr(args, 'backup_id') else None
+
volume = cs.volumes.create(args.size,
args.consisgroup_id,
group_id,
@@ -598,7 +605,8 @@ def do_create(cs, args):
metadata=volume_metadata,
scheduler_hints=hints,
source_replica=args.source_replica,
- multiattach=args.multiattach)
+ multiattach=args.multiattach,
+ backup_id=backup_id)
info = dict()
volume = cs.volumes.get(volume.id)
diff --git a/cinderclient/v3/volumes.py b/cinderclient/v3/volumes.py
index bba714b..99006b4 100644
--- a/cinderclient/v3/volumes.py
+++ b/cinderclient/v3/volumes.py
@@ -75,7 +75,7 @@ class VolumeManager(volumes.VolumeManager):
volume_type=None, user_id=None,
project_id=None, availability_zone=None,
metadata=None, imageRef=None, scheduler_hints=None,
- source_replica=None, multiattach=False):
+ source_replica=None, multiattach=False, backup_id=None):
"""Create a volume.
:param size: Size of volume in GB
@@ -96,6 +96,7 @@ class VolumeManager(volumes.VolumeManager):
specified by the client to help boot an instance
:param multiattach: Allow the volume to be attached to more than
one instance
+ :param backup_id: ID of the backup
:rtype: :class:`Volume`
"""
if metadata is None:
@@ -119,6 +120,7 @@ class VolumeManager(volumes.VolumeManager):
'source_volid': source_volid,
'source_replica': source_replica,
'multiattach': multiattach,
+ 'backup_id': backup_id
}}
if group_id: