From 22c372cbe07c46007a56dffa41f71ac4d0edaf55 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 13 Nov 2024 17:38:40 +0000 Subject: [PATCH] api: Add response body schemas for server topology API Change-Id: I2cd4086d7b348f6d7f1b93a956b8b25f3a60d07f Signed-off-by: Stephen Finucane --- .../compute/schemas/server_topology.py | 39 +++++++++++++++++++ nova/api/openstack/compute/server_topology.py | 2 + 2 files changed, 41 insertions(+) diff --git a/nova/api/openstack/compute/schemas/server_topology.py b/nova/api/openstack/compute/schemas/server_topology.py index c96eb536a7..091da073af 100644 --- a/nova/api/openstack/compute/schemas/server_topology.py +++ b/nova/api/openstack/compute/schemas/server_topology.py @@ -16,3 +16,42 @@ query_params_v21 = { 'properties': {}, 'additionalProperties': True, } + +index_response = { + 'type': 'object', + 'properties': { + 'nodes': { + 'type': 'array', + 'items': { + 'type': 'object', + 'properties': { + 'cpu_pinning': { + 'type': 'object', + 'patternProperties': { + '^[0-9]+$': {'type': 'integer'}, + }, + 'additionalProperties': False, + }, + 'host_node': {'type': 'integer'}, + 'memory_mb': {'type': 'integer'}, + 'siblings': { + 'type': 'array', + 'items': { + 'type': 'array', + 'items': {'type': 'integer'}, + }, + }, + 'vcpu_set': { + 'type': 'array', + 'items': {'type': 'integer'}, + }, + }, + 'required': ['memory_mb', 'siblings', 'vcpu_set'], + 'additionalProperties': False, + }, + }, + 'pagesize_kb': {'type': ['integer', 'null']}, + }, + 'required': ['nodes', 'pagesize_kb'], + 'additionalProperties': False, +} diff --git a/nova/api/openstack/compute/server_topology.py b/nova/api/openstack/compute/server_topology.py index 48cc328012..7df0dd0241 100644 --- a/nova/api/openstack/compute/server_topology.py +++ b/nova/api/openstack/compute/server_topology.py @@ -19,6 +19,7 @@ from nova.compute import api as compute from nova.policies import server_topology as st_policies +@validation.validated class ServerTopologyController(wsgi.Controller): def __init__(self, *args, **kwargs): @@ -28,6 +29,7 @@ class ServerTopologyController(wsgi.Controller): @wsgi.api_version("2.78") @wsgi.expected_errors(404) @validation.query_schema(schema.query_params_v21) + @validation.response_body_schema(schema.index_response) def index(self, req, server_id): context = req.environ["nova.context"] instance = common.get_instance(self.compute_api, context, server_id,