Merge lp://qastaging/~johannes.erdfelt/nova/lp844910 into lp://qastaging/~hudson-openstack/nova/trunk

Proposed by Johannes Erdfelt
Status: Merged
Approved by: Dan Prince
Approved revision: 1561
Merged at revision: 1572
Proposed branch: lp://qastaging/~johannes.erdfelt/nova/lp844910
Merge into: lp://qastaging/~hudson-openstack/nova/trunk
Diff against target: 267 lines (+101/-28)
4 files modified
nova/api/openstack/versions.py (+4/-0)
nova/api/openstack/wsgi.py (+38/-5)
nova/tests/api/openstack/test_api.py (+25/-0)
nova/tests/api/openstack/test_wsgi.py (+34/-23)
To merge this branch: bzr merge lp://qastaging/~johannes.erdfelt/nova/lp844910
Reviewer Review Type Date Requested Status
Dan Prince (community) Approve
Brian Waldon (community) Approve
Jay Pipes (community) Approve
Review via email: mp+75255@code.qastaging.launchpad.net

Description of the change

The 1.1 API specifies that two vendor content types are allowed in addition to the standard JSON and XML content types.

This branch adds support for application/vnd.openstack.compute+json and application/vnd.openstack.compute+xml.

To post a comment you must log in.
Revision history for this message
Brian Waldon (bcwaldon) wrote :

Personally, I feel like these new content types are just aliases to their simpler counterparts. I don't really think it is necessary to map them individually for (de)serialization. Did you think about writing a simple middleware that just simplifies the content types?

Revision history for this message
Johannes Erdfelt (johannes.erdfelt) wrote :

I had thought about that, but if you alias the values, then the content-type returned won't necessarily match what is requested in the accept header.

Revision history for this message
Brian Waldon (bcwaldon) wrote :

Being middleware, you could remember that you aliased the value in the request and set it back in the response.

Revision history for this message
Johannes Erdfelt (johannes.erdfelt) wrote :

True, but the code would be relatively complicated. Much of the code in nova/api/openstack/wsgi.py deals with determining the best match for the accept header. This isn't trivial since content types can be weighted.

To handle the case of "application/vnd.openstack.compute+xml; q=0.2, application/xml; q=0.8" would require some fairly sophisticated code to parse out the accept, choose the best match, possibly replace/remove it from the accept header and then possibly replace the content-type on the response path.

It would duplicate much of the existing code.

The proposed branch is extremely straight forward and has no tricky code in it. I still think it's the better option.

Revision history for this message
Jay Pipes (jaypipes) wrote :

> True, but the code would be relatively complicated. Much of the code in
> nova/api/openstack/wsgi.py deals with determining the best match for the
> accept header. This isn't trivial since content types can be weighted.
>
> To handle the case of "application/vnd.openstack.compute+xml; q=0.2,
> application/xml; q=0.8" would require some fairly sophisticated code to parse
> out the accept, choose the best match, possibly replace/remove it from the
> accept header and then possibly replace the content-type on the response path.

Sophisticated code that's actually already written :)

http://docs.webob.org/en/latest/reference.html#accept-headers

-jay

Revision history for this message
Johannes Erdfelt (johannes.erdfelt) wrote :

The sophisticated code I meant was the code to wrap up the webob best match code with code to modify the Accept header.

The webob code makes matching against the Accept header easy, but not modifying it. That's the sophisticated part.

Revision history for this message
Jay Pipes (jaypipes) wrote :

OK, I don't really see why you would need to modify the Accept header at all (is that even advisable/legal?)

Revision history for this message
Jay Pipes (jaypipes) wrote :

In any case, my remark is not consequential to this patch being good, which it is ;)

review: Approve
Revision history for this message
Johannes Erdfelt (johannes.erdfelt) wrote :

I've made changes to simplify the code a little bit and fix a bug that snuck during a merge. The vendor types will be mapped to the standard types when the code goes to serialize or deserialize. This simplifies the code while minimizing the changes to all of the other code that handles XML serialization.

I also added a couple of more tests and a missing copyright.

Revision history for this message
Brian Waldon (bcwaldon) wrote :

This is great, Johannes.

review: Approve
Revision history for this message
Dan Prince (dan-prince) wrote :

This looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.