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/ce2fc3cb Tree: http://git-wip-us.apache.org/repos/asf/libcloud/tree/ce2fc3cb Diff: http://git-wip-us.apache.org/repos/asf/libcloud/diff/ce2fc3cb Branch: refs/heads/trunk Commit: ce2fc3cb54436e95d78b6823febb596acbbfbf6c Parents: c546826 Author: Rick Wright <[email protected]> Authored: Mon Dec 30 23:40:22 2013 -0800 Committer: Rick Wright <[email protected]> Committed: Mon Dec 30 23:40:22 2013 -0800 ---------------------------------------------------------------------- libcloud/compute/drivers/gce.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/libcloud/blob/ce2fc3cb/libcloud/compute/drivers/gce.py ---------------------------------------------------------------------- diff --git a/libcloud/compute/drivers/gce.py b/libcloud/compute/drivers/gce.py index 6315b6a..6573590 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.
