api: Add response body schemas for server external events API
We also fix some issues in the api-ref, since it'll be another while before we can replace that. Change-Id: If661e3af796475637c0e76b3dfbfd5b7a7f38c24 Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
@@ -2089,11 +2089,11 @@ code:
|
||||
description: |
|
||||
The HTTP response code for the event. The following codes are currently used:
|
||||
|
||||
* 200 - successfully submitted event
|
||||
* 400 - the request is missing required parameter
|
||||
* 404 - the instance specified by ``server_uuid`` was not found
|
||||
* 422 - no host was found for the server specified by ``server_uuid``,
|
||||
so there is no route to this server.
|
||||
* 200 - successfully submitted event
|
||||
* 400 - the request is missing required parameter
|
||||
* 404 - the instance specified by ``server_uuid`` was not found
|
||||
* 422 - no host was found for the server specified by ``server_uuid``,
|
||||
so there is no route to this server.
|
||||
in: body
|
||||
required: true
|
||||
type: string
|
||||
@@ -2737,6 +2737,7 @@ event_name:
|
||||
- ``volume-extended`` (since microversion ``2.51``)
|
||||
- ``power-update`` (since microversion ``2.76``)
|
||||
- ``accelerator-request-bound`` (since microversion ``2.82``)
|
||||
- ``volume-reimaged`` (since microversion ``2.93``)
|
||||
|
||||
in: body
|
||||
required: true
|
||||
|
@@ -19,31 +19,33 @@ create = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'events': {
|
||||
'type': 'array', 'minItems': 1,
|
||||
'type': 'array',
|
||||
'minItems': 1,
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'server_uuid': {
|
||||
'type': 'string', 'format': 'uuid'
|
||||
},
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'enum': [
|
||||
'network-changed',
|
||||
'network-vif-plugged',
|
||||
'network-vif-unplugged',
|
||||
'network-vif-deleted'
|
||||
'network-vif-deleted',
|
||||
],
|
||||
},
|
||||
'server_uuid': {
|
||||
'type': 'string', 'format': 'uuid'
|
||||
},
|
||||
'status': {
|
||||
'type': 'string',
|
||||
'enum': external_event_obj.EVENT_STATUSES,
|
||||
'type': 'string',
|
||||
'enum': external_event_obj.EVENT_STATUSES,
|
||||
},
|
||||
'tag': {
|
||||
'type': 'string', 'maxLength': 255,
|
||||
'type': 'string',
|
||||
'maxLength': 255,
|
||||
},
|
||||
},
|
||||
'required': ['server_uuid', 'name'],
|
||||
'required': ['name', 'server_uuid'],
|
||||
'additionalProperties': False,
|
||||
},
|
||||
},
|
||||
@@ -67,3 +69,74 @@ name['enum'].append('accelerator-request-bound')
|
||||
create_v293 = copy.deepcopy(create_v282)
|
||||
name = create_v293['properties']['events']['items']['properties']['name']
|
||||
name['enum'].append('volume-reimaged')
|
||||
|
||||
create_response = {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'events': {
|
||||
'type': 'array',
|
||||
'items': {
|
||||
'type': 'object',
|
||||
'properties': {
|
||||
'code': {
|
||||
'type': 'integer',
|
||||
'enum': [200, 400, 404, 422],
|
||||
},
|
||||
'name': {
|
||||
'type': 'string',
|
||||
'enum': [
|
||||
'network-changed',
|
||||
'network-vif-plugged',
|
||||
'network-vif-unplugged',
|
||||
'network-vif-deleted',
|
||||
],
|
||||
},
|
||||
'server_uuid': {'type': 'string', 'format': 'uuid'},
|
||||
'status': {
|
||||
'type': 'string',
|
||||
'enum': external_event_obj.EVENT_STATUSES,
|
||||
},
|
||||
'tag': {
|
||||
'type': 'string',
|
||||
'maxLength': 255,
|
||||
},
|
||||
},
|
||||
'required': [
|
||||
'code',
|
||||
'name',
|
||||
'server_uuid',
|
||||
'status',
|
||||
# tag is not required in responses, although omitting it
|
||||
# from requests will result in a failed event response
|
||||
],
|
||||
'additionalProperties': False,
|
||||
},
|
||||
},
|
||||
},
|
||||
'required': ['events'],
|
||||
'additionalProperties': False,
|
||||
}
|
||||
|
||||
create_response_v251 = copy.deepcopy(create_response)
|
||||
name = create_response_v251['properties']['events']['items']['properties'][
|
||||
'name'
|
||||
]
|
||||
name['enum'].append('volume-extended')
|
||||
|
||||
create_response_v276 = copy.deepcopy(create_response_v251)
|
||||
name = create_response_v276['properties']['events']['items']['properties'][
|
||||
'name'
|
||||
]
|
||||
name['enum'].append('power-update')
|
||||
|
||||
create_response_v282 = copy.deepcopy(create_response_v276)
|
||||
name = create_response_v282['properties']['events']['items']['properties'][
|
||||
'name'
|
||||
]
|
||||
name['enum'].append('accelerator-request-bound')
|
||||
|
||||
create_response_v293 = copy.deepcopy(create_response_v282)
|
||||
name = create_response_v293['properties']['events']['items']['properties'][
|
||||
'name'
|
||||
]
|
||||
name['enum'].append('volume-reimaged')
|
||||
|
@@ -14,7 +14,7 @@
|
||||
|
||||
from oslo_log import log as logging
|
||||
|
||||
from nova.api.openstack.compute.schemas import server_external_events
|
||||
from nova.api.openstack.compute.schemas import server_external_events as schema
|
||||
from nova.api.openstack import wsgi
|
||||
from nova.api import validation
|
||||
from nova.compute import api as compute
|
||||
@@ -30,6 +30,7 @@ TAG_REQUIRED = ('volume-extended', 'power-update',
|
||||
'accelerator-request-bound')
|
||||
|
||||
|
||||
@validation.validated
|
||||
class ServerExternalEventsController(wsgi.Controller):
|
||||
|
||||
def __init__(self):
|
||||
@@ -66,11 +67,16 @@ class ServerExternalEventsController(wsgi.Controller):
|
||||
|
||||
@wsgi.expected_errors(403)
|
||||
@wsgi.response(200)
|
||||
@validation.schema(server_external_events.create, '2.0', '2.50')
|
||||
@validation.schema(server_external_events.create_v251, '2.51', '2.75')
|
||||
@validation.schema(server_external_events.create_v276, '2.76', '2.81')
|
||||
@validation.schema(server_external_events.create_v282, '2.82', '2.92')
|
||||
@validation.schema(server_external_events.create_v293, '2.93')
|
||||
@validation.schema(schema.create, '2.0', '2.50')
|
||||
@validation.schema(schema.create_v251, '2.51', '2.75')
|
||||
@validation.schema(schema.create_v276, '2.76', '2.81')
|
||||
@validation.schema(schema.create_v282, '2.82', '2.92')
|
||||
@validation.schema(schema.create_v293, '2.93')
|
||||
@validation.response_body_schema(schema.create_response, '2.0', '2.50')
|
||||
@validation.response_body_schema(schema.create_response_v251, '2.51', '2.75') # noqa: E501
|
||||
@validation.response_body_schema(schema.create_response_v276, '2.76', '2.81') # noqa: E501
|
||||
@validation.response_body_schema(schema.create_response_v282, '2.82', '2.92') # noqa: E501
|
||||
@validation.response_body_schema(schema.create_response_v293, '2.93')
|
||||
def create(self, req, body):
|
||||
"""Creates a new instance event."""
|
||||
context = req.environ['nova.context']
|
||||
|
Reference in New Issue
Block a user