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:03 UTC

[1/5] libcloud git commit: Change signature of base class (see comment)

Repository: libcloud
Updated Branches:
  refs/heads/trunk ab6ad7758 -> 659d64cec


Change signature of base class (see comment)

The base driver defines a signature that is not used by any of the drivers implementing `create_volume`.

1. `gandi` does not use the snapshot parameter.
1. `gce` uses the parameter, but accepts either a string or an object or None.
1. `ibm` does not use the snapshot parameter.
1. `opennebula` does not use the snapshot parameter.
1. `profitbricks` breaks the contract entirely.

In this PR both `ec2` and `openstack` implement the signature like this. This matches `gce`, so all drivers using the snapshot functionality act like this new signature.

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/53f9917b
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/53f9917b
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/53f9917b

Branch: refs/heads/trunk
Commit: 53f9917b04b184341607d4d44c27957a3edd6ebd
Parents: 1628fc4
Author: Allard Hoeve <al...@byte.nl>
Authored: Tue Feb 24 13:54:36 2015 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Wed Mar 4 23:30:12 2015 +0100

----------------------------------------------------------------------
 libcloud/compute/base.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/53f9917b/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index 8387104..1705950 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -997,9 +997,9 @@ class NodeDriver(BaseDriver):
                                (optional)
         :type location: :class:`.NodeLocation`
 
-        :param snapshot:  Name of snapshot from which to create the new
-                               volume.  (optional)
-        :type snapshot:  ``str``
+        :param snapshot:  Snapshot from which to create the new
+                          volume.  (optional)
+        :type snapshot: :class:`.VolumeSnapshot`
 
         :return: The newly created volume.
         :rtype: :class:`StorageVolume`


[4/5] libcloud git commit: Re-add availability_zone

Posted by to...@apache.org.
Re-add availability_zone

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/eff4644f
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/eff4644f
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/eff4644f

Branch: refs/heads/trunk
Commit: eff4644ff4eed393bc82cb84306d3698e49aed43
Parents: 53f9917
Author: Allard Hoeve <al...@byte.nl>
Authored: Fri Feb 27 10:23:07 2015 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Wed Mar 4 23:30:13 2015 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/openstack.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/eff4644f/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index 313abab..34c41b1 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -177,7 +177,8 @@ class OpenStackNodeDriver(NodeDriver, OpenStackDriverMixin):
             'volume_type': None,
             'metadata': {
                 'contents': name,
-            }
+            },
+            'availability_zone': location
         }
 
         if snapshot:


[2/5] libcloud git commit: Implement creating volumes from OpenStack snapshots

Posted by to...@apache.org.
Implement creating volumes from OpenStack snapshots

LIBCLOUD-673 #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/1628fc49
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/1628fc49
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/1628fc49

Branch: refs/heads/trunk
Commit: 1628fc49bb39ebfa43f26618aaa7edd6ee80b039
Parents: ceccf30
Author: Allard Hoeve <al...@byte.nl>
Authored: Tue Feb 24 13:50:42 2015 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Wed Mar 4 23:30:12 2015 +0100

----------------------------------------------------------------------
 libcloud/compute/drivers/openstack.py | 48 +++++++++++++++++++++---------
 1 file changed, 34 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/1628fc49/libcloud/compute/drivers/openstack.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/openstack.py b/libcloud/compute/drivers/openstack.py
index da8c05b..313abab 100644
--- a/libcloud/compute/drivers/openstack.py
+++ b/libcloud/compute/drivers/openstack.py
@@ -149,23 +149,43 @@ class OpenStackNodeDriver(NodeDriver, OpenStackDriverMixin):
             self.connection.request('/servers/detail', params=params).object)
 
     def create_volume(self, size, name, location=None, snapshot=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`
+
+        :return: The newly created volume.
+        :rtype: :class:`StorageVolume`
+        """
+        volume = {
+            'display_name': name,
+            'display_description': name,
+            'size': size,
+            'volume_type': None,
+            'metadata': {
+                'contents': name,
+            }
+        }
+
         if snapshot:
-            raise NotImplementedError(
-                "create_volume does not yet support create from snapshot")
+            volume['snapshot_id'] = snapshot.id
+
         resp = self.connection.request('/os-volumes',
                                        method='POST',
-                                       data={
-                                           'volume': {
-                                               'display_name': name,
-                                               'display_description': name,
-                                               'size': size,
-                                               'volume_type': None,
-                                               'metadata': {
-                                                   'contents': name,
-                                               },
-                                               'availability_zone': location,
-                                           }
-                                       })
+                                       data={'volume': volume})
         return self._to_volume(resp.object)
 
     def destroy_volume(self, volume):


[3/5] libcloud git commit: Implement creating volumes from EC2 snapshots

Posted by to...@apache.org.
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
 


[5/5] libcloud git commit: Document create volume from snapshot changes

Posted by to...@apache.org.
Document create volume from snapshot changes

Closes #467

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/659d64ce
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/659d64ce
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/659d64ce

Branch: refs/heads/trunk
Commit: 659d64cece8aeb6b1679e40e00dd639eee7a9cde
Parents: eff4644
Author: Allard Hoeve <al...@gmail.com>
Authored: Sun Mar 1 12:51:15 2015 +0100
Committer: Tomaz Muraus <to...@apache.org>
Committed: Wed Mar 4 23:30:51 2015 +0100

----------------------------------------------------------------------
 CHANGES.rst            |  6 ++++++
 docs/upgrade_notes.rst | 10 ++++++++++
 2 files changed, 16 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/659d64ce/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 96b3971..b33aede 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -15,6 +15,12 @@ General
 Compute
 ~~~~~~~
 
+- Add support for creating volumes based on snapshots to EC2 and OS drivers.
+  Also modify signature of base NodeDriver.create_volume to reflect the fact
+  that all drivers expect a StorageSnapshot object as the snapshot argument.
+  (GITHUB-467, LIBCLOUD-672)
+  [Allard Hoeve]
+
 - Improve GCE create_node, make sure ex_get_disktype function
   (GITHUB-448)
   [Markos Gogoulos]

http://git-wip-us.apache.org/repos/asf/libcloud/blob/659d64ce/docs/upgrade_notes.rst
----------------------------------------------------------------------
diff --git a/docs/upgrade_notes.rst b/docs/upgrade_notes.rst
index dd6c52b..93a104d 100644
--- a/docs/upgrade_notes.rst
+++ b/docs/upgrade_notes.rst
@@ -5,6 +5,16 @@ This page describes how to upgrade from a previous version to a new version
 which contains backward incompatible or semi-incompatible changes and how to
 preserve the old behavior when this is possible.
 
+Development
+-----------
+
+* The base signature of NodeDriver.create_volume has changed. The snapshot
+  argument is now expected to be a VolumeSnapshot instead of a string.
+  The older signature was never correct for built-in drivers, but custom
+  drivers may break. (GCE accepted strings, names or None and still does.
+  Other drivers did not implement creating volumes from snapshots at all
+  until now.)
+
 Libcloud 0.16.0
 ---------------