summaryrefslogtreecommitdiffstats
path: root/nova/image
diff options
context:
space:
mode:
authorMichael Gundlach <michael.gundlach@rackspace.com>2010-10-08 12:21:26 -0400
committerMichael Gundlach <michael.gundlach@rackspace.com>2010-10-08 12:21:26 -0400
commitdb87fd5a8145d045c4767a8d02cde5a0750113f8 (patch)
tree3aa6c9a09fec377ecd2b198defe73483f2447e6f /nova/image
parentdb331240afdbd43d63b0a71cc284fc8d37e7989a (diff)
downloadnova-db87fd5a8145d045c4767a8d02cde5a0750113f8.tar.gz
nova-db87fd5a8145d045c4767a8d02cde5a0750113f8.tar.xz
nova-db87fd5a8145d045c4767a8d02cde5a0750113f8.zip
Remove redis dependency from Images controller.
LocalImageService now works with integer ids, so there's no need for the translator. Once Glance exists we'll have to revisit this.
Diffstat (limited to 'nova/image')
-rw-r--r--nova/image/service.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/nova/image/service.py b/nova/image/service.py
index 2e570e8a4..5276e1312 100644
--- a/nova/image/service.py
+++ b/nova/image/service.py
@@ -225,7 +225,9 @@ class GlanceImageService(BaseImageService):
class LocalImageService(BaseImageService):
- """Image service storing images to local disk."""
+ """Image service storing images to local disk.
+
+ It assumes that image_ids are integers."""
def __init__(self):
self._path = "/tmp/nova/images"
@@ -234,12 +236,12 @@ class LocalImageService(BaseImageService):
except OSError: # exists
pass
- def _path_to(self, image_id=''):
- return os.path.join(self._path, image_id)
+ def _path_to(self, image_id):
+ return os.path.join(self._path, str(image_id))
def _ids(self):
"""The list of all image ids."""
- return os.listdir(self._path)
+ return [int(i) for i in os.listdir(self._path)]
def index(self):
return [ self.show(id) for id in self._ids() ]
@@ -254,7 +256,7 @@ class LocalImageService(BaseImageService):
"""
Store the image data and return the new image id.
"""
- id = ''.join(random.choice(string.letters) for _ in range(20))
+ id = random.randint(0, 2**32-1)
data['id'] = id
self.update(id, data)
return id
@@ -279,5 +281,5 @@ class LocalImageService(BaseImageService):
"""
Clears out all images in local directory
"""
- for f in os.listdir(self._path):
- os.unlink(self._path_to(f))
+ for id in self._ids():
+ os.unlink(self._path_to(id))