Merge "Fix ConsoleAuthTokens to work for all console types"
This commit is contained in:
@@ -146,7 +146,8 @@ Show Console Authentication Token
|
||||
Given the console authentication token for a server instance,
|
||||
shows the related connection information.
|
||||
|
||||
This method is available for ``rdp-html5`` console type only.
|
||||
This method used to be available just for the ``rdp-html5`` console type prior
|
||||
microversion 2.31. Now it's available for all console types.
|
||||
|
||||
Normal response codes: 200
|
||||
|
||||
|
@@ -19,7 +19,7 @@
|
||||
}
|
||||
],
|
||||
"status": "CURRENT",
|
||||
"version": "2.30",
|
||||
"version": "2.31",
|
||||
"min_version": "2.1",
|
||||
"updated": "2013-07-23T11:33:21Z"
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@
|
||||
}
|
||||
],
|
||||
"status": "CURRENT",
|
||||
"version": "2.30",
|
||||
"version": "2.31",
|
||||
"min_version": "2.1",
|
||||
"updated": "2013-07-23T11:33:21Z"
|
||||
}
|
||||
|
@@ -79,6 +79,7 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
||||
behaviour for the host flag by calling the scheduler.
|
||||
* 2.30 - Add a force flag in live-migrate request body and change the
|
||||
behaviour for the host flag by calling the scheduler.
|
||||
* 2.31 - Fix os-console-auth-tokens to work for all console types.
|
||||
"""
|
||||
|
||||
# The minimum and maximum versions of the API supported
|
||||
@@ -87,7 +88,7 @@ REST_API_VERSION_HISTORY = """REST API Version History:
|
||||
# Note(cyeoh): This only applies for the v2.1 API once microversions
|
||||
# support is fully merged. It does not affect the V2 API.
|
||||
_MIN_API_VERSION = "2.1"
|
||||
_MAX_API_VERSION = "2.30"
|
||||
_MAX_API_VERSION = "2.31"
|
||||
DEFAULT_API_VERSION = _MIN_API_VERSION
|
||||
|
||||
|
||||
|
@@ -29,8 +29,7 @@ class ConsoleAuthTokensController(wsgi.Controller):
|
||||
self._consoleauth_rpcapi = consoleauth_rpcapi.ConsoleAuthAPI()
|
||||
super(ConsoleAuthTokensController, self).__init__(*args, **kwargs)
|
||||
|
||||
@extensions.expected_errors((400, 401, 404))
|
||||
def show(self, req, id):
|
||||
def _show(self, req, id, rdp_only):
|
||||
"""Checks a console auth token and returns the related connect info."""
|
||||
context = req.environ['nova.context']
|
||||
authorize(context)
|
||||
@@ -45,8 +44,8 @@ class ConsoleAuthTokensController(wsgi.Controller):
|
||||
raise webob.exc.HTTPNotFound(explanation=_("Token not found"))
|
||||
|
||||
console_type = connect_info.get('console_type')
|
||||
# This is currently required only for RDP consoles
|
||||
if console_type != "rdp-html5":
|
||||
|
||||
if rdp_only and console_type != "rdp-html5":
|
||||
raise webob.exc.HTTPUnauthorized(
|
||||
explanation=_("The requested console type details are not "
|
||||
"accessible"))
|
||||
@@ -57,6 +56,16 @@ class ConsoleAuthTokensController(wsgi.Controller):
|
||||
'internal_access_path']
|
||||
if i in connect_info}}
|
||||
|
||||
@wsgi.Controller.api_version("2.1", "2.30")
|
||||
@extensions.expected_errors((400, 401, 404))
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, True)
|
||||
|
||||
@wsgi.Controller.api_version("2.31") # noqa
|
||||
@extensions.expected_errors((400, 404))
|
||||
def show(self, req, id):
|
||||
return self._show(req, id, False)
|
||||
|
||||
|
||||
class ConsoleAuthTokens(extensions.V21APIExtensionBase):
|
||||
"""Console token authentication support."""
|
||||
|
@@ -318,3 +318,9 @@ user documentation.
|
||||
Also changes the live-migrate action behaviour when providing a ``host``
|
||||
string field by calling the nova scheduler to verify the provided host unless
|
||||
the ``force`` attribute is set.
|
||||
|
||||
2.31
|
||||
----
|
||||
|
||||
Fix os-console-auth-tokens to return connection info for all types of tokens,
|
||||
not just RDP.
|
||||
|
@@ -15,8 +15,10 @@
|
||||
|
||||
import copy
|
||||
|
||||
import mock
|
||||
import webob
|
||||
|
||||
from nova.api.openstack import api_version_request
|
||||
from nova.api.openstack.compute import console_auth_tokens \
|
||||
as console_auth_tokens_v21
|
||||
from nova.consoleauth import rpcapi as consoleauth_rpcapi
|
||||
@@ -71,8 +73,26 @@ class ConsoleAuthTokensExtensionTestV21(test.NoDBTestCase):
|
||||
self.assertRaises(webob.exc.HTTPNotFound,
|
||||
self.controller.show, self.req, fakes.FAKE_UUID)
|
||||
|
||||
def test_get_console_connect_info_unauthorized_console_type(self):
|
||||
def test_get_console_connect_info_nonrdp_console_type(self):
|
||||
self.stubs.Set(consoleauth_rpcapi.ConsoleAuthAPI, 'check_token',
|
||||
_fake_check_token_unauthorized)
|
||||
self.assertRaises(webob.exc.HTTPUnauthorized,
|
||||
self.controller.show, self.req, fakes.FAKE_UUID)
|
||||
|
||||
|
||||
class ConsoleAuthTokensExtensionTestV231(ConsoleAuthTokensExtensionTestV21):
|
||||
|
||||
def setUp(self):
|
||||
super(ConsoleAuthTokensExtensionTestV231, self).setUp()
|
||||
self.req.api_version_request = api_version_request.APIVersionRequest(
|
||||
'2.31')
|
||||
|
||||
@mock.patch.object(consoleauth_rpcapi.ConsoleAuthAPI, 'check_token')
|
||||
def test_get_console_connect_info_nonrdp_console_type(self, mock_check):
|
||||
mock_check.return_value = {'instance_uuid': 'fake_instance_uuid',
|
||||
'host': 'fake_host',
|
||||
'port': 'fake_port',
|
||||
'internal_access_path': 'fake_access_path',
|
||||
'console_type': 'webmks'}
|
||||
output = self.controller.show(self.req, fakes.FAKE_UUID)
|
||||
self.assertEqual(self._EXPECTED_OUTPUT, output)
|
||||
|
@@ -0,0 +1,4 @@
|
||||
---
|
||||
features:
|
||||
- Fix os-console-auth-tokens API to return connection info for all types
|
||||
of tokens, not just RDP.
|
Reference in New Issue
Block a user