Move tag schema to parameter_types.py
tag schema is being used in multiple place like server tags and device tags and may be in future it will be used in many other schema also. So this patch moves tag schema from server_tags.py to common place (parameter_types.py). Change-Id: I9385c436c48c881dc5fab475ed35eb0e10010637
This commit is contained in:
parent
22498982d1
commit
af673dbb0b
|
@ -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)
|
||||
|
|
|
@ -10,11 +10,6 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
tag = {
|
||||
"type": "string",
|
||||
"pattern": "^[^,/]*$"
|
||||
}
|
||||
|
||||
update_all = {
|
||||
"definitions": {
|
||||
"tag": {
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -395,3 +395,8 @@ personality = {
|
|||
'additionalProperties': False,
|
||||
}
|
||||
}
|
||||
|
||||
tag = {
|
||||
"type": "string",
|
||||
"pattern": "^[^,/]*$"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue