You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by an...@apache.org on 2016/06/24 04:17:17 UTC

[1/6] libcloud git commit: Add tests for storage-related operations on the DigitalOcean driver

Repository: libcloud
Updated Branches:
  refs/heads/trunk 74a2ce762 -> 20c924bf1


Add tests for storage-related operations on the DigitalOcean driver


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

Branch: refs/heads/trunk
Commit: e450d9eeb6bcc713dc61a1e02033637978764b02
Parents: a796810
Author: Adam Wolfe Gordon <aw...@digitalocean.com>
Authored: Mon Jun 6 17:26:04 2016 -0400
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Jun 24 14:15:16 2016 +1000

----------------------------------------------------------------------
 .../fixtures/digitalocean_v2/attach_volume.json | 34 ++++++++++
 .../fixtures/digitalocean_v2/create_volume.json | 32 +++++++++
 .../fixtures/digitalocean_v2/detach_volume.json | 34 ++++++++++
 .../fixtures/digitalocean_v2/list_volumes.json  | 38 +++++++++++
 .../digitalocean_v2/list_volumes_empty.json     |  7 ++
 libcloud/test/compute/test_digitalocean_v2.py   | 69 ++++++++++++++++++++
 6 files changed, 214 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/e450d9ee/libcloud/test/compute/fixtures/digitalocean_v2/attach_volume.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/attach_volume.json b/libcloud/test/compute/fixtures/digitalocean_v2/attach_volume.json
new file mode 100644
index 0000000..398bca0
--- /dev/null
+++ b/libcloud/test/compute/fixtures/digitalocean_v2/attach_volume.json
@@ -0,0 +1,34 @@
+{
+  "action": {
+    "region_slug": "nyc1",
+    "region": {
+      "available": true,
+      "features": [
+        "private_networking",
+        "backups",
+        "ipv6",
+        "metadata"
+      ],
+      "sizes": [
+        "512mb",
+        "1gb",
+        "2gb",
+        "4gb",
+        "8gb",
+        "16gb",
+        "32gb",
+        "48gb",
+        "64gb"
+      ],
+      "slug": "nyc1",
+      "name": "New York 1"
+    },
+    "resource_type": "backend",
+    "resource_id": null,
+    "completed_at": null,
+    "started_at": "2016-06-06T21:01:30Z",
+    "type": "attach_volume",
+    "status": "in-progress",
+    "id": 110956293
+  }
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/e450d9ee/libcloud/test/compute/fixtures/digitalocean_v2/create_volume.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/create_volume.json b/libcloud/test/compute/fixtures/digitalocean_v2/create_volume.json
new file mode 100644
index 0000000..dd336aa
--- /dev/null
+++ b/libcloud/test/compute/fixtures/digitalocean_v2/create_volume.json
@@ -0,0 +1,32 @@
+{
+  "volume": {
+    "created_at": "2016-06-06T20:51:04Z",
+    "size_gigabytes": 4,
+    "description": "Block store for examples",
+    "name": "example",
+    "droplet_ids": [],
+    "region": {
+      "available": true,
+      "features": [
+        "private_networking",
+        "backups",
+        "ipv6",
+        "metadata"
+      ],
+      "sizes": [
+        "512mb",
+        "1gb",
+        "2gb",
+        "4gb",
+        "8gb",
+        "16gb",
+        "32gb",
+        "48gb",
+        "64gb"
+      ],
+      "slug": "nyc1",
+      "name": "New York 1"
+    },
+    "id": "62766883-2c28-11e6-b8e6-000f53306ae1"
+  }
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/e450d9ee/libcloud/test/compute/fixtures/digitalocean_v2/detach_volume.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/detach_volume.json b/libcloud/test/compute/fixtures/digitalocean_v2/detach_volume.json
new file mode 100644
index 0000000..9ef1c33
--- /dev/null
+++ b/libcloud/test/compute/fixtures/digitalocean_v2/detach_volume.json
@@ -0,0 +1,34 @@
+{
+  "action": {
+    "region_slug": "nyc1",
+    "region": {
+      "available": true,
+      "features": [
+        "private_networking",
+        "backups",
+        "ipv6",
+        "metadata"
+      ],
+      "sizes": [
+        "512mb",
+        "1gb",
+        "2gb",
+        "4gb",
+        "8gb",
+        "16gb",
+        "32gb",
+        "48gb",
+        "64gb"
+      ],
+      "slug": "nyc1",
+      "name": "New York 1"
+    },
+    "resource_type": "backend",
+    "resource_id": null,
+    "completed_at": null,
+    "started_at": "2016-06-06T21:02:20Z",
+    "type": "detach_volume",
+    "status": "in-progress",
+    "id": 110956599
+  }
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/e450d9ee/libcloud/test/compute/fixtures/digitalocean_v2/list_volumes.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/list_volumes.json b/libcloud/test/compute/fixtures/digitalocean_v2/list_volumes.json
new file mode 100644
index 0000000..7ab3da8
--- /dev/null
+++ b/libcloud/test/compute/fixtures/digitalocean_v2/list_volumes.json
@@ -0,0 +1,38 @@
+{
+  "volumes": [
+    {
+      "size_gigabytes": 4,
+      "region": {
+        "slug": "nyc1",
+        "sizes": [
+          "512mb",
+          "1gb",
+          "2gb",
+          "4gb",
+          "8gb",
+          "16gb",
+          "32gb",
+          "48gb",
+          "64gb"
+        ],
+        "name": "New York 1",
+        "features": [
+          "private_networking",
+          "backups",
+          "ipv6",
+          "metadata"
+        ],
+        "available": true
+      },
+      "name": "example",
+      "id": "62766883-2c28-11e6-b8e6-000f53306ae1",
+      "droplet_ids": [],
+      "description": "Block store for examples",
+      "created_at": "2016-06-06T20:51:04Z"
+    }
+  ],
+  "links": {},
+  "meta": {
+    "total": 1
+  }
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/e450d9ee/libcloud/test/compute/fixtures/digitalocean_v2/list_volumes_empty.json
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/fixtures/digitalocean_v2/list_volumes_empty.json b/libcloud/test/compute/fixtures/digitalocean_v2/list_volumes_empty.json
new file mode 100644
index 0000000..f05e66f
--- /dev/null
+++ b/libcloud/test/compute/fixtures/digitalocean_v2/list_volumes_empty.json
@@ -0,0 +1,7 @@
+{
+  "volumes": [],
+  "links": {},
+  "meta": {
+    "total": 0
+  }
+}

http://git-wip-us.apache.org/repos/asf/libcloud/blob/e450d9ee/libcloud/test/compute/test_digitalocean_v2.py
----------------------------------------------------------------------
diff --git a/libcloud/test/compute/test_digitalocean_v2.py b/libcloud/test/compute/test_digitalocean_v2.py
index 1754ce1..25e6e76 100644
--- a/libcloud/test/compute/test_digitalocean_v2.py
+++ b/libcloud/test/compute/test_digitalocean_v2.py
@@ -189,6 +189,48 @@ class DigitalOcean_v2_Tests(LibcloudTestCase):
         nodes = self.driver._paginated_request('/v2/droplets', 'droplets')
         self.assertEqual(len(nodes), 2)
 
+    def test_list_volumes(self):
+        volumes = self.driver.list_volumes()
+        self.assertEqual(len(volumes), 1)
+        volume = volumes[0]
+        self.assertEqual(volume.id, "62766883-2c28-11e6-b8e6-000f53306ae1")
+        self.assertEqual(volume.name, "example")
+        self.assertEqual(volume.size, 4)
+        self.assertEqual(volume.driver, self.driver)
+
+    def test_list_volumes_empty(self):
+        DigitalOceanMockHttp.type = 'EMPTY'
+        volumes = self.driver.list_volumes()
+        self.assertEqual(len(volumes), 0)
+
+    def test_create_volume(self):
+        nyc1 = [r for r in self.driver.list_locations() if r.id == 'nyc1'][0]
+        DigitalOceanMockHttp.type = 'CREATE'
+        volume = self.driver.create_volume(4, 'example', nyc1)
+        self.assertEqual(volume.id, "62766883-2c28-11e6-b8e6-000f53306ae1")
+        self.assertEqual(volume.name, "example")
+        self.assertEqual(volume.size, 4)
+        self.assertEqual(volume.driver, self.driver)
+
+    def test_attach_volume(self):
+        node = self.driver.list_nodes()[0]
+        volume = self.driver.list_volumes()[0]
+        DigitalOceanMockHttp.type = 'ATTACH'
+        resp = self.driver.attach_volume(node, volume)
+        self.assertTrue(resp)
+
+    def test_detach_volume(self):
+        volume = self.driver.list_volumes()[0]
+        DigitalOceanMockHttp.type = 'DETACH'
+        resp = self.driver.detach_volume(volume)
+        self.assertTrue(resp)
+
+    def test_destroy_volume(self):
+        volume = self.driver.list_volumes()[0]
+        DigitalOceanMockHttp.type = 'DESTROY'
+        resp = self.driver.destroy_volume(volume)
+        self.assertTrue(resp)
+
 
 class DigitalOceanMockHttp(MockHttpTestCase):
     fixtures = ComputeFileFixtures('digitalocean_v2')
@@ -279,5 +321,32 @@ class DigitalOceanMockHttp(MockHttpTestCase):
         body = self.fixtures.load('list_nodes_page_1.json')
         return (httplib.OK, body, {}, httplib.responses[httplib.OK])
 
+    def _v2_volumes(self, method, url, body, headers):
+        body = self.fixtures.load('list_volumes.json')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _v2_volumes_EMPTY(self, method, url, body, headers):
+        body = self.fixtures.load('list_volumes_empty.json')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _v2_volumes_CREATE(self, method, url, body, headers):
+        body = self.fixtures.load('create_volume.json')
+        return (httplib.CREATED, body, {}, httplib.responses[httplib.CREATED])
+
+    def _v2_volumes_actions_ATTACH(self, method, url, body, headers):
+        body = self.fixtures.load('attach_volume.json')
+        return (httplib.ACCEPTED, body, {},
+                httplib.responses[httplib.ACCEPTED])
+
+    def _v2_volumes_DETACH(self, method, url, body, headers):
+        body = self.fixtures.load('detach_volume.json')
+        return (httplib.OK, body, {}, httplib.responses[httplib.OK])
+
+    def _v2_volumes_62766883_2c28_11e6_b8e6_000f53306ae1_DESTROY(self, method,
+                                                                 url, body,
+                                                                 headers):
+        return (httplib.NO_CONTENT, None, {},
+                httplib.responses[httplib.NO_CONTENT])
+
 if __name__ == '__main__':
     sys.exit(unittest.main())


[6/6] libcloud git commit: update changes for #807

Posted by an...@apache.org.
update changes for #807


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

Branch: refs/heads/trunk
Commit: 20c924bf1ba67322edd3404016babe6c0e45a62c
Parents: f1c2361
Author: Anthony Shaw <an...@apache.org>
Authored: Fri Jun 24 14:17:03 2016 +1000
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Jun 24 14:17:03 2016 +1000

----------------------------------------------------------------------
 CHANGES.rst | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/20c924bf/CHANGES.rst
----------------------------------------------------------------------
diff --git a/CHANGES.rst b/CHANGES.rst
index 1e27a32..faa4f22 100644
--- a/CHANGES.rst
+++ b/CHANGES.rst
@@ -7,6 +7,10 @@ Changes with current version of Apache Libcloud
 Compute
 ~~~~~~~
 
+- Add block storage support to DigitalOcean node driver
+  (GITHUB-807)
+  [Adam Wolfe Gordon]
+
 - Add SASL auth support to libvirt driver
   (GITHUB-809)
   [Katana-Steel]


[3/6] libcloud git commit: Implement {attach, detach}_volume for DigitalOcean

Posted by an...@apache.org.
Implement {attach,detach}_volume for DigitalOcean


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

Branch: refs/heads/trunk
Commit: a796810a138eaade2808dba78529e56ec20e33e4
Parents: cbda630
Author: Adam Wolfe Gordon <aw...@digitalocean.com>
Authored: Mon Jun 6 15:13:07 2016 -0400
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Jun 24 14:15:16 2016 +1000

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


http://git-wip-us.apache.org/repos/asf/libcloud/blob/a796810a/libcloud/compute/drivers/digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py
index e73d6ad..aefa099 100644
--- a/libcloud/compute/drivers/digitalocean.py
+++ b/libcloud/compute/drivers/digitalocean.py
@@ -584,6 +584,50 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
                                       method='DELETE')
         return res.status == httplib.NO_CONTENT
 
+    def attach_volume(self, node, volume, device=None):
+        """
+        Attaches volume to node.
+
+        :param node: Node to attach volume to.
+        :type node: :class:`.Node`
+
+        :param volume: Volume to attach.
+        :type volume: :class:`.StorageVolume`
+
+        :param device: Where the device is exposed, e.g. '/dev/sdb'
+        :type device: ``str``
+
+        :rytpe: ``bool``
+        """
+        attr = {'type': 'attach', 'droplet_id': node.id,
+                'volume_id': volume.id, 'region': volume.extra['region_slug']}
+
+        res = self.connection.request('/v2/volumes/actions',
+                                      data=json.dumps(attr), method='POST')
+
+        return res.status == httplib.ACCEPTED
+
+    def detach_volume(self, volume):
+        """
+        Detaches a volume from a node.
+
+        :param volume: Volume to be detached
+        :type volume: :class:`.StorageVolume`
+
+        :rtype: ``bool``
+        """
+        attr = {'type': 'detach', 'volume_id': volume.id,
+                'region': volume.extra['region_slug']}
+
+        responses = []
+        for droplet_id in volume.extra['droplet_ids']:
+            attr['droplet_id'] = droplet_id
+            res = self.connection.request('/v2/volumes/actions',
+                                          data=json.dumps(attr), method='POST')
+            responses.append(res)
+
+        return all([r.status == httplib.ACCEPTED for r in responses])
+
     def _to_node(self, data):
         extra_keys = ['memory', 'vcpus', 'disk', 'region', 'image',
                       'size_slug', 'locked', 'created_at', 'networks',


[5/6] libcloud git commit: Update docs to reflect that DigitalOcean has block storage Closes #807

Posted by an...@apache.org.
Update docs to reflect that DigitalOcean has block storage
Closes #807


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

Branch: refs/heads/trunk
Commit: f1c236154b34cb8c70f514adfdac9f53782d0cd8
Parents: e450d9e
Author: Adam Wolfe Gordon <aw...@digitalocean.com>
Authored: Mon Jun 6 18:44:18 2016 -0400
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Jun 24 14:16:15 2016 +1000

----------------------------------------------------------------------
 docs/compute/_supported_methods_block_storage.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/libcloud/blob/f1c23615/docs/compute/_supported_methods_block_storage.rst
----------------------------------------------------------------------
diff --git a/docs/compute/_supported_methods_block_storage.rst b/docs/compute/_supported_methods_block_storage.rst
index d184c85..60a33c6 100644
--- a/docs/compute/_supported_methods_block_storage.rst
+++ b/docs/compute/_supported_methods_block_storage.rst
@@ -14,7 +14,7 @@ Provider                              list volumes create volume destroy volume
 `CloudSigma (API v2.0)`_              no           no            no             no            no            no             no             
 `CloudStack`_                         yes          yes           yes            yes           yes           no             yes            
 `Cloudwatt`_                          yes          yes           yes            yes           yes           yes            yes            
-`DigitalOcean`_                       no           no            no             no            no            no             no             
+`DigitalOcean`_                       yes          yes           yes            yes           yes           no             no             
 `DimensionData`_                      no           no            no             no            no            no             no             
 `Amazon EC2`_                         yes          yes           yes            yes           yes           yes            yes            
 `Enomaly Elastic Computing Platform`_ no           no            no             no            no            no             no             


[4/6] libcloud git commit: Implement {create, destroy}_volume for DigitalOcean

Posted by an...@apache.org.
Implement {create,destroy}_volume for DigitalOcean


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

Branch: refs/heads/trunk
Commit: cbda6303f0f9f800a666bd00456fc2ae796cef62
Parents: 71eb956
Author: Adam Wolfe Gordon <aw...@digitalocean.com>
Authored: Mon Jun 6 15:12:52 2016 -0400
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Jun 24 14:15:16 2016 +1000

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


http://git-wip-us.apache.org/repos/asf/libcloud/blob/cbda6303/libcloud/compute/drivers/digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py
index f326bca..e73d6ad 100644
--- a/libcloud/compute/drivers/digitalocean.py
+++ b/libcloud/compute/drivers/digitalocean.py
@@ -536,6 +536,54 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
                                        qkey.extra['id']).object['ssh_key']
         return self._to_key_pair(data=data)
 
+    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`
+        """
+        attr = {'name': name, 'size_gigabytes': size, 'region': location.id}
+
+        res = self.connection.request('/v2/volumes', data=json.dumps(attr),
+                                      method='POST')
+        data = res.object['volume']
+        status = res.object.get('status', 'OK')
+        if status == 'ERROR':
+            message = res.object.get('message', None)
+            error_message = res.object.get('error_message', message)
+            raise ValueError('Failed to create volume: %s' % (error_message))
+
+        return self._to_volume(data=data)
+
+    def destroy_volume(self, volume):
+        """
+        Destroys a storage volume.
+
+        :param volume: Volume to be destroyed
+        :type volume: :class:`StorageVolume`
+
+        :rtype: ``bool``
+        """
+        res = self.connection.request('/v2/volumes/%s' % volume.id,
+                                      method='DELETE')
+        return res.status == httplib.NO_CONTENT
+
     def _to_node(self, data):
         extra_keys = ['memory', 'vcpus', 'disk', 'region', 'image',
                       'size_slug', 'locked', 'created_at', 'networks',


[2/6] libcloud git commit: Implement list_volumes for DigitalOcean

Posted by an...@apache.org.
Implement list_volumes for DigitalOcean


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

Branch: refs/heads/trunk
Commit: 71eb9565e1092dcf4468ee88692745868c3f2d44
Parents: 74a2ce7
Author: Adam Wolfe Gordon <aw...@digitalocean.com>
Authored: Mon Jun 6 15:12:23 2016 -0400
Committer: Anthony Shaw <an...@apache.org>
Committed: Fri Jun 24 14:15:16 2016 +1000

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


http://git-wip-us.apache.org/repos/asf/libcloud/blob/71eb9565/libcloud/compute/drivers/digitalocean.py
----------------------------------------------------------------------
diff --git a/libcloud/compute/drivers/digitalocean.py b/libcloud/compute/drivers/digitalocean.py
index 0428cbb..f326bca 100644
--- a/libcloud/compute/drivers/digitalocean.py
+++ b/libcloud/compute/drivers/digitalocean.py
@@ -27,6 +27,7 @@ from libcloud.common.types import InvalidCredsError
 from libcloud.compute.types import Provider, NodeState
 from libcloud.compute.base import NodeImage, NodeSize, NodeLocation, KeyPair
 from libcloud.compute.base import Node, NodeDriver
+from libcloud.compute.base import StorageVolume
 
 __all__ = [
     'DigitalOceanNodeDriver',
@@ -352,6 +353,10 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
         data = self._paginated_request('/v2/sizes', 'sizes')
         return list(map(self._to_size, data))
 
+    def list_volumes(self):
+        data = self._paginated_request('/v2/volumes', 'volumes')
+        return list(map(self._to_volume, data))
+
     def create_node(self, name, size, image, location, ex_create_attr=None,
                     ex_ssh_key_ids=None, ex_user_data=None):
         """
@@ -571,6 +576,16 @@ class DigitalOcean_v2_NodeDriver(DigitalOcean_v2_BaseDriver,
         return NodeImage(id=data['id'], name=data['name'], driver=self,
                          extra=extra)
 
+    def _to_volume(self, data):
+        extra = {'created_at': data['created_at'],
+                 'droplet_ids': data['droplet_ids'],
+                 'region': data['region'],
+                 'region_slug': data['region']['slug']}
+
+        return StorageVolume(id=data['id'], name=data['name'],
+                             size=data['size_gigabytes'], driver=self,
+                             extra=extra)
+
     def _to_location(self, data):
         return NodeLocation(id=data['slug'], name=data['name'], country=None,
                             driver=self)