api: Add response body schemas for remote consoles

Most of these were already tackled as part of the server actions. We add
a schema for the RDP console, even though it's deprecated, since it
allows us to complete validation.

Change-Id: If13541b47b2b35f5a352049add65ced35f91f216
Signed-off-by: Stephen Finucane <stephenfin@redhat.com>
This commit is contained in:
Stephen Finucane
2024-11-05 11:42:13 +00:00
parent 2b3eb6b015
commit 485ee768d6
2 changed files with 73 additions and 2 deletions

View File

@@ -28,6 +28,7 @@ removed from Nova in the 29.0.0 (Caracal) release.
""" """
@validation.validated
class RemoteConsolesController(wsgi.Controller): class RemoteConsolesController(wsgi.Controller):
def __init__(self): def __init__(self):
super(RemoteConsolesController, self).__init__() super(RemoteConsolesController, self).__init__()
@@ -103,6 +104,7 @@ class RemoteConsolesController(wsgi.Controller):
@wsgi.action('os-getRDPConsole') @wsgi.action('os-getRDPConsole')
@wsgi.removed('29.0.0', _rdp_console_removal_reason) @wsgi.removed('29.0.0', _rdp_console_removal_reason)
@validation.schema(schema.get_rdp_console) @validation.schema(schema.get_rdp_console)
@validation.response_body_schema(schema.get_rdp_console_response)
def get_rdp_console(self, req, id, body): def get_rdp_console(self, req, id, body):
"""RDP console was available only for HyperV driver which has been """RDP console was available only for HyperV driver which has been
removed from Nova in 29.0.0 (Caracal) release. removed from Nova in 29.0.0 (Caracal) release.
@@ -145,6 +147,9 @@ class RemoteConsolesController(wsgi.Controller):
@validation.schema(schema.create_v26, "2.6", "2.7") @validation.schema(schema.create_v26, "2.6", "2.7")
@validation.schema(schema.create_v28, "2.8", "2.98") @validation.schema(schema.create_v28, "2.8", "2.98")
@validation.schema(schema.create_v299, "2.99") @validation.schema(schema.create_v299, "2.99")
@validation.response_body_schema(schema.create_response, "2.6", "2.7")
@validation.response_body_schema(schema.create_response_v28, "2.8", "2.98")
@validation.response_body_schema(schema.create_response_v299, "2.99")
def create(self, req, server_id, body): def create(self, req, server_id, body):
context = req.environ['nova.context'] context = req.environ['nova.context']
instance = common.get_instance(self.compute_api, context, server_id) instance = common.get_instance(self.compute_api, context, server_id)

View File

@@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import copy
get_vnc_console = { get_vnc_console = {
'type': 'object', 'type': 'object',
'properties': { 'properties': {
@@ -177,7 +179,31 @@ get_spice_console_response = {
'properties': { 'properties': {
'type': { 'type': {
'type': 'string', 'type': 'string',
'enum': ['spice-html5'], 'const': 'spice-html5',
'description': '',
},
'url': {
'type': 'string',
'format': 'uri',
'description': '',
},
},
'required': ['type', 'url'],
'additionalProperties': False,
},
},
'additionalProperties': False,
}
get_rdp_console_response = {
'type': 'object',
'properties': {
'console': {
'type': 'object',
'properties': {
'type': {
'type': 'string',
'const': 'rdp',
'description': '', 'description': '',
}, },
'url': { 'url': {
@@ -202,7 +228,7 @@ get_serial_console_response = {
'properties': { 'properties': {
'type': { 'type': {
'type': 'string', 'type': 'string',
'enum': ['serial'], 'const': 'serial',
'description': '', 'description': '',
}, },
'url': { 'url': {
@@ -218,3 +244,43 @@ get_serial_console_response = {
'required': ['console'], 'required': ['console'],
'additionalProperties': False, 'additionalProperties': False,
} }
create_response = {
'type': 'object',
'properties': {
'remote_console': {
'type': 'object',
'properties': {
'protocol': {
'type': 'string',
'enum': ['vnc', 'spice', 'serial'],
},
'type': {
'type': 'string',
'enum': ['novnc', 'xvpvnc', 'spice-html5', 'serial'],
},
'url': {
'type': 'string',
'format': 'uri',
},
},
'required': ['protocol', 'type'],
'additionalProperties': False,
},
},
'required': ['remote_console'],
'additionalProperties': False,
}
create_response_v28 = copy.deepcopy(create_response)
create_response_v28['properties']['remote_console']['properties'][
'protocol'
]['enum'].append('mks')
create_response_v28['properties']['remote_console']['properties'][
'type'
]['enum'].append('webmks')
create_response_v299 = copy.deepcopy(create_response_v28)
create_response_v299['properties']['remote_console']['properties'][
'type'
]['enum'].append('spice-direct')