Remove 'os-consoles' API
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 <sfinucan@redhat.com>
This commit is contained in:
parent
991d675675
commit
3062a1199d
@ -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
|
||||
@ -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
|
||||
|
@ -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
|
||||
==============
|
||||
@ -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
|
||||
-------
|
||||
@ -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
|
||||
-------
|
||||
@ -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
|
||||
-------
|
||||
@ -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
|
||||
-------
|
||||
@ -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
|
||||
|
@ -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
|
||||
@ -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.
|
||||
@ -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.
|
||||
@ -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.
|
||||
|
@ -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
|
||||
|
||||
@ -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
|
||||
|
@ -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')
|
||||
raise exc.HTTPGone()
|
||||
|
||||
try:
|
||||
self.console_api.create_console(
|
||||
req.environ['nova.context'], server_id)
|
||||
except exception.InstanceNotFound as e:
|
||||
raise exc.HTTPNotFound(explanation=e.format_message())
|
||||
|
||||
@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()
|
||||
|
@ -24,7 +24,6 @@ from nova.policies import baremetal_nodes
|
||||
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
|
||||
@ -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(),
|
||||
|
@ -1,69 +0,0 @@
|
||||
# Copyright 2016 Cloudbase Solutions Srl
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from oslo_policy import policy
|
||||
|
||||
from nova.policies import base
|
||||
|
||||
|
||||
POLICY_ROOT = 'os_compute_api:os-consoles:%s'
|
||||
|
||||
|
||||
consoles_policies = [
|
||||
policy.DocumentedRuleDefault(
|
||||
POLICY_ROOT % 'create',
|
||||
base.RULE_ADMIN_OR_OWNER,
|
||||
'Create a console for a server instance',
|
||||
[
|
||||
{
|
||||
'method': 'POST',
|
||||
'path': '/servers/{server_id}/consoles'
|
||||
}
|
||||
]),
|
||||
policy.DocumentedRuleDefault(
|
||||
POLICY_ROOT % 'show',
|
||||
base.RULE_ADMIN_OR_OWNER,
|
||||
'Show console details for a server instance',
|
||||
[
|
||||
{
|
||||
'method': 'GET',
|
||||
'path': '/servers/{server_id}/consoles/{console_id}'
|
||||
}
|
||||
]),
|
||||
policy.DocumentedRuleDefault(
|
||||
POLICY_ROOT % 'delete',
|
||||
base.RULE_ADMIN_OR_OWNER,
|
||||
'Delete a console for a server instance',
|
||||
[
|
||||
{
|
||||
'method': 'DELETE',
|
||||
'path': '/servers/{server_id}/consoles/{console_id}'
|
||||
}
|
||||
]),
|
||||
policy.DocumentedRuleDefault(
|
||||
POLICY_ROOT % 'index',
|
||||
base.RULE_ADMIN_OR_OWNER,
|
||||
'List all consoles for a server instance',
|
||||
[
|
||||
{
|
||||
'method': 'GET',
|
||||
'path': '/servers/{server_id}/consoles'
|
||||
}
|
||||
])
|
||||
]
|
||||
|
||||
|
||||
def list_rules():
|
||||
return consoles_policies
|
@ -1 +0,0 @@
|
||||
{"console": {"console_type": "fake", "port": 5999, "instance_name": "instance-00000001", "host": "fake", "password": "%(password)s", "id": 1}}
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"consoles": [
|
||||
{
|
||||
"console": {
|
||||
"console_type": "fake",
|
||||
"id": 1
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
@ -13,47 +13,25 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import fixtures
|
||||
|
||||
from nova.console import manager as console_manager # noqa - only for cfg
|
||||
from nova.tests.functional.api_sample_tests import test_servers
|
||||
from nova.tests.unit import fake_xvp_console_proxy
|
||||
|
||||
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
|
||||
|
||||
class ConsolesSamplesJsonTest(test_servers.ServersSampleBase):
|
||||
sample_dir = "consoles"
|
||||
|
||||
def setUp(self):
|
||||
super(ConsolesSamplesJsonTest, self).setUp()
|
||||
self.flags(console_public_hostname='fake', group='xenserver')
|
||||
self.flags(console_host='fake')
|
||||
self.useFixture(fixtures.MonkeyPatch(
|
||||
'nova.console.manager.xvp.XVPConsoleProxy',
|
||||
fake_xvp_console_proxy.FakeConsoleProxy))
|
||||
self.console = self.start_service('console', host='fake')
|
||||
|
||||
def _create_consoles(self, server_uuid):
|
||||
response = self._do_post('servers/%s/consoles' % server_uuid)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
def test_create_consoles(self):
|
||||
uuid = self._post_server()
|
||||
self._create_consoles(uuid)
|
||||
self.api.api_post('servers/%s/consoles' % FAKE_UUID, {},
|
||||
check_response_status=[410])
|
||||
|
||||
def test_list_consoles(self):
|
||||
uuid = self._post_server()
|
||||
self._create_consoles(uuid)
|
||||
response = self._do_get('servers/%s/consoles' % uuid)
|
||||
self._verify_response('consoles-list-get-resp', {}, response, 200)
|
||||
self.api.api_get('servers/%s/consoles' % FAKE_UUID,
|
||||
check_response_status=[410])
|
||||
|
||||
def test_console_get(self):
|
||||
uuid = self._post_server()
|
||||
self._create_consoles(uuid)
|
||||
response = self._do_get('servers/%s/consoles/1' % uuid)
|
||||
self._verify_response('consoles-get-resp', {}, response, 200)
|
||||
self.api.api_get('servers/%s/consoles/1' % FAKE_UUID,
|
||||
check_response_status=[410])
|
||||
|
||||
def test_console_delete(self):
|
||||
uuid = self._post_server()
|
||||
self._create_consoles(uuid)
|
||||
response = self._do_delete('servers/%s/consoles/1' % uuid)
|
||||
self.assertEqual(202, response.status_code)
|
||||
self.api.api_delete('servers/%s/consoles/1' % FAKE_UUID,
|
||||
check_response_status=[410])
|
||||
|
@ -1,300 +0,0 @@
|
||||
# Copyright 2010-2011 OpenStack Foundation
|
||||
# Copyright 2011 Piston Cloud Computing, Inc.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import datetime
|
||||
|
||||
from oslo_policy import policy as oslo_policy
|
||||
from oslo_utils.fixture import uuidsentinel as uuids
|
||||
from oslo_utils import timeutils
|
||||
import webob
|
||||
|
||||
from nova.api.openstack.compute import consoles as consoles_v21
|
||||
from nova.compute import vm_states
|
||||
from nova import exception
|
||||
from nova import policy
|
||||
from nova import test
|
||||
from nova.tests.unit.api.openstack import fakes
|
||||
from nova.tests.unit import matchers
|
||||
|
||||
|
||||
FAKE_UUID = 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
|
||||
|
||||
|
||||
class FakeInstanceDB(object):
|
||||
|
||||
def __init__(self):
|
||||
self.instances_by_id = {}
|
||||
self.ids_by_uuid = {}
|
||||
self.max_id = 0
|
||||
|
||||
def return_server_by_id(self, context, id):
|
||||
if id not in self.instances_by_id:
|
||||
self._add_server(id=id)
|
||||
return dict(self.instances_by_id[id])
|
||||
|
||||
def return_server_by_uuid(self, context, uuid):
|
||||
if uuid not in self.ids_by_uuid:
|
||||
self._add_server(uuid=uuid)
|
||||
return dict(self.instances_by_id[self.ids_by_uuid[uuid]])
|
||||
|
||||
def _add_server(self, id=None, uuid=None):
|
||||
if id is None:
|
||||
id = self.max_id + 1
|
||||
if uuid is None:
|
||||
uuid = uuids.fake
|
||||
instance = stub_instance(id, uuid=uuid)
|
||||
self.instances_by_id[id] = instance
|
||||
self.ids_by_uuid[uuid] = id
|
||||
if id > self.max_id:
|
||||
self.max_id = id
|
||||
|
||||
|
||||
def stub_instance(id, user_id='fake', project_id='fake', host=None,
|
||||
vm_state=None, task_state=None,
|
||||
reservation_id="", uuid=FAKE_UUID, image_ref="10",
|
||||
flavor_id="1", name=None, key_name='',
|
||||
access_ipv4=None, access_ipv6=None, progress=0):
|
||||
|
||||
if host is not None:
|
||||
host = str(host)
|
||||
|
||||
if key_name:
|
||||
key_data = 'FAKE'
|
||||
else:
|
||||
key_data = ''
|
||||
|
||||
# ReservationID isn't sent back, hack it in there.
|
||||
server_name = name or "server%s" % id
|
||||
if reservation_id != "":
|
||||
server_name = "reservation_%s" % (reservation_id, )
|
||||
|
||||
instance = {
|
||||
"id": int(id),
|
||||
"created_at": datetime.datetime(2010, 10, 10, 12, 0, 0),
|
||||
"updated_at": datetime.datetime(2010, 11, 11, 11, 0, 0),
|
||||
"admin_pass": "",
|
||||
"user_id": user_id,
|
||||
"project_id": project_id,
|
||||
"image_ref": image_ref,
|
||||
"kernel_id": "",
|
||||
"ramdisk_id": "",
|
||||
"launch_index": 0,
|
||||
"key_name": key_name,
|
||||
"key_data": key_data,
|
||||
"vm_state": vm_state or vm_states.BUILDING,
|
||||
"task_state": task_state,
|
||||
"memory_mb": 0,
|
||||
"vcpus": 0,
|
||||
"root_gb": 0,
|
||||
"hostname": "",
|
||||
"host": host,
|
||||
"instance_type": {},
|
||||
"user_data": "",
|
||||
"reservation_id": reservation_id,
|
||||
"mac_address": "",
|
||||
"launched_at": timeutils.utcnow(),
|
||||
"terminated_at": timeutils.utcnow(),
|
||||
"availability_zone": "",
|
||||
"display_name": server_name,
|
||||
"display_description": "",
|
||||
"locked": False,
|
||||
"metadata": [],
|
||||
"access_ip_v4": access_ipv4,
|
||||
"access_ip_v6": access_ipv6,
|
||||
"uuid": uuid,
|
||||
"progress": progress}
|
||||
|
||||
return instance
|
||||
|
||||
|
||||
class ConsolesControllerTestV21(test.NoDBTestCase):
|
||||
def setUp(self):
|
||||
super(ConsolesControllerTestV21, self).setUp()
|
||||
self.instance_db = FakeInstanceDB()
|
||||
self.stub_out('nova.db.api.instance_get',
|
||||
self.instance_db.return_server_by_id)
|
||||
self.stub_out('nova.db.api.instance_get_by_uuid',
|
||||
self.instance_db.return_server_by_uuid)
|
||||
self.uuid = uuids.fake
|
||||
self.url = '/v2/%s/servers/%s/consoles' % (fakes.FAKE_PROJECT_ID,
|
||||
self.uuid)
|
||||
self._set_up_controller()
|
||||
|
||||
def _set_up_controller(self):
|
||||
self.controller = consoles_v21.ConsolesController()
|
||||
|
||||
def test_create_console(self):
|
||||
def fake_create_console(cons_self, context, instance_id):
|
||||
self.assertEqual(instance_id, self.uuid)
|
||||
return {}
|
||||
|
||||
self.stub_out('nova.console.api.API.create_console',
|
||||
fake_create_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
self.controller.create(req, self.uuid, None)
|
||||
|
||||
def test_create_console_unknown_instance(self):
|
||||
def fake_create_console(cons_self, context, instance_id):
|
||||
raise exception.InstanceNotFound(instance_id=instance_id)
|
||||
|
||||
self.stub_out('nova.console.api.API.create_console',
|
||||
fake_create_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.create,
|
||||
req, self.uuid, None)
|
||||
|
||||
def test_show_console(self):
|
||||
def fake_get_console(cons_self, context, instance_id, console_id):
|
||||
self.assertEqual(instance_id, self.uuid)
|
||||
self.assertEqual(console_id, 20)
|
||||
pool = dict(console_type='fake_type',
|
||||
public_hostname='fake_hostname')
|
||||
return dict(id=console_id, password='fake_password',
|
||||
port='fake_port', pool=pool, instance_name='inst-0001')
|
||||
|
||||
expected = {'console': {'id': 20,
|
||||
'port': 'fake_port',
|
||||
'host': 'fake_hostname',
|
||||
'password': 'fake_password',
|
||||
'instance_name': 'inst-0001',
|
||||
'console_type': 'fake_type'}}
|
||||
|
||||
self.stub_out('nova.console.api.API.get_console', fake_get_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
res_dict = self.controller.show(req, self.uuid, '20')
|
||||
self.assertThat(res_dict, matchers.DictMatches(expected))
|
||||
|
||||
def test_show_console_unknown_console(self):
|
||||
def fake_get_console(cons_self, context, instance_id, console_id):
|
||||
raise exception.ConsoleNotFound(console_id=console_id)
|
||||
|
||||
self.stub_out('nova.console.api.API.get_console', fake_get_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.show,
|
||||
req, self.uuid, '20')
|
||||
|
||||
def test_show_console_unknown_instance(self):
|
||||
def fake_get_console(cons_self, context, instance_id, console_id):
|
||||
raise exception.ConsoleNotFoundForInstance(
|
||||
instance_uuid=instance_id)
|
||||
|
||||
self.stub_out('nova.console.api.API.get_console', fake_get_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.show,
|
||||
req, self.uuid, '20')
|
||||
|
||||
def test_list_consoles(self):
|
||||
def fake_get_consoles(cons_self, context, instance_id):
|
||||
self.assertEqual(instance_id, self.uuid)
|
||||
|
||||
pool1 = dict(console_type='fake_type',
|
||||
public_hostname='fake_hostname')
|
||||
cons1 = dict(id=10, password='fake_password',
|
||||
port='fake_port', pool=pool1)
|
||||
pool2 = dict(console_type='fake_type2',
|
||||
public_hostname='fake_hostname2')
|
||||
cons2 = dict(id=11, password='fake_password2',
|
||||
port='fake_port2', pool=pool2)
|
||||
return [cons1, cons2]
|
||||
|
||||
expected = {'consoles':
|
||||
[{'console': {'id': 10, 'console_type': 'fake_type'}},
|
||||
{'console': {'id': 11, 'console_type': 'fake_type2'}}]}
|
||||
|
||||
self.stub_out('nova.console.api.API.get_consoles', fake_get_consoles)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url)
|
||||
res_dict = self.controller.index(req, self.uuid)
|
||||
self.assertThat(res_dict, matchers.DictMatches(expected))
|
||||
|
||||
def test_delete_console(self):
|
||||
def fake_get_console(cons_self, context, instance_id, console_id):
|
||||
self.assertEqual(instance_id, self.uuid)
|
||||
self.assertEqual(console_id, 20)
|
||||
pool = dict(console_type='fake_type',
|
||||
public_hostname='fake_hostname')
|
||||
return dict(id=console_id, password='fake_password',
|
||||
port='fake_port', pool=pool)
|
||||
|
||||
def fake_delete_console(cons_self, context, instance_id, console_id):
|
||||
self.assertEqual(instance_id, self.uuid)
|
||||
self.assertEqual(console_id, 20)
|
||||
|
||||
self.stub_out('nova.console.api.API.get_console', fake_get_console)
|
||||
self.stub_out('nova.console.api.API.delete_console',
|
||||
fake_delete_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
self.controller.delete(req, self.uuid, '20')
|
||||
|
||||
def test_delete_console_unknown_console(self):
|
||||
def fake_delete_console(cons_self, context, instance_id, console_id):
|
||||
raise exception.ConsoleNotFound(console_id=console_id)
|
||||
|
||||
self.stub_out('nova.console.api.API.delete_console',
|
||||
fake_delete_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete,
|
||||
req, self.uuid, '20')
|
||||
|
||||
def test_delete_console_unknown_instance(self):
|
||||
def fake_delete_console(cons_self, context, instance_id, console_id):
|
||||
raise exception.ConsoleNotFoundForInstance(
|
||||
instance_uuid=instance_id)
|
||||
|
||||
self.stub_out('nova.console.api.API.delete_console',
|
||||
fake_delete_console)
|
||||
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete,
|
||||
req, self.uuid, '20')
|
||||
|
||||
def _test_fail_policy(self, rule, action, data=None):
|
||||
rules = {
|
||||
rule: "!",
|
||||
}
|
||||
|
||||
policy.set_rules(oslo_policy.Rules.from_dict(rules))
|
||||
req = fakes.HTTPRequest.blank(self.url + '/20')
|
||||
|
||||
if data is not None:
|
||||
self.assertRaises(exception.PolicyNotAuthorized, action,
|
||||
req, self.uuid, data)
|
||||
else:
|
||||
self.assertRaises(exception.PolicyNotAuthorized, action,
|
||||
req, self.uuid)
|
||||
|
||||
def test_delete_console_fail_policy(self):
|
||||
self._test_fail_policy("os_compute_api:os-consoles:delete",
|
||||
self.controller.delete, data='20')
|
||||
|
||||
def test_create_console_fail_policy(self):
|
||||
self._test_fail_policy("os_compute_api:os-consoles:create",
|
||||
self.controller.create, data='20')
|
||||
|
||||
def test_index_console_fail_policy(self):
|
||||
self._test_fail_policy("os_compute_api:os-consoles:index",
|
||||
self.controller.index)
|
||||
|
||||
def test_show_console_fail_policy(self):
|
||||
self._test_fail_policy("os_compute_api:os-consoles:show",
|
||||
self.controller.show, data='20')
|
@ -30,10 +30,6 @@ policy_data = """
|
||||
"os_compute_api:os-baremetal-nodes": "",
|
||||
"os_compute_api:os-console-output": "",
|
||||
"os_compute_api:os-remote-consoles": "",
|
||||
"os_compute_api:os-consoles:create": "",
|
||||
"os_compute_api:os-consoles:delete": "",
|
||||
"os_compute_api:os-consoles:index": "",
|
||||
"os_compute_api:os-consoles:show": "",
|
||||
"os_compute_api:os-create-backup": "",
|
||||
"os_compute_api:os-deferred-delete": "",
|
||||
"os_compute_api:os-extended-server-attributes": "",
|
||||
|
@ -416,10 +416,6 @@ class RealRolePolicyTestCase(test.NoDBTestCase):
|
||||
"os_compute_api:os-attach-interfaces",
|
||||
"os_compute_api:os-attach-interfaces:create",
|
||||
"os_compute_api:os-attach-interfaces:delete",
|
||||
"os_compute_api:os-consoles:create",
|
||||
"os_compute_api:os-consoles:delete",
|
||||
"os_compute_api:os-consoles:index",
|
||||
"os_compute_api:os-consoles:show",
|
||||
"os_compute_api:os-console-output",
|
||||
"os_compute_api:os-remote-consoles",
|
||||
"os_compute_api:os-deferred-delete",
|
||||
|
18
releasenotes/notes/remove-nova-console-5a2b86210a43e7c8.yaml
Normal file
18
releasenotes/notes/remove-nova-console-5a2b86210a43e7c8.yaml
Normal file
@ -0,0 +1,18 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
The following APIs have been removed. Calling these APIs will
|
||||
now result in a ``410 HTTPGone`` error response:
|
||||
|
||||
* ``POST /servers/{server_id}/consoles``
|
||||
* ``GET /servers/{server_id}/consoles``
|
||||
* ``GET /servers/{server_id}/consoles/{console_id}``
|
||||
* ``DELETE /servers/{server_id}/consoles/{console_id}``
|
||||
|
||||
In addition, the following policies are removed. These were related to the
|
||||
removed APIs listed above and no longer had any effect:
|
||||
|
||||
* ``os_compute_api:os-consoles:index``
|
||||
* ``os_compute_api:os-consoles:create``
|
||||
* ``os_compute_api:os-consoles:delete``
|
||||
* ``os_compute_api:os-consoles:show``
|
Loading…
Reference in New Issue
Block a user