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 2013/07/17 00:01:56 UTC

[3/4] git commit: Added some as-yet-unimplemented methods to the base compute driver.

Added some as-yet-unimplemented methods to the base compute driver.

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

Branch: refs/heads/0.13.x
Commit: 8fd8acd8be4a72f010792c0d5ff4e9346fbe5538
Parents: 31a148b
Author: Alex Gaynor <al...@gmail.com>
Authored: Mon Jul 15 09:54:25 2013 -0700
Committer: Tomaz Muraus <to...@apache.org>
Committed: Tue Jul 16 23:58:43 2013 +0200

----------------------------------------------------------------------
 libcloud/compute/base.py | 57 ++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/8fd8acd8/libcloud/compute/base.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/base.py b/libcloud/compute/base.py
index 03f0ecf..5014a54 100644
--- a/libcloud/compute/base.py
+++ b/libcloud/compute/base.py
@@ -403,8 +403,23 @@ class StorageVolume(UuidMixin):
 
         return self.driver.detach_volume(volume=self)
 
+    def list_snapshots(self):
+        """
+        @returns C{list} of C{VolumeSnapshot}
+        """
+        return self.driver.list_volume_snapshots(volume=self)
+
+    def snapshot(self, name):
+        """
+        Creates a snapshot of this volume.
+
+        @returns C{VolumeSnapshot}
+        """
+        return self.driver.snapshot_volume(volume=self, name=name)
+
     def destroy(self):
-        """Destroy this storage volume.
+        """
+        Destroy this storage volume.
 
         @returns C{bool}
         """
@@ -416,6 +431,19 @@ class StorageVolume(UuidMixin):
                self.id, self.size, self.driver.name)
 
 
+class VolumeSnapshot(object):
+    def __init__(self, driver):
+        self.driver = driver
+
+    def destroy(self):
+        """
+        Destroys this snapshot.
+
+        @returns C{bool}
+        """
+        return self.driver.destroy_snapshot(snapshot=self)
+
+
 class NodeDriver(BaseDriver):
     """
     A base NodeDriver class to derive from
@@ -780,6 +808,33 @@ class NodeDriver(BaseDriver):
         raise NotImplementedError(
             'list_volumes not implemented for this driver')
 
+    def list_volume_snapshots(self, volume):
+        """
+        List snapshots for a storage volume.
+
+        @rtype: C{list} of L{VolumeSnapshot}
+        """
+        raise NotImplementedError(
+            'list_volume_snapshots not implemented for this driver')
+
+    def snapshot_volume(self, volume, name):
+        """
+        Creates a snapshot of the storage volume.
+
+        @rtype: L{VolumeSnapshot}
+        """
+        raise NotImplementedError(
+            'snapshot_volume not implemented for this driver')
+
+    def destroy_snapshot(self, snapshot):
+        """
+        Destroys a snapshot.
+
+        @rtype: L{bool}
+        """
+        raise NotImplementedError(
+            'destroy_snapshot not implemented for this driver')
+
     def _wait_until_running(self, node, wait_period=3, timeout=600,
                             ssh_interface='public_ips', force_ipv4=True):
         # This is here for backward compatibility and will be removed in the