Merge "Merge server create schema for legacy BDM extension"

This commit is contained in:
Zuul 2018-06-29 08:52:05 +00:00 committed by Gerrit Code Review
commit 451eec1ce1
5 changed files with 34 additions and 58 deletions

View File

@ -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

View File

@ -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 = {

View File

@ -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
}
}

View File

@ -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,

View File

@ -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,