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 2014/01/03 15:59:48 UTC

[36/44] git commit: Add list_volume_snapshots method to help fill out the API. This is not an efficient method, but in GCE snapshots are not keyed on the volumes they are created from.

Add list_volume_snapshots method to help fill out the API.
This is not an efficient method, but in GCE snapshots are not keyed on the volumes they are created from.


Project: http://git-wip-us.apache.org/repos/asf/libcloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/libcloud/commit/c321b37d
Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/c321b37d
Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/c321b37d

Branch: refs/heads/trunk
Commit: c321b37da792da1231c0271ad847e813059961cd
Parents: 00c30bc
Author: Rick Wright <ri...@google.com>
Authored: Mon Dec 30 23:40:22 2013 -0800
Committer: Rick Wright <ri...@google.com>
Committed: Thu Jan 2 23:30:03 2014 -0800

----------------------------------------------------------------------
 libcloud/compute/drivers/gce.py | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/c321b37d/libcloud/compute/drivers/gce.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py
index f056774..c8e770f 100644
--- a/libcloud/compute/drivers/gce.py
+++ b/libcloud/compute/drivers/gce.py
@@ -1393,6 +1393,28 @@ class GCENodeDriver(NodeDriver):
 
         return self.ex_get_snapshot(name)
 
+    def list_volume_snapshots(self, volume):
+        """
+        List snapshots created from the provided volume.
+
+        For GCE, snapshots are global, but while the volume they were
+        created from still exists, the source disk for the snapshot is
+        tracked.
+
+        :param  volume: A StorageVolume object
+        :type   volume: :class:`StorageVolume`
+
+        :return:  A list of Snapshot objects
+        :rtype:   ``list`` of :class:`GCESnapshot`
+        """
+        volume_snapshots = []
+        volume_link = volume.extra['selfLink']
+        all_snapshots = self.ex_list_snapshots()
+        for snapshot in all_snapshots:
+            if snapshot.extra['sourceDisk'] == volume_link:
+                volume_snapshots.append(snapshot)
+        return volume_snapshots
+
     def ex_update_healthcheck(self, healthcheck):
         """
         Update a health check with new values.