diff --git a/nova/api/openstack/placement/handlers/resource_provider.py b/nova/api/openstack/placement/handlers/resource_provider.py index 45fbe9b2c5fe..c504bc94fc72 100644 --- a/nova/api/openstack/placement/handlers/resource_provider.py +++ b/nova/api/openstack/placement/handlers/resource_provider.py @@ -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 diff --git a/nova/api/openstack/placement/microversion.py b/nova/api/openstack/placement/microversion.py index 41406293609f..892ef27761e7 100644 --- a/nova/api/openstack/placement/microversion.py +++ b/nova/api/openstack/placement/microversion.py @@ -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 ] diff --git a/nova/api/openstack/placement/rest_api_version_history.rst b/nova/api/openstack/placement/rest_api_version_history.rst index 6d691ba2fe38..510cc8ef5e29 100644 --- a/nova/api/openstack/placement/rest_api_version_history.rst +++ b/nova/api/openstack/placement/rest_api_version_history.rst @@ -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. diff --git a/nova/tests/functional/api/openstack/placement/gabbits/microversion.yaml b/nova/tests/functional/api/openstack/placement/gabbits/microversion.yaml index 778ab4fce0db..dcd4f4dce8a8 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/microversion.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/microversion.yaml @@ -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: / diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-provider-links.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-provider-links.yaml index 766c2654116b..304d9fca9bce 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/resource-provider-links.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-provider-links.yaml @@ -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 diff --git a/nova/tests/functional/api/openstack/placement/gabbits/resource-provider.yaml b/nova/tests/functional/api/openstack/placement/gabbits/resource-provider.yaml index 1ae19be47bd7..8c2ac663fa5d 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/resource-provider.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-provider.yaml @@ -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 diff --git a/releasenotes/notes/placement-allocations-link-in-get-resource-providers-0b1d26a264eceb4b.yaml b/releasenotes/notes/placement-allocations-link-in-get-resource-providers-0b1d26a264eceb4b.yaml new file mode 100644 index 000000000000..2bdf8abc630f --- /dev/null +++ b/releasenotes/notes/placement-allocations-link-in-get-resource-providers-0b1d26a264eceb4b.yaml @@ -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``.