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

Asked by Harika Vakadi

While trying to list images using filter as limit = 1

http://10.233.52.230:8774/v2/6bbd80f698a241d58aa5dfebcd073b8b/images?limit=1

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:

<?xml version='1.0' encoding='UTF-8'?>
<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

XML Response

<?xml version='1.0' encoding='UTF-8'?>
<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"/><atom:link href="http://10.233.52.230:9292/6bbd80f698a241d58aa5dfebcd073b8b/images/8e6f2a43-5a6c-459f-8e0f-d72808c6ea06" type="application/vnd.openstack.image" rel="alternate"/></image></images>

Details_XML_Parse_body = [{'status': 'ACTIVE', 'updated': '2013-03-01T15:52:38Z', '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'}], 'created': '2013-03-01T15:52:37Z', 'minDisk': '0', '{http://docs.openstack.org/compute/ext/image_size/api/v1.1}size': '25165824', 'progress': '100', 'minRam': '0', 'id': '8e6f2a43-5a6c-459f-8e0f-d72808c6ea06', 'metadata': {'kernel_id': '906e734d-95aa-4acb-bee0-4eff2fc73f30', 'ramdisk_id': 'edafffbf-8a90-4d06-84a0-7e32f98655b8'}}]

len(Details_XML_Parse_body) = 1

Thanks in advance,
Harika.

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Compute (nova) Edit question
Assignee:
No assignee Edit question
Solved by:
Giampaolo Lauria
Solved:
Last query:
Last reply:
Revision history for this message
Best Giampaolo Lauria (lauria) said :
#1

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

"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. 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. "

Revision history for this message
Harika Vakadi (harika-vakadi) said :
#2

Thanks Giampaolo Lauria, that solved my question.