summaryrefslogtreecommitdiffstats
path: root/nova/volume
diff options
context:
space:
mode:
authorEric Day <eday@oddments.org>2011-01-05 09:50:19 -0800
committerEric Day <eday@oddments.org>2011-01-05 09:50:19 -0800
commitdef5583469bd265c9107ed54d461441bc6303151 (patch)
tree36767dd00c4db73c345f76ea611b7873ab0879fe /nova/volume
parente97cb0f19f66ee4d28685575cea57b1eb32c4ed3 (diff)
downloadnova-def5583469bd265c9107ed54d461441bc6303151.tar.gz
nova-def5583469bd265c9107ed54d461441bc6303151.tar.xz
nova-def5583469bd265c9107ed54d461441bc6303151.zip
Split internal API get calls to get and get_all, where the former takes an ID and returns one resource, and the latter can optionally take a filter and return a list of resources.
Diffstat (limited to 'nova/volume')
-rw-r--r--nova/volume/api.py13
1 files changed, 7 insertions, 6 deletions
diff --git a/nova/volume/api.py b/nova/volume/api.py
index 48ecdbe68..2d7fe3762 100644
--- a/nova/volume/api.py
+++ b/nova/volume/api.py
@@ -63,7 +63,7 @@ class API(base.Base):
return volume
def delete(self, context, volume_id):
- volume = self.db.volume_get(context, volume_id)
+ volume = self.get(context, volume_id)
if volume['status'] != "available":
raise exception.ApiError(_("Volume status must be available"))
now = datetime.datetime.utcnow()
@@ -78,15 +78,16 @@ class API(base.Base):
def update(self, context, volume_id, fields):
self.db.volume_update(context, volume_id, fields)
- def get(self, context, volume_id=None):
- if volume_id is not None:
- return self.db.volume_get(context, volume_id)
+ def get(self, context, volume_id):
+ return self.db.volume_get(context, volume_id)
+
+ def get_all(self, context):
if context.user.is_admin():
return self.db.volume_get_all(context)
return self.db.volume_get_all_by_project(context, context.project_id)
def check_attach(self, context, volume_id):
- volume = self.db.volume_get(context, volume_id)
+ volume = self.get(context, volume_id)
# TODO(vish): abstract status checking?
if volume['status'] != "available":
raise exception.ApiError(_("Volume status must be available"))
@@ -94,7 +95,7 @@ class API(base.Base):
raise exception.ApiError(_("Volume is already attached"))
def check_detach(self, context, volume_id):
- volume = self.db.volume_get(context, volume_id)
+ volume = self.get(context, volume_id)
# TODO(vish): abstract status checking?
if volume['status'] == "available":
raise exception.ApiError(_("Volume is already detached"))