From 8f6b14bada61f365c7e2f5df61fa07588f04b042 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Wed, 29 Jan 2025 11:37:41 +0000 Subject: [PATCH] api: project/tenant and user IDs are not UUIDs Who knew? Change-Id: Id3366ce2897cfcb1678034c3d24d809d8c24c43a Signed-off-by: Stephen Finucane --- nova/api/openstack/compute/schemas/flavor_access.py | 5 ++++- nova/api/openstack/compute/schemas/servers.py | 4 ++-- nova/api/validation/parameter_types.py | 6 ++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/nova/api/openstack/compute/schemas/flavor_access.py b/nova/api/openstack/compute/schemas/flavor_access.py index 222ce742d1..3356b4ce92 100644 --- a/nova/api/openstack/compute/schemas/flavor_access.py +++ b/nova/api/openstack/compute/schemas/flavor_access.py @@ -14,6 +14,9 @@ import copy +from nova.api.validation import parameter_types + + add_tenant_access = { 'type': 'object', 'properties': { @@ -68,7 +71,7 @@ _common_response = { 'type': 'object', 'properties': { 'flavor_id': {'type': 'string'}, - 'tenant_id': {'type': 'string', 'format': 'uuid'}, + 'tenant_id': parameter_types.project_id, }, 'required': ['flavor_id', 'tenant_id'], 'additionalProperties': True, diff --git a/nova/api/openstack/compute/schemas/servers.py b/nova/api/openstack/compute/schemas/servers.py index 9f98e7b98f..2cd2737694 100644 --- a/nova/api/openstack/compute/schemas/servers.py +++ b/nova/api/openstack/compute/schemas/servers.py @@ -952,9 +952,9 @@ rebuild_response = { 'name': {'type': ['string', 'null']}, 'progress': {'type': ['null', 'number']}, 'status': {'type': 'string'}, - 'tenant_id': {'type': 'string', 'format': 'uuid'}, + 'tenant_id': parameter_types.project_id, 'updated': {'type': 'string', 'format': 'date-time'}, - 'user_id': {'type': 'string'}, + 'user_id': parameter_types.user_id, 'OS-DCF:diskConfig': {'type': 'string'}, }, 'required': [ diff --git a/nova/api/validation/parameter_types.py b/nova/api/validation/parameter_types.py index dd693bf3f2..5ca9a19daf 100644 --- a/nova/api/validation/parameter_types.py +++ b/nova/api/validation/parameter_types.py @@ -347,6 +347,12 @@ project_id = { 'pattern': '^[a-zA-Z0-9-]*$' } +user_id = { + 'type': 'string', + 'pattern': '^[a-zA-Z0-9-]*$', + 'minLength': 1, + 'maxLength': 255, +} server_id = { 'type': 'string', 'format': 'uuid'