Merge "Fix: Schema validation for attachment create API"
This commit is contained in:
commit
7a854c11ed
|
@ -253,7 +253,7 @@ Request
|
|||
|
||||
- project_id: project_id_path
|
||||
- attachment: attachment
|
||||
- instance_uuid: instance_uuid_req
|
||||
- instance_uuid: instance_uuid
|
||||
- connector: connector
|
||||
- volume_uuid: volume_id_attachment
|
||||
- mode: attach_mode
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
Schema for V3 Attachments API.
|
||||
|
||||
"""
|
||||
import copy
|
||||
|
||||
from cinder.api.validation import parameter_types
|
||||
|
||||
|
@ -32,7 +33,7 @@ create = {
|
|||
'connector': {'type': ['object', 'null']},
|
||||
'volume_uuid': parameter_types.uuid,
|
||||
},
|
||||
'required': ['instance_uuid', 'volume_uuid'],
|
||||
'required': ['volume_uuid'],
|
||||
'additionalProperties': False,
|
||||
},
|
||||
},
|
||||
|
@ -56,3 +57,7 @@ update = {
|
|||
'required': ['attachment'],
|
||||
'additionalProperties': False,
|
||||
}
|
||||
|
||||
create_v354 = copy.deepcopy(create)
|
||||
create_v354['properties']['attachment']['properties']['mode'] = (
|
||||
{'type': 'string', 'enum': ['rw', 'ro']})
|
||||
|
|
|
@ -107,7 +107,9 @@ class AttachmentsController(wsgi.Controller):
|
|||
|
||||
@wsgi.Controller.api_version(mv.NEW_ATTACH)
|
||||
@wsgi.response(HTTPStatus.OK)
|
||||
@validation.schema(attachment.create)
|
||||
@validation.schema(attachment.create, mv.NEW_ATTACH,
|
||||
mv.get_prior_version(mv.ATTACHMENT_CREATE_MODE_ARG))
|
||||
@validation.schema(attachment.create_v354, mv.ATTACHMENT_CREATE_MODE_ARG)
|
||||
def create(self, req, body):
|
||||
"""Create an attachment.
|
||||
|
||||
|
@ -130,6 +132,9 @@ class AttachmentsController(wsgi.Controller):
|
|||
referenced below is the UUID of the Instance, for non-nova consumers
|
||||
this can be a server UUID or some other arbitrary unique identifier.
|
||||
|
||||
Starting from microversion 3.54, we can pass the attach mode as
|
||||
argument in the request body.
|
||||
|
||||
Expected format of the input parameter 'body':
|
||||
|
||||
.. code-block:: json
|
||||
|
@ -138,8 +143,9 @@ class AttachmentsController(wsgi.Controller):
|
|||
"attachment":
|
||||
{
|
||||
"volume_uuid": "volume-uuid",
|
||||
"instance_uuid": "nova-server-uuid",
|
||||
"connector": "null|<connector-object>"
|
||||
"instance_uuid": "null|nova-server-uuid",
|
||||
"connector": "null|<connector-object>",
|
||||
"mode": "null|rw|ro"
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -167,7 +173,7 @@ class AttachmentsController(wsgi.Controller):
|
|||
returns: A summary view of the attachment object
|
||||
"""
|
||||
context = req.environ['cinder.context']
|
||||
instance_uuid = body['attachment']['instance_uuid']
|
||||
instance_uuid = body['attachment'].get('instance_uuid')
|
||||
volume_uuid = body['attachment']['volume_uuid']
|
||||
volume_ref = objects.Volume.get_by_id(
|
||||
context,
|
||||
|
|
Loading…
Reference in New Issue