diff --git a/nova/api/openstack/compute/block_device_mapping_v1.py b/nova/api/openstack/compute/block_device_mapping_v1.py index 0e47231a8011..7fc031a4258d 100644 --- a/nova/api/openstack/compute/block_device_mapping_v1.py +++ b/nova/api/openstack/compute/block_device_mapping_v1.py @@ -18,8 +18,6 @@ from oslo_utils import strutils from webob import exc -from nova.api.openstack.compute.schemas import block_device_mapping_v1 as \ - schema_block_device_mapping from nova.i18n import _ ATTRIBUTE_NAME = "block_device_mapping" @@ -46,7 +44,3 @@ def server_create(server_dict, create_kwargs, body_deprecated_param): create_kwargs['block_device_mapping'] = block_device_mapping # Sets the legacy_bdm flag if we got a legacy block device mapping. create_kwargs['legacy_bdm'] = True - - -def get_server_create_schema(version): - return schema_block_device_mapping.server_create diff --git a/nova/api/openstack/compute/schemas/block_device_mapping.py b/nova/api/openstack/compute/schemas/block_device_mapping.py index 667b95b0669b..080e729f7705 100644 --- a/nova/api/openstack/compute/schemas/block_device_mapping.py +++ b/nova/api/openstack/compute/schemas/block_device_mapping.py @@ -14,7 +14,7 @@ import copy -from nova.api.openstack.compute.schemas import block_device_mapping_v1 +from nova.api.openstack.compute.schemas import servers from nova.api.validation import parameter_types @@ -61,7 +61,7 @@ block_device_mapping_new_item = { } block_device_mapping = copy.deepcopy( - block_device_mapping_v1.legacy_block_device_mapping) + servers.legacy_block_device_mapping) block_device_mapping['properties'].update(block_device_mapping_new_item) server_create = { diff --git a/nova/api/openstack/compute/schemas/block_device_mapping_v1.py b/nova/api/openstack/compute/schemas/block_device_mapping_v1.py deleted file mode 100644 index 91ca3a2ec9e0..000000000000 --- a/nova/api/openstack/compute/schemas/block_device_mapping_v1.py +++ /dev/null @@ -1,49 +0,0 @@ -# Copyright 2014 NEC Corporation. All rights reserved. -# -# 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 - -legacy_block_device_mapping = { - 'type': 'object', - 'properties': { - 'virtual_name': { - 'type': 'string', 'maxLength': 255, - }, - 'volume_id': parameter_types.volume_id, - 'snapshot_id': parameter_types.image_id, - 'volume_size': parameter_types.volume_size, - # Do not allow empty device names and number values and - # containing spaces(defined in nova/block_device.py:from_api()) - 'device_name': { - 'type': 'string', 'minLength': 1, 'maxLength': 255, - 'pattern': '^[a-zA-Z0-9._-r/]*$', - }, - # Defined as boolean in nova/block_device.py:from_api() - 'delete_on_termination': parameter_types.boolean, - 'no_device': {}, - # Defined as mediumtext in column "connection_info" in table - # "block_device_mapping" - 'connection_info': { - 'type': 'string', 'maxLength': 16777215 - }, - }, - 'additionalProperties': False -} - -server_create = { - 'block_device_mapping': { - 'type': 'array', - 'items': legacy_block_device_mapping - } -} diff --git a/nova/api/openstack/compute/schemas/servers.py b/nova/api/openstack/compute/schemas/servers.py index e77a56c8614c..8dc3afda63d8 100644 --- a/nova/api/openstack/compute/schemas/servers.py +++ b/nova/api/openstack/compute/schemas/servers.py @@ -19,6 +19,33 @@ from nova.api.validation import parameter_types from nova.api.validation.parameter_types import multi_params from nova.objects import instance +legacy_block_device_mapping = { + 'type': 'object', + 'properties': { + 'virtual_name': { + 'type': 'string', 'maxLength': 255, + }, + 'volume_id': parameter_types.volume_id, + 'snapshot_id': parameter_types.image_id, + 'volume_size': parameter_types.volume_size, + # Do not allow empty device names and number values and + # containing spaces(defined in nova/block_device.py:from_api()) + 'device_name': { + 'type': 'string', 'minLength': 1, 'maxLength': 255, + 'pattern': '^[a-zA-Z0-9._-r/]*$', + }, + # Defined as boolean in nova/block_device.py:from_api() + 'delete_on_termination': parameter_types.boolean, + 'no_device': {}, + # Defined as mediumtext in column "connection_info" in table + # "block_device_mapping" + 'connection_info': { + 'type': 'string', 'maxLength': 16777215 + }, + }, + 'additionalProperties': False +} + base_create = { 'type': 'object', 'properties': { @@ -55,6 +82,11 @@ base_create = { 'accessIPv6': parameter_types.accessIPv6, 'personality': parameter_types.personality, 'availability_zone': parameter_types.name, + 'block_device_mapping': { + 'type': 'array', + 'items': legacy_block_device_mapping + } + }, 'required': ['name', 'flavorRef'], 'additionalProperties': False, diff --git a/nova/api/openstack/compute/servers.py b/nova/api/openstack/compute/servers.py index ca550ff00bbb..6348c0f736c2 100644 --- a/nova/api/openstack/compute/servers.py +++ b/nova/api/openstack/compute/servers.py @@ -93,7 +93,6 @@ class ServersController(wsgi.Controller): # should be removed in the future. schema_func_list = [ block_device_mapping.get_server_create_schema, - block_device_mapping_v1.get_server_create_schema, config_drive.get_server_create_schema, keypairs.get_server_create_schema, multiple_create.get_server_create_schema,