Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cloud Block Storage implementation

Missing calls:
-- create
-- all snapshots section
  • Loading branch information...
commit 0949e1f96cf3c308f465a5c19cbd9623dad91447 1 parent 16fdd7a
@rvoicilas rvoicilas authored
View
1  README.rst
@@ -57,6 +57,7 @@ Support for the following Rackspace Cloud services:
* CloudLoadBalancers
* CloudDNS
* CloudDatabases
+ * CloudBlockStorage
Planned Features
----------------
View
9 docs/blockstorage.rst
@@ -0,0 +1,9 @@
+``blockstorage`` --- Rackspace Cloud Block Storage
+==================================================
+
+.. automodule:: vaporize.volumes
+
+ ``Volume`` --- Volumes
+ ----------------------
+ .. autoclass:: Volume
+ :members:
View
1  docs/index.rst
@@ -25,6 +25,7 @@ API
domains
loadbalancers
servers
+ blockstorage
Indices and tables
==================
View
2  vaporize/__init__.py
@@ -7,5 +7,5 @@
__license__ = 'MIT'
__copyright__ = 'Copyright 2012 Michael Lavers'
-from . import databases, domains, loadbalancers, servers
+from . import databases, domains, loadbalancers, servers, volumes
from .core import connect
View
56 vaporize/volumes.py
@@ -0,0 +1,56 @@
+from vaporize.core import get_url, handle_request
+from vaporize.utils import DotDict
+
+
+class Volume(DotDict):
+ """A CloudBlockStorage Volume."""
+
+ def delete(self):
+ """Delete this CloudBlockStorage volum."""
+ assert 'id' in self
+ url = '/'.join((get_url('cloudblockstorage'), 'volumes',
+ str(self['id'])))
+ handle_request('delete', url)
+
+ @classmethod
+ def list(cls, detail=False):
+ """Returns a list of volumes.
+
+ :param detail: Provides more details about the volume
+ :type detail: bool
+ :type: A list of :class:`Volume`
+ """
+ url = [get_url('cloudblockstorage'), 'volumes']
+ if detail:
+ url.append('detail')
+ url = '/'.join(url)
+ return handle_request('get', url, wrapper=cls, container='volumes')
+
+ @classmethod
+ def get(cls, volume_id):
+ """Returns a Volume by id
+
+ :param volume_id: The ``volume_id`` of the Volume to be retrieved
+ :type volume_id: str
+ :returns: A :class:`Volume`
+ """
+ url = '/'.join((get_url('cloudblockstorage'), 'volumes',
+ str(volume_id)))
+ return handle_request('get', url, wrapper=cls, container='volume')
+
+ @classmethod
+ def types(cls):
+ """Returns a list of volume types."""
+ url = '/'.join((get_url('cloudblockstorage'), 'types'))
+ return handle_request('get', url, container='volume_types')
+
+ @classmethod
+ def describe_type(cls, volume_type_id):
+ """Returns info about :param volume_type_id.
+
+ :param volume_type_id: One of the ids returned by the types() call.
+ :type volume_type_id: int
+ """
+ url = '/'.join((get_url('cloudblockstorage'), 'types',
+ str(volume_type_id)))
+ return handle_request('get', url, container='volume_type')

0 comments on commit 0949e1f

Please sign in to comment.
Something went wrong with that request. Please try again.