Skip to content

Commit

Permalink
Merge trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Feb 18, 2011
2 parents 9835b3d + 1f890ec commit a9415cd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion glance/registry/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class Image(BASE, ModelBase):

@validates('type')
def validate_type(self, key, type):
if not type in ('machine', 'kernel', 'ramdisk', 'raw'):
if not type in ('machine', 'kernel', 'ramdisk', 'raw', 'vhd'):
raise exception.Invalid(
"Invalid image type '%s' for image." % type)
return type
Expand Down
8 changes: 7 additions & 1 deletion glance/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,13 @@ def create(self, req):
location = req.headers['x-image-meta-location']
self._activate(req, image_meta, location)

return dict(image=image_meta)
# APP states we should return a Location: header with the edit
# URI of the resource newly-created.
res = Response(request=req, body=json.dumps(dict(image=image_meta)),
content_type="text/plain")
res.headers.add('Location', "/images/%s" % image_meta['id'])

return req.get_response(res)

def update(self, req, id):
"""
Expand Down
8 changes: 8 additions & 0 deletions tests/unit/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,14 @@ def test_add_image_basic_file_store(self):
self.assertEquals(res_body['location'],
'file:///tmp/glance-tests/3')

# Test that the Location: header is set to the URI to
# edit the newly-created image, as required by APP.
# See LP Bug #719825
self.assertTrue('location' in res.headers,
"'location' not in response headers.\n"
"res.headerlist = %r" % res.headerlist)
self.assertTrue('/images/3' in res.headers['location'])

def test_image_meta(self):
"""Test for HEAD /images/<ID>"""
expected_headers = {'x-image-meta-id': 2,
Expand Down

0 comments on commit a9415cd

Please sign in to comment.