Skip to content

Commit

Permalink
Remove 'os-consoles' API
Browse files Browse the repository at this point in the history
This exposes the 'nova-console' service via a REST API, a service that
can only be used with XVP VNC consoles, which in turn require the
'nova-xvpvncproxy' service. We we would like to remove the
'nova-console' and 'nova-xvpvncproxy' services, so start here.

Part of blueprint remove-xvpvncproxy

Change-Id: I2ee3b8c44e5d85e9b3c811ed3c5e6cddc563054f
Signed-off-by: Stephen Finucane <[email protected]>
  • Loading branch information
stephenfin committed Nov 22, 2019
1 parent 991d675 commit 3062a11
Show file tree
Hide file tree
Showing 14 changed files with 108 additions and 561 deletions.
2 changes: 1 addition & 1 deletion api-ref/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ the `API guide <https://docs.openstack.org/api-guide/compute/index.html>`_.
.. include:: os-aggregates.inc
.. include:: os-assisted-volume-snapshots.inc
.. include:: os-availability-zone.inc
.. include:: os-consoles.inc
.. include:: os-hypervisors.inc
.. include:: os-instance-usage-audit-log.inc
.. include:: os-migrations.inc
Expand Down Expand Up @@ -89,4 +88,5 @@ Compute API in the past, but no longer exist.
.. include:: os-floating-ips-bulk.inc
.. include:: os-floating-ip-dns.inc
.. include:: os-cells.inc
.. include:: os-consoles.inc
.. include:: os-security-group-default-rules.inc
69 changes: 15 additions & 54 deletions api-ref/source/os-consoles.inc
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
.. -*- rst -*-
===============================================================
Server consoles (servers, os-consoles, os-console-auth-tokens)
===============================================================
==================================================
XenServer VNC Proxy (XVP) consoles (os-consoles)
==================================================

Manages server consoles.
Manages server XVP consoles.

.. note:: This is only used in Xenserver VNC Proxy.
.. warning::

These APIs are only applicable when using the XenServer virt driver.
They were removed in the 21.0.0 (Ussuri) release.

Lists Consoles
==============
Expand All @@ -17,7 +20,7 @@ Lists all consoles for a server.

Normal response codes: 200

Error response codes: unauthorized(401), forbidden(403)
Error response codes: unauthorized(401), forbidden(403), gone(410)

Request
-------
Expand Down Expand Up @@ -53,7 +56,8 @@ Creates a console for a server.

Normal response codes: 200

Error response codes: unauthorized(401), forbidden(403), itemNotFound(404)
Error response codes: unauthorized(401), forbidden(403), itemNotFound(404),
gone(410)

Request
-------
Expand All @@ -77,7 +81,8 @@ Shows console details for a server.

Normal response codes: 200

Error response codes: unauthorized(401), forbidden(403), itemNotFound(404)
Error response codes: unauthorized(401), forbidden(403), itemNotFound(404),
gone(410)

Request
-------
Expand Down Expand Up @@ -117,7 +122,8 @@ Deletes a console for a server.

Normal response codes: 202

Error response codes: unauthorized(401), forbidden(403), itemNotFound(404)
Error response codes: unauthorized(401), forbidden(403), itemNotFound(404),
gone(410)

Request
-------
Expand All @@ -132,48 +138,3 @@ Response
--------

If successful, this method does not return a response body.


Show Console Connection Information
===================================

.. rest_method:: GET /os-console-auth-tokens/{console_token}

Given the console authentication token for a server,
shows the related connection information.

This method used to be available only for the ``rdp-html5`` console type before
microversion 2.31. Starting from microversion 2.31 it's available for all
console types.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403), itemNotFound(404)

Request
-------

.. rest_parameters:: parameters.yaml


- console_token: console_token

|
Response
--------

.. rest_parameters:: parameters.yaml

- console: console
- instance_uuid: instance_id_body
- host: console_host
- port: port_number
- internal_access_path: internal_access_path

|
**Example Show Console Authentication Token**

.. literalinclude:: ../../doc/api_samples/os-console-auth-tokens/get-console-connect-info-get-resp.json
:language: javascript
8 changes: 4 additions & 4 deletions api-ref/source/servers-action-remote-consoles.inc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Gets an `RDP <https://technet.microsoft.com/en-us/windowsserver/ee236407>`__ con
.. warning::

This action is deprecated in microversion 2.5 and superseded
by the API `Server Remote Consoles`_ in microversion 2.6.
by the API `Server Consoles`_ in microversion 2.6.
The new API offers a unified API for different console types.

The only supported connect type is ``rdp-html5``. The ``type`` parameter should
Expand Down Expand Up @@ -64,7 +64,7 @@ Gets a serial console for a server.
.. warning::

This action is deprecated in microversion 2.5 and superseded
by the API `Server Remote Consoles`_ in microversion 2.6.
by the API `Server Consoles`_ in microversion 2.6.
The new API offers a unified API for different console types.

Specify the ``os-getSerialConsole`` action in the request body.
Expand Down Expand Up @@ -117,7 +117,7 @@ Gets a SPICE console for a server.
.. warning::

This action is deprecated in microversion 2.5 and superseded
by the API `Server Remote Consoles`_ in microversion 2.6.
by the API `Server Consoles`_ in microversion 2.6.
The new API offers a unified API for different console types.

Specify the ``os-getSPICEConsole`` action in the request body.
Expand Down Expand Up @@ -170,7 +170,7 @@ Gets a VNC console for a server.
.. warning::

This action is deprecated in microversion 2.5 and superseded
by the API `Server Remote Consoles`_ in microversion 2.6.
by the API `Server Consoles`_ in microversion 2.6.
The new API offers a unified API for different console types.

Specify the ``os-getVNCConsole`` action in the request body.
Expand Down
54 changes: 48 additions & 6 deletions api-ref/source/servers-remote-consoles.inc
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
.. -*- rst -*-
======================
Server Remote Consoles
======================
=================
Server Consoles
=================

Create server remote console.
Manage server consoles.

Create Remote Console
=====================
Create Console
==============

.. rest_method:: POST /servers/{server_id}/remote-consoles

Expand Down Expand Up @@ -56,3 +56,45 @@ Response

.. literalinclude:: ../../doc/api_samples/os-remote-consoles/v2.6/create-vnc-console-resp.json
:language: javascript


Show Console Connection Information
===================================

.. rest_method:: GET /os-console-auth-tokens/{console_token}

Given the console authentication token for a server, shows the related
connection information.

This method used to be available only for the ``rdp-html5`` console type before
microversion 2.31. Starting from microversion 2.31 it's available for all
console types.

Normal response codes: 200

Error response codes: badRequest(400), unauthorized(401), forbidden(403),
itemNotFound(404)

Request
-------

.. rest_parameters:: parameters.yaml

- console_token: console_token


Response
--------

.. rest_parameters:: parameters.yaml

- console: console
- instance_uuid: instance_id_body
- host: console_host
- port: port_number
- internal_access_path: internal_access_path

**Example Show Console Authentication Token**

.. literalinclude:: ../../doc/api_samples/os-console-auth-tokens/get-console-connect-info-get-resp.json
:language: javascript
86 changes: 12 additions & 74 deletions nova/api/openstack/compute/consoles.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,89 +16,27 @@
from webob import exc

from nova.api.openstack import wsgi
from nova.console import api as console_api
from nova import exception
from nova.policies import consoles as consoles_policies


def _translate_keys(cons):
"""Coerces a console instance into proper dictionary format."""
pool = cons['pool']
info = {'id': cons['id'],
'console_type': pool['console_type']}
return dict(console=info)


def _translate_detail_keys(cons):
"""Coerces a console instance into proper dictionary format with detail."""
pool = cons['pool']
info = {'id': cons['id'],
'console_type': pool['console_type'],
'password': cons['password'],
'instance_name': cons['instance_name'],
'port': cons['port'],
'host': pool['public_hostname']}
return dict(console=info)


class ConsolesController(wsgi.Controller):
"""The Consoles controller for the OpenStack API."""
"""(Removed) The Consoles controller for the OpenStack API.
def __init__(self):
super(ConsolesController, self).__init__()
self.console_api = console_api.API()
This was removed during the Ussuri release along with the nova-console
service.
"""

@wsgi.expected_errors(())
@wsgi.expected_errors(410)
def index(self, req, server_id):
"""Returns a list of consoles for this instance."""
context = req.environ['nova.context']
context.can(consoles_policies.POLICY_ROOT % 'index')
raise exc.HTTPGone()

consoles = self.console_api.get_consoles(
req.environ['nova.context'], server_id)
return dict(consoles=[_translate_keys(console)
for console in consoles])

# NOTE(gmann): Here should be 201 instead of 200 by v2.1
# +microversions because the console has been created
# completely when returning a response.
@wsgi.expected_errors(404)
@wsgi.expected_errors(410)
def create(self, req, server_id, body):
"""Creates a new console."""
context = req.environ['nova.context']
context.can(consoles_policies.POLICY_ROOT % 'create')

try:
self.console_api.create_console(
req.environ['nova.context'], server_id)
except exception.InstanceNotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())
raise exc.HTTPGone()

@wsgi.expected_errors(404)
@wsgi.expected_errors(410)
def show(self, req, server_id, id):
"""Shows in-depth information on a specific console."""
context = req.environ['nova.context']
context.can(consoles_policies.POLICY_ROOT % 'show')
raise exc.HTTPGone()

try:
console = self.console_api.get_console(
req.environ['nova.context'],
server_id,
int(id))
except exception.ConsoleNotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())
return _translate_detail_keys(console)

@wsgi.response(202)
@wsgi.expected_errors(404)
@wsgi.expected_errors(410)
def delete(self, req, server_id, id):
"""Deletes a console."""
context = req.environ['nova.context']
context.can(consoles_policies.POLICY_ROOT % 'delete')

try:
self.console_api.delete_console(req.environ['nova.context'],
server_id,
int(id))
except exception.ConsoleNotFound as e:
raise exc.HTTPNotFound(explanation=e.format_message())
raise exc.HTTPGone()
2 changes: 0 additions & 2 deletions nova/policies/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from nova.policies import base
from nova.policies import console_auth_tokens
from nova.policies import console_output
from nova.policies import consoles
from nova.policies import create_backup
from nova.policies import deferred_delete
from nova.policies import evacuate
Expand Down Expand Up @@ -85,7 +84,6 @@ def list_rules():
baremetal_nodes.list_rules(),
console_auth_tokens.list_rules(),
console_output.list_rules(),
consoles.list_rules(),
create_backup.list_rules(),
deferred_delete.list_rules(),
evacuate.list_rules(),
Expand Down
Loading

0 comments on commit 3062a11

Please sign in to comment.