You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by to...@apache.org on 2015/03/04 23:37:05 UTC
[3/5] libcloud git commit: Implement creating volumes from EC2
snapshots
Implement creating volumes from EC2 snapshots
LIBCLOUD-672 #close
Signed-off-by: Tomaz Muraus <to...@apache.org>
Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/ceccf30a
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ceccf30a
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ceccf30a
Branch: refs/heads/trunk
Commit: ceccf30acea8b8fbbd9d5cc8ecaa16dcb4924304
Parents: ab6ad77
Author: Allard Hoeve <al...@byte.nl>
Authored: Tue Feb 24 13:47:00 2015 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Wed Mar 4 23:30:12 2015 +0100
----------------------------------------------------------------------
libcloud/compute/drivers/ec2.py | 23 +++++++++++++++++++++++
1 file changed, 23 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/libcloud/blob/ceccf30a/libcloud/compute/drivers/ec2.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/ec2.py b/libcloud/compute/drivers/ec2.py
index fd7c98c..b32fcc7 100644
--- a/libcloud/compute/drivers/ec2.py
+++ b/libcloud/compute/drivers/ec2.py
@@ -2314,6 +2314,23 @@ class BaseEC2NodeDriver(NodeDriver):
def create_volume(self, size, name, location=None, snapshot=None,
ex_volume_type='standard', ex_iops=None):
"""
+ Create a new volume.
+
+ :param size: Size of volume in gigabytes (required)
+ :type size: ``int``
+
+ :param name: Name of the volume to be created
+ :type name: ``str``
+
+ :param location: Which data center to create a volume in. If
+ empty, undefined behavior will be selected.
+ (optional)
+ :type location: :class:`.NodeLocation`
+
+ :param snapshot: Snapshot from which to create the new
+ volume. (optional)
+ :type snapshot: :class:`.VolumeSnapshot`
+
:param location: Datacenter in which to create a volume in.
:type location: :class:`.ExEC2AvailabilityZone`
@@ -2324,6 +2341,9 @@ class BaseEC2NodeDriver(NodeDriver):
that the volume supports. Only used if ex_volume_type
is io1.
:type iops: ``int``
+
+ :return: The newly created volume.
+ :rtype: :class:`StorageVolume`
"""
valid_volume_types = ['standard', 'io1', 'gp2']
@@ -2335,6 +2355,9 @@ class BaseEC2NodeDriver(NodeDriver):
raise ValueError('Invalid volume type specified: %s' %
(ex_volume_type))
+ if snapshot:
+ params['SnapshotId'] = snapshot.id
+
if location is not None:
params['AvailabilityZone'] = location.availability_zone.name