From 9610b6e252c81d6a44af24c68604b02d28143983 Mon Sep 17 00:00:00 2001 From: ghanshyam Date: Tue, 10 Jul 2018 09:28:40 +0000 Subject: [PATCH] Use hard coded values in schema than reference API request schema should be using hard coded values than reference of other nova code. If refference code is changed for any reason and without knowledge of that is being used in schema then, it can change the schema unintentionally which leads to API backward incompatible change. It is always better to use raw and hard coded values in schema to avoid unintentional API changes. This commit removes the db value reference from few schema. Change-Id: Ie1431b7f08172292d77d72fd8d0471a2c1b392b0 --- nova/api/openstack/compute/schemas/flavor_manage.py | 5 +++-- nova/api/openstack/compute/schemas/quota_sets.py | 5 +++-- nova/api/validation/parameter_types.py | 5 +++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/nova/api/openstack/compute/schemas/flavor_manage.py b/nova/api/openstack/compute/schemas/flavor_manage.py index a035ed1bd0c2..08899a21eee1 100644 --- a/nova/api/openstack/compute/schemas/flavor_manage.py +++ b/nova/api/openstack/compute/schemas/flavor_manage.py @@ -15,7 +15,6 @@ import copy from nova.api.validation import parameter_types -from nova.db import api as db create = { 'type': 'object', @@ -42,7 +41,9 @@ create = { 'type': ['number', 'string'], 'pattern': '^[0-9]+(\.[0-9]+)?$', 'minimum': 0, 'exclusiveMinimum': True, - 'maximum': db.SQL_SP_FLOAT_MAX + # maximum's value is limited to db constant's + # SQL_SP_FLOAT_MAX (in nova/db/constants.py) + 'maximum': 3.40282e+38 }, 'os-flavor-access:is_public': parameter_types.boolean, }, diff --git a/nova/api/openstack/compute/schemas/quota_sets.py b/nova/api/openstack/compute/schemas/quota_sets.py index 549617ad7d87..1942488ac251 100644 --- a/nova/api/openstack/compute/schemas/quota_sets.py +++ b/nova/api/openstack/compute/schemas/quota_sets.py @@ -15,14 +15,15 @@ import copy from nova.api.validation import parameter_types -from nova.db import api as db common_quota = { 'type': ['integer', 'string'], 'pattern': '^-?[0-9]+$', # -1 is a flag value for unlimited 'minimum': -1, - 'maximum': db.MAX_INT + # maximum's value is limited to db constant's MAX_INT + # (in nova/db/constants.py) + 'maximum': 0x7FFFFFFF } quota_resources = { diff --git a/nova/api/validation/parameter_types.py b/nova/api/validation/parameter_types.py index 49d84f780100..8c54c1993d58 100644 --- a/nova/api/validation/parameter_types.py +++ b/nova/api/validation/parameter_types.py @@ -21,7 +21,6 @@ import unicodedata import six -from nova.db import api as db from nova.i18n import _ from nova.objects import tag @@ -427,7 +426,9 @@ volume_size = { 'type': ['integer', 'string'], 'pattern': '^[0-9]+$', 'minimum': 1, - 'maximum': db.MAX_INT + # maximum's value is limited to db constant's MAX_INT + # (in nova/db/constants.py) + 'maximum': 0x7FFFFFFF } disk_config = {