Include /resource_providers/uuid/allocations link

/resource_providers/{rp_uuid}/allocations has been available since
microversion 1.0 [1], but wasn't listed in the "links" section of the
GET /resource_providers response.  This change adds the link in a new
microversion, 1.11

[1] https://review.openstack.org/#/c/366789/

Closes-Bug: #1714275

Change-Id: I6a1d320ce914926791d5f45e89bf4c601a6b10a0
This commit is contained in:
Eric Fried 2017-08-31 17:02:33 -05:00
parent 9058ed951f
commit a9105b4904
7 changed files with 51 additions and 4 deletions

View File

@ -90,6 +90,8 @@ def _serialize_links(environ, resource_provider):
rel_types.append('aggregates')
if want_version >= (1, 6):
rel_types.append('traits')
if want_version >= (1, 11):
rel_types.append('allocations')
for rel in rel_types:
links.append({'rel': rel, 'href': '%s/%s' % (url, rel)})
return links

View File

@ -48,6 +48,7 @@ VERSIONS = [
# PUT /allocations
'1.9', # Adds GET /usages
'1.10', # Adds GET /allocation_candidates resource endpoint
'1.11', # Adds 'allocations' link to the GET /resource_providers response
]

View File

@ -152,3 +152,10 @@ The 1.10 version brings a new REST resource endpoint for getting a list of
allocation candidates. Allocation candidates are collections of possible
allocations against resource providers that can satisfy a particular request
for resources.
1.11 Add 'allocations' link to the ``GET /resource_providers`` response
-----------------------------------------------------------------------
The ``/resource_providers/{rp_uuid}/allocations`` endpoint has been available
since version 1.0, but was not listed in the ``links`` section of the
``GET /resource_providers`` response. The link is included as of version 1.11.

View File

@ -39,13 +39,13 @@ tests:
response_json_paths:
$.errors[0].title: Not Acceptable
- name: latest microversion is 1.10
- name: latest microversion is 1.11
GET: /
request_headers:
openstack-api-version: placement latest
response_headers:
vary: /OpenStack-API-Version/
openstack-api-version: placement 1.10
openstack-api-version: placement 1.11
- name: other accept header bad version
GET: /

View File

@ -24,11 +24,12 @@ tests:
request_headers:
openstack-api-version: placement latest
response_json_paths:
$.links.`len`: 5
$.links.`len`: 6
$.links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']
$.links[?rel = "inventories"].href: /resource_providers/$ENVIRON['RP_UUID']/inventories
$.links[?rel = "aggregates"].href: /resource_providers/$ENVIRON['RP_UUID']/aggregates
$.links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages
$.links[?rel = "allocations"].href: /resource_providers/$ENVIRON['RP_UUID']/allocations
$.links[?rel = "traits"].href: /resource_providers/$ENVIRON['RP_UUID']/traits
- name: get rp 1.0
@ -90,3 +91,16 @@ tests:
$.links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages
$.links[?rel = "aggregates"].href: /resource_providers/$ENVIRON['RP_UUID']/aggregates
$.links[?rel = "traits"].href: /resource_providers/$ENVIRON['RP_UUID']/traits
- name: get rp allocations link added in 1.11
GET: /resource_providers/$ENVIRON['RP_UUID']
request_headers:
openstack-api-version: placement 1.11
response_json_paths:
$.links.`len`: 6
$.links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']
$.links[?rel = "inventories"].href: /resource_providers/$ENVIRON['RP_UUID']/inventories
$.links[?rel = "aggregates"].href: /resource_providers/$ENVIRON['RP_UUID']/aggregates
$.links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages
$.links[?rel = "allocations"].href: /resource_providers/$ENVIRON['RP_UUID']/allocations
$.links[?rel = "traits"].href: /resource_providers/$ENVIRON['RP_UUID']/traits

View File

@ -147,12 +147,29 @@ tests:
response_json_paths:
$.errors[0].title: Bad Request
- name: list one resource provider filtering by uuid
- name: list one resource provider filtering by uuid with allocations link
GET: /resource_providers?uuid=$ENVIRON['RP_UUID']
request_headers:
openstack-api-version: placement 1.11
response_json_paths:
$.resource_providers.`len`: 1
$.resource_providers[0].uuid: $ENVIRON['RP_UUID']
$.resource_providers[0].name: $ENVIRON['RP_NAME']
$.resource_providers[0].links.`len`: 6
$.resource_providers[0].links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']
$.resource_providers[0].links[?rel = "inventories"].href: /resource_providers/$ENVIRON['RP_UUID']/inventories
$.resource_providers[0].links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages
$.resource_providers[0].links[?rel = "allocations"].href: /resource_providers/$ENVIRON['RP_UUID']/allocations
- name: list one resource provider filtering by uuid no allocations link
GET: /resource_providers?uuid=$ENVIRON['RP_UUID']
request_headers:
openstack-api-version: placement 1.10
response_json_paths:
$.resource_providers.`len`: 1
$.resource_providers[0].uuid: $ENVIRON['RP_UUID']
$.resource_providers[0].name: $ENVIRON['RP_NAME']
$.resource_providers[0].links.`len`: 5
$.resource_providers[0].links[?rel = "self"].href: /resource_providers/$ENVIRON['RP_UUID']
$.resource_providers[0].links[?rel = "inventories"].href: /resource_providers/$ENVIRON['RP_UUID']/inventories
$.resource_providers[0].links[?rel = "usages"].href: /resource_providers/$ENVIRON['RP_UUID']/usages

View File

@ -0,0 +1,6 @@
---
features:
- |
A new 1.11 API microversion is added to the Placement REST API. This adds
the ``resource_providers/{rp_uuid}/allocations`` link to the ``links``
section of the response from ``GET /resource_providers``.