Bug 863183

Summary: [RFE] [RHEVM-API] Expose size of all collections and sub-collections.
Product: Red Hat Enterprise Virtualization Manager Reporter: Stephen Gordon <sgordon>
Component: ovirt-engine-restapiAssignee: Ravi Nori <rnori>
Status: CLOSED WONTFIX QA Contact: Shai Revivo <srevivo>
Severity: low Docs Contact:
Priority: low    
Version: 3.1.0CC: acathrow, bazulay, ecohen, gklein, iheim, jkt, juan.hernandez, lpeer, oramraz, pstehlik, Rhev-m-bugs, yeylon
Target Milestone: ---Keywords: FutureFeature, Triaged
Target Release: 3.5.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: infra
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2014-03-18 08:56:16 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Infra RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Stephen Gordon 2012-10-04 15:50:46 UTC
Description of problem:

Currently, the only way to determine the size of a collection or sub-collection that is not included in the api summary information (which only contains vms, hosts, users, and storage_domains) is to iterate through all pages of the list method like so:

dc_list = []
dc_page_index = 1 
dc_page_current = api.datacenters.list(query="page %s" % dc_page_index)
while(len(dc_page_current) != 0): 
    dc_list = dc_list + dc_page_current
    dc_page_index = dc_page_index + 1 
    dc_page_current = api.datacenters.list(query="page %s" % dc_page_index)
print len(dc_list)

The REST API and SDK should ideally expose the size of all collections more directly.

Comment 1 Michael Pasternak 2012-10-09 13:18:16 UTC
1. i'm not sure if it works for RESTfull api

2. i did not convinced that knowing collection size ahead of
   paging/looping gives any benefit to the client.

what i do think, that client should be able retrieving entire collection,
using max=-1 or search dialect.

Comment 2 Stephen Gordon 2012-10-09 14:01:25 UTC
(In reply to comment #1)
> 2. i did not convinced that knowing collection size ahead of
>    paging/looping gives any benefit to the client.

This isn't the only reason you might want the size though. In my scenario I was working on an overview dashboard application with summary totals. The problem is that to generate those summary totals you effectively have to page through every record in every collection you are interested in - just to determine the size.

> what i do think, that client should be able retrieving entire collection,
> using max=-1 or search dialect.

I think, based on the discussions I lurked on in #rhev on Freenode, this is what many users/developers expect. Obviously in the documentation we would need to point out the performance risks of using this operation for large environments.

Comment 10 Juan Hernández 2014-03-18 08:56:16 UTC
After analyzing the complexity required to implement this (specially for subcollections implemented using queries), the cost in terms of performance and the benefit for the user we have came to the conclussion that it isn't worth implementing it.