Merge lp:~gundlach/nova/image_ids into lp:~hudson-openstack/nova/trunk

Proposed by Michael Gundlach
Status: Merged
Approved by: Michael Gundlach
Approved revision: 333
Merged at revision: 333
Proposed branch: lp:~gundlach/nova/image_ids
Merge into: lp:~hudson-openstack/nova/trunk
Diff against target: 109 lines (+10/-18)
4 files modified
nova/api/rackspace/backup_schedules.py (+0/-1)
nova/api/rackspace/images.py (+1/-9)
nova/image/service.py (+9/-7)
nova/tests/api/rackspace/fakes.py (+0/-1)
To merge this branch: bzr merge lp:~gundlach/nova/image_ids
Reviewer Review Type Date Requested Status
Jay Pipes (community) Approve
Review via email: mp+37988@code.launchpad.net

Description of the change

Remove redis dependency from RS Images API.

To post a comment you must log in.
Revision history for this message
Jay Pipes (jaypipes) wrote :

w00t.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'nova/api/rackspace/backup_schedules.py'
2--- nova/api/rackspace/backup_schedules.py 2010-09-29 14:17:10 +0000
3+++ nova/api/rackspace/backup_schedules.py 2010-10-08 16:23:40 +0000
4@@ -19,7 +19,6 @@
5 from webob import exc
6
7 from nova import wsgi
8-from nova.api.rackspace import _id_translator
9 from nova.api.rackspace import faults
10 import nova.image.service
11
12
13=== modified file 'nova/api/rackspace/images.py'
14--- nova/api/rackspace/images.py 2010-10-01 20:06:14 +0000
15+++ nova/api/rackspace/images.py 2010-10-08 16:23:40 +0000
16@@ -20,7 +20,6 @@
17 from nova import flags
18 from nova import utils
19 from nova import wsgi
20-from nova.api.rackspace import _id_translator
21 import nova.api.rackspace
22 import nova.image.service
23 from nova.api.rackspace import faults
24@@ -41,8 +40,6 @@
25
26 def __init__(self):
27 self._service = utils.import_object(FLAGS.image_service)
28- self._id_translator = _id_translator.RackspaceAPIIdTranslator(
29- "image", self._service.__class__.__name__)
30
31 def index(self, req):
32 """Return all public images in brief."""
33@@ -53,16 +50,11 @@
34 """Return all public images in detail."""
35 data = self._service.index()
36 data = nova.api.rackspace.limited(data, req)
37- for img in data:
38- img['id'] = self._id_translator.to_rs_id(img['id'])
39 return dict(images=data)
40
41 def show(self, req, id):
42 """Return data about the given image id."""
43- opaque_id = self._id_translator.from_rs_id(id)
44- img = self._service.show(opaque_id)
45- img['id'] = id
46- return dict(image=img)
47+ return dict(image=self._service.show(id))
48
49 def delete(self, req, id):
50 # Only public images are supported for now.
51
52=== modified file 'nova/image/service.py'
53--- nova/image/service.py 2010-10-05 17:29:27 +0000
54+++ nova/image/service.py 2010-10-08 16:23:40 +0000
55@@ -225,7 +225,9 @@
56
57 class LocalImageService(BaseImageService):
58
59- """Image service storing images to local disk."""
60+ """Image service storing images to local disk.
61+
62+ It assumes that image_ids are integers."""
63
64 def __init__(self):
65 self._path = "/tmp/nova/images"
66@@ -234,12 +236,12 @@
67 except OSError: # exists
68 pass
69
70- def _path_to(self, image_id=''):
71- return os.path.join(self._path, image_id)
72+ def _path_to(self, image_id):
73+ return os.path.join(self._path, str(image_id))
74
75 def _ids(self):
76 """The list of all image ids."""
77- return os.listdir(self._path)
78+ return [int(i) for i in os.listdir(self._path)]
79
80 def index(self):
81 return [ self.show(id) for id in self._ids() ]
82@@ -254,7 +256,7 @@
83 """
84 Store the image data and return the new image id.
85 """
86- id = ''.join(random.choice(string.letters) for _ in range(20))
87+ id = random.randint(0, 2**32-1)
88 data['id'] = id
89 self.update(id, data)
90 return id
91@@ -279,5 +281,5 @@
92 """
93 Clears out all images in local directory
94 """
95- for f in os.listdir(self._path):
96- os.unlink(self._path_to(f))
97+ for id in self._ids():
98+ os.unlink(self._path_to(id))
99
100=== modified file 'nova/tests/api/rackspace/fakes.py'
101--- nova/tests/api/rackspace/fakes.py 2010-10-05 21:08:47 +0000
102+++ nova/tests/api/rackspace/fakes.py 2010-10-08 16:23:40 +0000
103@@ -28,7 +28,6 @@
104 from nova import flags
105 from nova import exception as exc
106 import nova.api.rackspace.auth
107-import nova.api.rackspace._id_translator
108 from nova.image import service
109 from nova.wsgi import Router
110