libcloud-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From to...@apache.org
Subject [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.
Date Fri, 03 Jan 2014 14:59:48 GMT
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 <rickw@google.com>
Authored: Mon Dec 30 23:40:22 2013 -0800
Committer: Rick Wright <rickw@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.


Mime
View raw message