diff --git a/nova/api/openstack/placement/handlers/resource_provider.py b/nova/api/openstack/placement/handlers/resource_provider.py index 271c8f57a..d8a895e79 100644 --- a/nova/api/openstack/placement/handlers/resource_provider.py +++ b/nova/api/openstack/placement/handlers/resource_provider.py @@ -28,7 +28,8 @@ POST_RESOURCE_PROVIDER_SCHEMA = { "type": "object", "properties": { "name": { - "type": "string" + "type": "string", + "maxLength": 200 }, "uuid": { "type": "string", 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 50d9c40de..d564a9905 100644 --- a/nova/tests/functional/api/openstack/placement/gabbits/resource-provider.yaml +++ b/nova/tests/functional/api/openstack/placement/gabbits/resource-provider.yaml @@ -254,3 +254,23 @@ tests: status: 400 response_strings: - "Failed validating 'format'" + +- name: try to create resource provider with name exceed max characters + POST: /resource_providers + request_headers: + content-type: application/json + data: + name: &name_exceeds_max_length_check This is a long text of 201 charactersssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss + status: 400 + response_strings: + - "Failed validating 'maxLength'" + +- name: try to update resource provider with name exceed max characters + PUT: /resource_providers/$ENVIRON['RP_UUID'] + request_headers: + content-type: application/json + data: + name: *name_exceeds_max_length_check + status: 400 + response_strings: + - "Failed validating 'maxLength'"