diff --git a/nova/api/openstack/compute/remote_consoles.py b/nova/api/openstack/compute/remote_consoles.py index 55b4da38fde8..52d8dcc8c94d 100644 --- a/nova/api/openstack/compute/remote_consoles.py +++ b/nova/api/openstack/compute/remote_consoles.py @@ -28,6 +28,7 @@ removed from Nova in the 29.0.0 (Caracal) release. """ +@validation.validated class RemoteConsolesController(wsgi.Controller): def __init__(self): super(RemoteConsolesController, self).__init__() @@ -103,6 +104,7 @@ class RemoteConsolesController(wsgi.Controller): @wsgi.action('os-getRDPConsole') @wsgi.removed('29.0.0', _rdp_console_removal_reason) @validation.schema(schema.get_rdp_console) + @validation.response_body_schema(schema.get_rdp_console_response) def get_rdp_console(self, req, id, body): """RDP console was available only for HyperV driver which has been 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_v28, "2.8", "2.98") @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): context = req.environ['nova.context'] instance = common.get_instance(self.compute_api, context, server_id) diff --git a/nova/api/openstack/compute/schemas/remote_consoles.py b/nova/api/openstack/compute/schemas/remote_consoles.py index 1e5b3a58a071..b563fbf9f5fd 100644 --- a/nova/api/openstack/compute/schemas/remote_consoles.py +++ b/nova/api/openstack/compute/schemas/remote_consoles.py @@ -12,6 +12,8 @@ # License for the specific language governing permissions and limitations # under the License. +import copy + get_vnc_console = { 'type': 'object', 'properties': { @@ -177,7 +179,31 @@ get_spice_console_response = { 'properties': { 'type': { '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': '', }, 'url': { @@ -202,7 +228,7 @@ get_serial_console_response = { 'properties': { 'type': { 'type': 'string', - 'enum': ['serial'], + 'const': 'serial', 'description': '', }, 'url': { @@ -218,3 +244,43 @@ get_serial_console_response = { 'required': ['console'], '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')