Skip to content
This repository has been archived by the owner on Apr 1, 2019. It is now read-only.

Commit

Permalink
Cloud Block Storage implementation
Browse files Browse the repository at this point in the history
Missing calls:
-- create
-- all snapshots section
  • Loading branch information
rvoicilas committed Nov 4, 2012
1 parent 16fdd7a commit 0949e1f
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ Support for the following Rackspace Cloud services:
* CloudLoadBalancers
* CloudDNS
* CloudDatabases
* CloudBlockStorage

Planned Features
----------------
Expand Down
9 changes: 9 additions & 0 deletions docs/blockstorage.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
``blockstorage`` --- Rackspace Cloud Block Storage
==================================================

.. automodule:: vaporize.volumes

``Volume`` --- Volumes
----------------------
.. autoclass:: Volume
:members:
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ API
domains
loadbalancers
servers
blockstorage

Indices and tables
==================
Expand Down
2 changes: 1 addition & 1 deletion vaporize/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
56 changes: 56 additions & 0 deletions vaporize/volumes.py
Original file line number Diff line number Diff line change
@@ -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.