'properties': update_quota_set, 'additionalProperties': False, }, }, 'required': ['quota_set'], 'additionalProperties': False, } update_v236 = copy.deepcopy(update) update_v236['properties']['quota_set']['properties'] = update_quota_set_v236 # 2.57 builds on 2.36 and removes injected_file* quotas. update_quota_set_v257 = copy.deepcopy(update_quota_set_v236) del update_quota_set_v257['injected_files'] del update_quota_set_v257['injected_file_content_bytes'] del update_quota_set_v257['injected_file_path_bytes'] update_v257 = copy.deepcopy(update_v236) update_v257['properties']['quota_set']['properties'] = update_quota_set_v257 query_schema = { 'type': 'object', 'properties': { 'user_id': parameter_types.multi_params({'type': 'string'}) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In the future, we may block the additional parameters # by bump in Microversion. 'additionalProperties': True }
# NOTE(takashin): The following sort keys are defined for backward # compatibility. If they are changed, the API microversion should be bumped. VALID_SORT_KEYS = [ 'created_at', 'description', 'disabled', 'ephemeral_gb', 'flavorid', 'id', 'is_public', 'memory_mb', 'name', 'root_gb', 'rxtx_factor', 'swap', 'updated_at', 'vcpu_weight', 'vcpus' ] VALID_SORT_DIR = ['asc', 'desc'] index_query = { 'type': 'object', 'properties': { 'limit': parameter_types.multi_params(parameter_types.non_negative_integer), 'marker': parameter_types.multi_params({'type': 'string'}), 'is_public': parameter_types.multi_params({'type': 'string'}), 'minRam': parameter_types.multi_params({'type': 'string'}), 'minDisk': parameter_types.multi_params({'type': 'string'}), 'sort_key': parameter_types.multi_params({ 'type': 'string', 'enum': VALID_SORT_KEYS }), 'sort_dir': parameter_types.multi_params({
# not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from nova.api.validation import parameter_types index_query = { 'type': 'object', 'properties': { 'limit': parameter_types.multi_params(parameter_types.non_negative_integer), 'marker': parameter_types.multi_params({'type': 'string'}), 'is_public': parameter_types.multi_params({'type': 'string'}), 'minRam': parameter_types.multi_params({'type': 'string'}), 'minDisk': parameter_types.multi_params({'type': 'string'}), 'sort_key': parameter_types.multi_params({'type': 'string'}), 'sort_dir': parameter_types.multi_params({'type': 'string'}) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In the future, we may block the additional parameters # by bump in Microversion. 'additionalProperties': True }
} trigger_crash_dump = { 'type': 'object', 'properties': { 'trigger_crash_dump': { 'type': 'null' } }, 'required': ['trigger_crash_dump'], 'additionalProperties': False } # NOTE: We don't check actual values of queries on params # which are defined as the following common_param. common_param = multi_params({'type': 'string'}) common_regex_param = multi_params({'type': 'string', 'format': 'regex'}) JOINED_TABLE_QUERY_PARAMS_SERVERS = { 'block_device_mapping': common_param, 'services': common_param, 'metadata': common_param, 'system_metadata': common_param, 'info_cache': common_param, 'security_groups': common_param, 'pci_devices': common_param } query_params_v21 = { 'type': 'object', 'properties': {
# The alias of name. It should be removed in the future # with microversion bump. 'display_name': parameter_types.common_query_regex_param, 'description': parameter_types.common_query_regex_param, # The alias of description. It should be removed in the # future with microversion bump. 'display_description': parameter_types.common_query_regex_param, 'locked_by': parameter_types.common_query_regex_param, 'uuid': parameter_types.common_query_param, 'root_device_name': parameter_types.common_query_regex_param, 'config_drive': parameter_types.common_query_regex_param, 'access_ip_v4': parameter_types.common_query_regex_param, 'access_ip_v6': parameter_types.common_query_regex_param, 'auto_disk_config': parameter_types.common_query_regex_param, 'progress': parameter_types.common_query_regex_param, 'sort_key': multi_params(VALID_SORT_KEYS), 'sort_dir': parameter_types.common_query_param, 'all_tenants': parameter_types.common_query_param, 'soft_deleted': parameter_types.common_query_param, 'deleted': parameter_types.common_query_param, 'status': parameter_types.common_query_param, 'changes-since': multi_params({ 'type': 'string', 'format': 'date-time' }), # NOTE(alex_xu): The ip and ip6 are implemented in the python. 'ip': parameter_types.common_query_regex_param, 'ip6': parameter_types.common_query_regex_param, 'created_at': parameter_types.common_query_regex_param, }, # For backward-compatible additionalProperties is set to be True here.
'enum': ['anti-affinity', 'affinity']}], 'uniqueItems': True, 'additionalItems': False, } }, 'required': ['name', 'policies'], 'additionalProperties': False, } }, 'required': ['server_group'], 'additionalProperties': False, } create_v215 = copy.deepcopy(create) policies = create_v215['properties']['server_group']['properties']['policies'] policies['items'][0]['enum'].extend(['soft-anti-affinity', 'soft-affinity']) server_groups_query_param = { 'type': 'object', 'properties': { 'all_projects': parameter_types.multi_params({'type': 'string'}), 'limit': parameter_types.multi_params( parameter_types.non_negative_integer), 'offset': parameter_types.multi_params( parameter_types.non_negative_integer), }, # For backward compatible changes 'additionalProperties': True }
from nova.api.openstack import api_version_request as api_version from nova.api import validation from nova.api.validation import parameter_types from nova.api.validation import validators from nova import exception from nova import test from nova.tests.unit.api.openstack import fakes query_schema = { 'type': 'object', 'properties': { 'foo': parameter_types.single_param({ 'type': 'string', 'format': 'uuid' }), 'foos': parameter_types.multi_params({'type': 'string'}) }, 'patternProperties': { "^_": parameter_types.multi_params({'type': 'string'}) }, 'additionalProperties': True } class FakeQueryParametersController(object): @validation.query_schema(query_schema, '2.3') def get(self, req): return list(set(req.GET.keys())) class RegexFormatFakeController(object):
# not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from nova.api.validation import parameter_types index_query = { 'type': 'object', 'properties': { 'limit': parameter_types.multi_params( parameter_types.non_negative_integer), 'marker': parameter_types.multi_params({'type': 'string'}), 'is_public': parameter_types.multi_params({'type': 'string'}), 'minRam': parameter_types.multi_params({'type': 'string'}), 'minDisk': parameter_types.multi_params({'type': 'string'}), 'sort_key': parameter_types.multi_params({'type': 'string'}), 'sort_dir': parameter_types.multi_params({'type': 'string'}) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In the future, we may block the additional parameters # by bump in Microversion. 'additionalProperties': True }
# http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import copy from nova.api.validation import parameter_types index_query = { 'type': 'object', 'properties': { 'start': parameter_types.multi_params({'type': 'string'}), 'end': parameter_types.multi_params({'type': 'string'}), 'detailed': parameter_types.multi_params({'type': 'string'}) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In the future, we may block the additional parameters # by bump in Microversion. 'additionalProperties': True } show_query = { 'type': 'object', 'properties': { 'start': parameter_types.multi_params({'type': 'string'}), 'end': parameter_types.multi_params({'type': 'string'})
True, 'additionalItems': False, } }, 'required': ['name', 'policies'], 'additionalProperties': False, } }, 'required': ['server_group'], 'additionalProperties': False, } create_v215 = copy.deepcopy(create) policies = create_v215['properties']['server_group']['properties']['policies'] policies['items'][0]['enum'].extend(['soft-anti-affinity', 'soft-affinity']) server_groups_query_param = { 'type': 'object', 'properties': { 'all_projects': parameter_types.multi_params({'type': 'string'}), 'limit': parameter_types.multi_params(parameter_types.non_negative_integer), 'offset': parameter_types.multi_params(parameter_types.non_negative_integer), }, # For backward compatible changes 'additionalProperties': True }
# The alias of name. It should be removed in the future # with microversion bump. 'display_name': parameter_types.common_query_regex_param, 'description': parameter_types.common_query_regex_param, # The alias of description. It should be removed in the # future with microversion bump. 'display_description': parameter_types.common_query_regex_param, 'locked_by': parameter_types.common_query_regex_param, 'uuid': parameter_types.common_query_param, 'root_device_name': parameter_types.common_query_regex_param, 'config_drive': parameter_types.common_query_regex_param, 'access_ip_v4': parameter_types.common_query_regex_param, 'access_ip_v6': parameter_types.common_query_regex_param, 'auto_disk_config': parameter_types.common_query_regex_param, 'progress': parameter_types.common_query_regex_param, 'sort_key': multi_params(VALID_SORT_KEYS), 'sort_dir': parameter_types.common_query_param, 'all_tenants': parameter_types.common_query_param, 'deleted': parameter_types.common_query_param, 'status': parameter_types.common_query_param, 'changes-since': multi_params({'type': 'string', 'format': 'date-time'}), # NOTE(alex_xu): The ip and ip6 are implemented in the python. 'ip': parameter_types.common_query_regex_param, 'ip6': parameter_types.common_query_regex_param, 'created_at': parameter_types.common_query_regex_param, }, # For backward-compatible additionalProperties is set to be True here. # And we will either strip the extra params out or raise HTTP 400 # according to the params' value in the later process. 'additionalProperties': True,
# # Licensed under the Apache License, Version 2.0 (the "License"); you may # not use this file except in compliance with the License. You may obtain # a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. from nova.api.validation import parameter_types index_query = { 'type': 'object', 'properties': { 'limit': parameter_types.multi_params( parameter_types.non_negative_integer), 'offset': parameter_types.multi_params( parameter_types.non_negative_integer), 'all_tenants': parameter_types.multi_params({'type': 'string'}) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. This API is deprecated in microversion 2.36 so we # do not to update the additionalProperties to False. 'additionalProperties': True }
'delete_on_termination': parameter_types.boolean, 'serverId': parameter_types.server_id, 'id': parameter_types.attachment_id }, 'required': ['volumeId'], 'additionalProperties': False, }, }, 'required': ['volumeAttachment'], 'additionalProperties': False, } index_query = { 'type': 'object', 'properties': { 'limit': parameter_types.multi_params( parameter_types.non_negative_integer), 'offset': parameter_types.multi_params( parameter_types.non_negative_integer) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In microversion 2.75, we have blocked the additional # parameters. 'additionalProperties': True } detail_query = index_query index_query_275 = copy.deepcopy(index_query) index_query_275['additionalProperties'] = False
'type': 'string', 'enum': ['enable', 'disable', 'Enable', 'Disable', 'ENABLE', 'DISABLE'], }, 'maintenance_mode': { 'type': 'string', 'enum': ['enable', 'disable', 'Enable', 'Disable', 'ENABLE', 'DISABLE'], }, 'anyOf': [ {'required': ['status']}, {'required': ['maintenance_mode']} ], }, 'additionalProperties': False } index_query = { 'type': 'object', 'properties': { 'zone': parameter_types.multi_params({'type': 'string'}) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In the future, we may block the additional parameters # by bump in Microversion. 'additionalProperties': True }
'additionalProperties': False, }, }, 'required': ['volumeAttachment'], 'additionalProperties': False, } create_volume_attachment_v249 = copy.deepcopy(create_volume_attachment) create_volume_attachment_v249['properties']['volumeAttachment']['properties'][ 'tag'] = parameter_types.tag update_volume_attachment = copy.deepcopy(create_volume_attachment) del update_volume_attachment['properties']['volumeAttachment']['properties'][ 'device'] index_query = { 'type': 'object', 'properties': { 'limit': parameter_types.multi_params(parameter_types.non_negative_integer), 'offset': parameter_types.multi_params(parameter_types.non_negative_integer) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In the future, we may block the additional parameters # by bump in Microversion. 'additionalProperties': True } detail_query = index_query
'new_file': { 'type': 'string', 'minLength': 1, }, 'id': { 'type': 'string', 'minLength': 1, }, }, 'required': ['snapshot_id', 'type', 'new_file'], 'additionalProperties': False, }, }, 'required': ['volume_id', 'create_info'], 'additionalProperties': False, } }, 'required': ['snapshot'], 'additionalProperties': False, } delete_query = { 'type': 'object', 'properties': { 'delete_info': parameter_types.multi_params({'type': 'string'}) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In the future, we may block the additional parameters # by bump in Microversion. 'additionalProperties': True }
} trigger_crash_dump = { 'type': 'object', 'properties': { 'trigger_crash_dump': { 'type': 'null' } }, 'required': ['trigger_crash_dump'], 'additionalProperties': False } # NOTE: We don't check actual values of queries on params # which are defined as the following common_param. common_param = multi_params({'type': 'string'}) common_regex_param = multi_params({'type': 'string', 'format': 'regex'}) JOINED_TABLE_QUERY_PARAMS_SERVERS = { 'block_device_mapping': common_param, 'services': common_param, 'metadata': common_param, 'system_metadata': common_param, 'info_cache': common_param, 'security_groups': common_param, 'pci_devices': common_param } # These fields are valid values for sort_keys before we start # using schema validation, but are considered to be bad values # and disabled to use. In order to avoid backward incompatibility,
# # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. import copy from nova.api.validation import parameter_types index_query = { 'type': 'object', 'properties': { 'start': parameter_types.multi_params({'type': 'string'}), 'end': parameter_types.multi_params({'type': 'string'}), 'detailed': parameter_types.multi_params({'type': 'string'}) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In the future, we may block the additional parameters # by bump in Microversion. 'additionalProperties': True } show_query = { 'type': 'object', 'properties': { 'start': parameter_types.multi_params({'type': 'string'}), 'end': parameter_types.multi_params({'type': 'string'})
from nova.api.openstack import api_version_request as api_version from nova.api import validation from nova.api.validation import parameter_types from nova.api.validation import validators from nova import exception from nova import test from nova.tests.unit.api.openstack import fakes query_schema = { 'type': 'object', 'properties': { 'foo': parameter_types.single_param({'type': 'string', 'format': 'uuid'}), 'foos': parameter_types.multi_params({'type': 'string'}) }, 'patternProperties': { "^_": parameter_types.multi_params({'type': 'string'})}, 'additionalProperties': True } class FakeQueryParametersController(object): @validation.query_schema(query_schema, '2.3') def get(self, req): return list(set(req.GET.keys())) class RegexFormatFakeController(object):
'string', 'enum': ['enable', 'disable', 'Enable', 'Disable', 'ENABLE', 'DISABLE'], }, 'maintenance_mode': { 'type': 'string', 'enum': ['enable', 'disable', 'Enable', 'Disable', 'ENABLE', 'DISABLE'], }, 'anyOf': [{ 'required': ['status'] }, { 'required': ['maintenance_mode'] }], }, 'additionalProperties': False } index_query = { 'type': 'object', 'properties': { 'zone': parameter_types.multi_params({'type': 'string'}) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In the future, we may block the additional parameters # by bump in Microversion. 'additionalProperties': True }
'additionalProperties': False, }, }, 'required': ['volumeAttachment'], 'additionalProperties': False, } create_volume_attachment_v249 = copy.deepcopy(create_volume_attachment) create_volume_attachment_v249['properties']['volumeAttachment'][ 'properties']['tag'] = parameter_types.tag update_volume_attachment = copy.deepcopy(create_volume_attachment) del update_volume_attachment['properties']['volumeAttachment'][ 'properties']['device'] index_query = { 'type': 'object', 'properties': { 'limit': parameter_types.multi_params( parameter_types.non_negative_integer), 'offset': parameter_types.multi_params( parameter_types.non_negative_integer) }, # NOTE(gmann): This is kept True to keep backward compatibility. # As of now Schema validation stripped out the additional parameters and # does not raise 400. In the future, we may block the additional parameters # by bump in Microversion. 'additionalProperties': True } detail_query = index_query