From 7e059f8b082f3f6e8bb2c877fc9f34e4f3f1288a Mon Sep 17 00:00:00 2001
From: Eric Fried <efried@us.ibm.com>
Date: Sun, 22 Oct 2017 16:06:30 -0500
Subject: [PATCH] placement: AllocCands.get_by_{filters => requests}

AllocationCandidates.get_by_filters used to take a `filter` parameter, a
dict with one member, 'resources'.  Looking toward granular resource
requests (and other things like limiting the number of results), this
change set reworks the method (and its down-stack callees) to be named
get_by_requests. These now accept a `requests` parameter, which is a
list of RequestGroup instances parsed from the querystring via
parse_qs_request_groups.

The current patch is just a refactor.  There is no API change, so the
schema will not allow anything other than the `resources` member of the
shared (use_same_provider=False) RequestGroup to come through.  That
member is extracted and passed down the line, resulting in no functional
change.

Change-Id: I8d7ccf56aa75d9183626f736b62fba62e239a826
blueprint: granular-resource-requests
---
 .../openstack/placement/handlers/allocation_candidate.py   | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/nova/api/openstack/placement/handlers/allocation_candidate.py b/nova/api/openstack/placement/handlers/allocation_candidate.py
index 394040852..8313e4ea9 100644
--- a/nova/api/openstack/placement/handlers/allocation_candidate.py
+++ b/nova/api/openstack/placement/handlers/allocation_candidate.py
@@ -163,13 +163,10 @@ def list_allocation_candidates(req):
     schema = _GET_SCHEMA_1_10
     util.validate_query_params(req, schema)
 
-    resources = util.normalize_resources_qs_param(req.GET['resources'])
-    filters = {
-        'resources': resources,
-    }
+    requests = util.parse_qs_request_groups(req.GET)
 
     try:
-        cands = rp_obj.AllocationCandidates.get_by_filters(context, filters)
+        cands = rp_obj.AllocationCandidates.get_by_requests(context, requests)
     except exception.ResourceClassNotFound as exc:
         raise webob.exc.HTTPBadRequest(
             _('Invalid resource class in resources parameter: %(error)s') %