Ask Your Question
0

List image with params as limit = 1 using XML interface is returning an extra tag

asked 2013-03-15 07:11:37 -0600

harika-vakadi gravatar image

While trying to list images using filter as limit = 1

http://10.233.52.230:8774/v2/6bbd80f698a241d58aa5dfebcd073b8b/images?limit=1 (http://10.233.52.230:8774/v2/6bbd80f6...)

The xml response is returning an extra tag "<atom:link href="http://10.233.52.230:8774/v2/6bbd80f698a241d58aa5dfebcd073b8b/images?limit=1&amp;marker=8e6f2a43-5a6c-459f-8e0f-d72808c6ea06" rel="next"/>"

XML Response:

<images xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1"><image name="cirros-0.3.1-x86_64-uec" id="8e6f2a43-5a6c-459f-8e0f-d72808c6ea06"><atom:link href="http://10.233.52.230:8774/v2/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06" rel="self"/><atom:link href="http://10.233.52.230:8774/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06" rel="bookmark"/><atom:link href="http://10.233.52.230:9292/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06" type="application/vnd.openstack.image" rel="alternate"/></image><atom:link href="http://10.233.52.230:8774/v2/6bbd80f698a241d58aa5dfebcd073b8b/images?limit=1&amp;marker=8e6f2a43-5a6c-459f-8e0f-d72808c6ea06" rel="next"/></images>

The result of parse the above body to JSON is as below

XML_parse_body = [{'name': 'cirros-0.3.1-x86_64-uec', 'links': [{'href': 'http://10.233.52.230:8774/v2/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06', 'rel': 'self'}, {'href': 'http://10.233.52.230:8774/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06', 'rel': 'bookmark'}, {'href': 'http://10.233.52.230:9292/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06', 'type': 'application/vnd.openstack.image', 'rel': 'alternate'}], 'id': '8e6f2a43-5a6c-459f-8e0f-d72808c6ea06'}, {'href': 'http://10.233.52.230:8774/v2/6bbd80f698a241d58aa5dfebcd073b8b/images?limit=1&marker=8e6f2a43-5a6c-459f-8e0f-d72808c6ea06', 'rel': 'next'}]

len(XML_parse_body) = 2 Hence the lenght is resulting as "2" but not 1

Where as in the case of JSON response it is as below JSON_resp_body = [{u'id': u'8e6f2a43-5a6c-459f-8e0f-d72808c6ea06', u'links': [{u'href': u'http://10.233.52.230:8774/v2/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06', u'rel': u'self'}, {u'href': u'http://10.233.52.230:8774/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06', u'rel': u'bookmark'}, {u'href': u'http://10.233.52.230:9292/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06', u'type': u'application/vnd.openstack.image', u'rel': u'alternate'}], u'name': u'cirros-0.3.1-x86_64-uec'}]

len(JSON_resp_body) = 1

This is resulting a failure in execution of test case (list images with filters) for both XML and JSON interfaces simultaneously.

Can any one please clarify on this ASAP?

It is as expected in the case of list images with details

url = http://10.233.52.230:8774/v2/6bbd80f698a241d58aa5dfebcd073b8b/images/detail?limit=1 (http://10.233.52.230:8774/v2/6bbd80f6...)

XML Response

<images xmlns:os-dcf="http://docs.openstack.org/compute/ext/disk_config/api/v1.1" xmlns:os-ext-img-size="http://docs.openstack.org/compute/ext/image_size/api/v1.1" xmlns:atom="http://www.w3.org/2005/Atom" xmlns="http://docs.openstack.org/compute/api/v1.1"><image status="ACTIVE" updated="2013-03-01T15:52:38Z" name="cirros-0.3.1-x86_64-uec" created="2013-03-01T15:52:37Z" mindisk="0" progress="100" minram="0" id="8e6f2a43-5a6c-459f-8e0f-d72808c6ea06" os-ext-img-size:size="25165824"><metadata><meta key="kernel_id">906e734d-95aa-4acb-bee0-4eff2fc73f30</meta><meta key="ramdisk_id">edafffbf-8a90-4d06-84a0-7e32f98655b8</meta></metadata><atom:link href="http://10.233.52.230:8774/v2/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06" rel="self"/><atom:link href="http://10.233.52.230:8774/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06" rel="bookmark ... (more)

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2013-03-29 09:13:16 -0600

harika-vakadi gravatar image

Thanks Giampaolo Lauria, that solved my question.

edit flag offensive delete link more
0

answered 2013-03-26 15:43:38 -0600

lauria gravatar image

This is really working as designed. The extra tag is supposed t be there as it is explained in the doc here: http://docs.openstack.org/api/openstack-compute/2/content/Paginated_Collections-d1e664.html (http://docs.openstack.org/api/opensta...)

"For convenience, collections are required to contain atom "next" links. They may optionally also contain "previous" links. The last page in the list will not contain a "next" link. The following examples illustrate three pages in a collection of images. The first page was retrieved via a GET to http://servers.api.openstack.org/v2/1234/images?limit=1 (http://servers.api.openstack.org/v2/1...) . In these examples, the limit parameter sets the page size to a single item. Subsequent links will honor the initial page size. Thus, a client may follow links to traverse a paginated collection without having to input the marker parameter. "

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2013-03-15 07:11:37 -0600

Seen: 54 times

Last updated: Mar 29 '13