diff --git a/nova/api/openstack/compute/schemas/block_device_mapping.py b/nova/api/openstack/compute/schemas/block_device_mapping.py index 81097f936f60..1d9dfbc1d81f 100644 --- a/nova/api/openstack/compute/schemas/block_device_mapping.py +++ b/nova/api/openstack/compute/schemas/block_device_mapping.py @@ -15,7 +15,6 @@ import copy from nova.api.openstack.compute.schemas import block_device_mapping_v1 -from nova.api.openstack.compute.schemas import server_tags from nova.api.validation import parameter_types from nova.objects import fields @@ -74,7 +73,7 @@ server_create = { } block_device_mapping_v232_new_item = { - 'tag': server_tags.tag + 'tag': parameter_types.tag } block_device_mapping_v232 = copy.deepcopy(block_device_mapping) diff --git a/nova/api/openstack/compute/schemas/server_tags.py b/nova/api/openstack/compute/schemas/server_tags.py index a236a30547a8..c60484d68785 100644 --- a/nova/api/openstack/compute/schemas/server_tags.py +++ b/nova/api/openstack/compute/schemas/server_tags.py @@ -10,11 +10,6 @@ # License for the specific language governing permissions and limitations # under the License. -tag = { - "type": "string", - "pattern": "^[^,/]*$" -} - update_all = { "definitions": { "tag": { diff --git a/nova/api/openstack/compute/schemas/servers.py b/nova/api/openstack/compute/schemas/servers.py index 585144b55980..7a9d13ef8f21 100644 --- a/nova/api/openstack/compute/schemas/servers.py +++ b/nova/api/openstack/compute/schemas/servers.py @@ -14,7 +14,6 @@ import copy -from nova.api.openstack.compute.schemas import server_tags from nova.api.validation import parameter_types @@ -76,7 +75,7 @@ base_create_v219['properties']['server'][ base_create_v232 = copy.deepcopy(base_create_v219) base_create_v232['properties']['server'][ 'properties']['networks']['items'][ - 'properties']['tag'] = server_tags.tag + 'properties']['tag'] = parameter_types.tag # 2.37 builds on 2.32 and makes the following changes: diff --git a/nova/api/openstack/compute/server_tags.py b/nova/api/openstack/compute/server_tags.py index a229e7b26c43..de0bb844d466 100644 --- a/nova/api/openstack/compute/server_tags.py +++ b/nova/api/openstack/compute/server_tags.py @@ -19,6 +19,7 @@ from nova.api.openstack.compute.views import server_tags from nova.api.openstack import extensions from nova.api.openstack import wsgi from nova.api import validation +from nova.api.validation import parameter_types from nova import compute from nova.compute import vm_states from nova import exception @@ -91,7 +92,7 @@ class ServerTagsController(wsgi.Controller): self._check_instance_in_valid_state(context, server_id, 'update tag') try: - jsonschema.validate(id, schema.tag) + jsonschema.validate(id, parameter_types.tag) except jsonschema.ValidationError as e: msg = (_("Tag '%(tag)s' is invalid. It must be a string without " "characters '/' and ','. Validation error message: " @@ -141,7 +142,7 @@ class ServerTagsController(wsgi.Controller): invalid_tags = [] for tag in body['tags']: try: - jsonschema.validate(tag, schema.tag) + jsonschema.validate(tag, parameter_types.tag) except jsonschema.ValidationError: invalid_tags.append(tag) if invalid_tags: diff --git a/nova/api/validation/parameter_types.py b/nova/api/validation/parameter_types.py index c3e548709a91..352b956c08f4 100644 --- a/nova/api/validation/parameter_types.py +++ b/nova/api/validation/parameter_types.py @@ -395,3 +395,8 @@ personality = { 'additionalProperties': False, } } + +tag = { + "type": "string", + "pattern": "^[^,/]*$" +}