Merge "HyperV: Remove RDP console connection information API"
This commit is contained in:
@@ -64,9 +64,9 @@ Show Console Connection Information
|
|||||||
Given the console authentication token for a server, shows the related
|
Given the console authentication token for a server, shows the related
|
||||||
connection information.
|
connection information.
|
||||||
|
|
||||||
This method used to be available only for the ``rdp-html5`` console type before
|
Nova HyperV driver has been removed therefore requests for RDP console connection
|
||||||
microversion 2.31. Starting from microversion 2.31 it's available for all
|
information will always return an http 400 error. Starting from microversion 2.31
|
||||||
console types.
|
it's available for all other console types.
|
||||||
|
|
||||||
Normal response codes: 200
|
Normal response codes: 200
|
||||||
|
|
||||||
@@ -94,5 +94,5 @@ Response
|
|||||||
|
|
||||||
**Example Show Console Authentication Token**
|
**Example Show Console Authentication Token**
|
||||||
|
|
||||||
.. literalinclude:: ../../doc/api_samples/os-console-auth-tokens/get-console-connect-info-get-resp.json
|
.. literalinclude:: ../../doc/api_samples/os-console-auth-tokens/v2.31/get-console-connect-info-get-resp.json
|
||||||
:language: javascript
|
:language: javascript
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"os-getRDPConsole": {
|
|
||||||
"type": "rdp-html5"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,7 +27,7 @@ CONF = nova.conf.CONF
|
|||||||
|
|
||||||
class ConsoleAuthTokensController(wsgi.Controller):
|
class ConsoleAuthTokensController(wsgi.Controller):
|
||||||
|
|
||||||
def _show(self, req, id, rdp_only):
|
def _show(self, req, id):
|
||||||
"""Checks a console auth token and returns the related connect info."""
|
"""Checks a console auth token and returns the related connect info."""
|
||||||
context = req.environ['nova.context']
|
context = req.environ['nova.context']
|
||||||
context.can(cat_policies.BASE_POLICY_NAME)
|
context.can(cat_policies.BASE_POLICY_NAME)
|
||||||
@@ -55,13 +55,6 @@ class ConsoleAuthTokensController(wsgi.Controller):
|
|||||||
if not connect_info:
|
if not connect_info:
|
||||||
raise webob.exc.HTTPNotFound(explanation=_("Token not found"))
|
raise webob.exc.HTTPNotFound(explanation=_("Token not found"))
|
||||||
|
|
||||||
console_type = connect_info.console_type
|
|
||||||
|
|
||||||
if rdp_only and console_type != "rdp-html5":
|
|
||||||
raise webob.exc.HTTPUnauthorized(
|
|
||||||
explanation=_("The requested console type details are not "
|
|
||||||
"accessible"))
|
|
||||||
|
|
||||||
return {'console': {
|
return {'console': {
|
||||||
'instance_uuid': connect_info.instance_uuid,
|
'instance_uuid': connect_info.instance_uuid,
|
||||||
'host': connect_info.host,
|
'host': connect_info.host,
|
||||||
@@ -72,9 +65,17 @@ class ConsoleAuthTokensController(wsgi.Controller):
|
|||||||
@wsgi.Controller.api_version("2.1", "2.30")
|
@wsgi.Controller.api_version("2.1", "2.30")
|
||||||
@wsgi.expected_errors((400, 401, 404))
|
@wsgi.expected_errors((400, 401, 404))
|
||||||
def show(self, req, id):
|
def show(self, req, id):
|
||||||
return self._show(req, id, True)
|
"""Until microversion 2.30, this API was available only for the
|
||||||
|
rdp-html5 console type which has been removed along with the HyperV
|
||||||
|
driver in the Nova 29.0.0 (Caracal) release. As this method is for
|
||||||
|
microversion <=2.30, it will return an http 400 error. Starting
|
||||||
|
from 2.31 microversion, this API works for all the supported
|
||||||
|
console types that are handled by the separate show method
|
||||||
|
defined below.
|
||||||
|
"""
|
||||||
|
raise webob.exc.HTTPBadRequest()
|
||||||
|
|
||||||
@wsgi.Controller.api_version("2.31") # noqa
|
@wsgi.Controller.api_version("2.31") # noqa
|
||||||
@wsgi.expected_errors((400, 404))
|
@wsgi.expected_errors((400, 404))
|
||||||
def show(self, req, id): # noqa
|
def show(self, req, id): # noqa
|
||||||
return self._show(req, id, False)
|
return self._show(req, id)
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"os-getRDPConsole": {
|
|
||||||
"type": "rdp-html5"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"remote_console": {
|
||||||
|
"protocol": "serial",
|
||||||
|
"type": "serial"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,20 +22,22 @@ from nova.tests.functional.api_sample_tests import test_servers
|
|||||||
class ConsoleAuthTokensSampleJsonTests(test_servers.ServersSampleBase):
|
class ConsoleAuthTokensSampleJsonTests(test_servers.ServersSampleBase):
|
||||||
ADMIN_API = True
|
ADMIN_API = True
|
||||||
sample_dir = "os-console-auth-tokens"
|
sample_dir = "os-console-auth-tokens"
|
||||||
|
microversion = '2.31'
|
||||||
|
scenarios = [('v2_31', {'api_major_version': 'v2.1'})]
|
||||||
|
|
||||||
def _get_console_url(self, data):
|
def _get_console_url(self, data):
|
||||||
return jsonutils.loads(data)["console"]["url"]
|
return jsonutils.loads(data)["remote_console"]["url"]
|
||||||
|
|
||||||
def _get_console_token(self, uuid):
|
def _get_console_token(self, uuid):
|
||||||
response = self._do_post('servers/%s/action' % uuid,
|
body = {'protocol': 'serial', 'type': 'serial'}
|
||||||
'get-rdp-console-post-req',
|
response = self._do_post('servers/%s/remote-consoles' % uuid,
|
||||||
{'action': 'os-getRDPConsole'})
|
'create-serial-console-req', body)
|
||||||
|
|
||||||
url = self._get_console_url(response.content)
|
url = self._get_console_url(response.content)
|
||||||
return re.match('.+?token=([^&]+)', url).groups()[0]
|
return re.match('.+?token=([^&]+)', url).groups()[0]
|
||||||
|
|
||||||
def test_get_console_connect_info(self):
|
def test_get_console_connect_info(self):
|
||||||
self.flags(enabled=True, group='rdp')
|
self.flags(enabled=True, group='serial_console')
|
||||||
|
|
||||||
uuid = self._post_server()
|
uuid = self._post_server()
|
||||||
token = self._get_console_token(uuid)
|
token = self._get_console_token(uuid)
|
||||||
|
|||||||
@@ -49,33 +49,11 @@ class ConsoleAuthTokensExtensionTestV21(test.NoDBTestCase):
|
|||||||
self.req = fakes.HTTPRequest.blank('', use_admin_context=True)
|
self.req = fakes.HTTPRequest.blank('', use_admin_context=True)
|
||||||
self.context = self.req.environ['nova.context']
|
self.context = self.req.environ['nova.context']
|
||||||
|
|
||||||
@mock.patch('nova.objects.ConsoleAuthToken.validate',
|
@mock.patch.object(objects.ConsoleAuthToken, 'validate')
|
||||||
return_value=objects.ConsoleAuthToken(
|
|
||||||
instance_uuid=fakes.FAKE_UUID, host='fake_host',
|
|
||||||
port='1234', internal_access_path='fake_access_path',
|
|
||||||
console_type='rdp-html5', token=fakes.FAKE_UUID))
|
|
||||||
def test_get_console_connect_info(self, mock_validate):
|
def test_get_console_connect_info(self, mock_validate):
|
||||||
output = self.controller.show(self.req, fakes.FAKE_UUID)
|
self.assertRaises(webob.exc.HTTPBadRequest,
|
||||||
self.assertEqual(self._EXPECTED_OUTPUT_DB, output)
|
|
||||||
mock_validate.assert_called_once_with(self.context, fakes.FAKE_UUID)
|
|
||||||
|
|
||||||
@mock.patch('nova.objects.ConsoleAuthToken.validate',
|
|
||||||
side_effect=exception.InvalidToken(token='***'))
|
|
||||||
def test_get_console_connect_info_token_not_found(self, mock_validate):
|
|
||||||
self.assertRaises(webob.exc.HTTPNotFound,
|
|
||||||
self.controller.show, self.req, fakes.FAKE_UUID)
|
self.controller.show, self.req, fakes.FAKE_UUID)
|
||||||
mock_validate.assert_called_once_with(self.context, fakes.FAKE_UUID)
|
mock_validate.assert_not_called()
|
||||||
|
|
||||||
@mock.patch('nova.objects.ConsoleAuthToken.validate',
|
|
||||||
return_value=objects.ConsoleAuthToken(
|
|
||||||
instance_uuid=fakes.FAKE_UUID, host='fake_host',
|
|
||||||
port='1234', internal_access_path='fake_access_path',
|
|
||||||
console_type='unauthorized_console_type',
|
|
||||||
token=fakes.FAKE_UUID))
|
|
||||||
def test_get_console_connect_info_nonrdp_console_type(self, mock_validate):
|
|
||||||
self.assertRaises(webob.exc.HTTPUnauthorized,
|
|
||||||
self.controller.show, self.req, fakes.FAKE_UUID)
|
|
||||||
mock_validate.assert_called_once_with(self.context, fakes.FAKE_UUID)
|
|
||||||
|
|
||||||
|
|
||||||
class ConsoleAuthTokensExtensionTestV231(ConsoleAuthTokensExtensionTestV21):
|
class ConsoleAuthTokensExtensionTestV231(ConsoleAuthTokensExtensionTestV21):
|
||||||
@@ -91,7 +69,14 @@ class ConsoleAuthTokensExtensionTestV231(ConsoleAuthTokensExtensionTestV21):
|
|||||||
port='1234', internal_access_path='fake_access_path',
|
port='1234', internal_access_path='fake_access_path',
|
||||||
console_type='webmks',
|
console_type='webmks',
|
||||||
token=fakes.FAKE_UUID))
|
token=fakes.FAKE_UUID))
|
||||||
def test_get_console_connect_info_nonrdp_console_type(self, mock_validate):
|
def test_get_console_connect_info(self, mock_validate):
|
||||||
output = self.controller.show(self.req, fakes.FAKE_UUID)
|
output = self.controller.show(self.req, fakes.FAKE_UUID)
|
||||||
self.assertEqual(self._EXPECTED_OUTPUT_DB, output)
|
self.assertEqual(self._EXPECTED_OUTPUT_DB, output)
|
||||||
mock_validate.assert_called_once_with(self.context, fakes.FAKE_UUID)
|
mock_validate.assert_called_once_with(self.context, fakes.FAKE_UUID)
|
||||||
|
|
||||||
|
@mock.patch('nova.objects.ConsoleAuthToken.validate',
|
||||||
|
side_effect=exception.InvalidToken(token='***'))
|
||||||
|
def test_get_console_connect_info_token_not_found(self, mock_validate):
|
||||||
|
self.assertRaises(webob.exc.HTTPNotFound,
|
||||||
|
self.controller.show, self.req, fakes.FAKE_UUID)
|
||||||
|
mock_validate.assert_called_once_with(self.context, fakes.FAKE_UUID)
|
||||||
|
|||||||
@@ -5,7 +5,14 @@ upgrade:
|
|||||||
Nova 27.2.0 (Antelope) release. This driver was untested and has no
|
Nova 27.2.0 (Antelope) release. This driver was untested and has no
|
||||||
maintainers. In addition, it has a dependency on the OpenStack Winstacker
|
maintainers. In addition, it has a dependency on the OpenStack Winstacker
|
||||||
project that also has been retired.
|
project that also has been retired.
|
||||||
- |
|
|
||||||
|
The RDP console was only available for the HyperV driver, therefore its
|
||||||
|
connection information via below API ``os-console-auth-tokens`` will now
|
||||||
|
return HTTP ``400 (BadRequest)`` error:
|
||||||
|
|
||||||
|
* Show Console Connection Information:
|
||||||
|
GET /os-console-auth-tokens/{console_token}
|
||||||
|
|
||||||
The following config options which only apply for the ``HyperV`` virt
|
The following config options which only apply for the ``HyperV`` virt
|
||||||
driver also been removed:
|
driver also been removed:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user