Add support for spice-direct console types.
This patch adds support for Nova microversion 2.99 which exposes the new spice-direct console type and the pre-existing /os-console-auth-token/ API. +----------+----------------------------------------------------------+ | Field | Value | +----------+----------------------------------------------------------+ | protocol | spice | | type | spice-direct | | url | http://127.0.0.1:13002/nova?token=f78009fb-41ad-... | +----------+----------------------------------------------------------+ +----------------------+--------------------------------------+ | Field | Value | +----------------------+--------------------------------------+ | host | 127.0.0.1 | | instance_uuid | f2477018-aa93-... | | internal_access_path | None | | port | 5900 | | tls_port | 5901 | +----------------------+--------------------------------------+ Change-Id: I2d33646d6ac9b25076d69be76dcef8f5c465cd1b Depends-On: https://review.opendev.org/c/openstack/openstacksdk/+/940479
This commit is contained in:
10
doc/source/cli/command-objects/console-connection.rst
Normal file
10
doc/source/cli/command-objects/console-connection.rst
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
==================
|
||||||
|
console connection
|
||||||
|
==================
|
||||||
|
|
||||||
|
Server console connection information
|
||||||
|
|
||||||
|
Compute v2
|
||||||
|
|
||||||
|
.. autoprogram-cliff:: openstack.compute.v2
|
||||||
|
:command: console connection show
|
@@ -106,6 +106,13 @@ class ShowConsoleURL(command.ShowOne):
|
|||||||
const='spice-html5',
|
const='spice-html5',
|
||||||
help=_("Show SPICE console URL"),
|
help=_("Show SPICE console URL"),
|
||||||
)
|
)
|
||||||
|
type_group.add_argument(
|
||||||
|
'--spice-direct',
|
||||||
|
dest='url_type',
|
||||||
|
action='store_const',
|
||||||
|
const='spice-direct',
|
||||||
|
help=_("Show SPICE direct protocol native console URL"),
|
||||||
|
)
|
||||||
type_group.add_argument(
|
type_group.add_argument(
|
||||||
'--rdp',
|
'--rdp',
|
||||||
dest='url_type',
|
dest='url_type',
|
||||||
|
48
openstackclient/compute/v2/console_connection.py
Normal file
48
openstackclient/compute/v2/console_connection.py
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# 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.
|
||||||
|
#
|
||||||
|
|
||||||
|
"""Compute v2 Console auth token implementations."""
|
||||||
|
|
||||||
|
from osc_lib.command import command
|
||||||
|
from osc_lib import utils
|
||||||
|
|
||||||
|
from openstackclient.i18n import _
|
||||||
|
|
||||||
|
|
||||||
|
def _get_console_connection_columns(item):
|
||||||
|
column_map: dict[str, str] = {}
|
||||||
|
hidden_columns = ['id', 'location', 'name']
|
||||||
|
return utils.get_osc_show_columns_for_sdk_resource(
|
||||||
|
item, column_map, hidden_columns
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class ShowConsoleConnectionInformation(command.ShowOne):
|
||||||
|
_description = _("Show server's remote console connection information")
|
||||||
|
|
||||||
|
def get_parser(self, prog_name):
|
||||||
|
parser = super().get_parser(prog_name)
|
||||||
|
parser.add_argument(
|
||||||
|
'token',
|
||||||
|
metavar='<token>',
|
||||||
|
help=_("Nova console token to lookup"),
|
||||||
|
)
|
||||||
|
return parser
|
||||||
|
|
||||||
|
def take_action(self, parsed_args):
|
||||||
|
compute_client = self.app.client_manager.compute
|
||||||
|
data = compute_client.validate_console_auth_token(parsed_args.token)
|
||||||
|
display_columns, columns = _get_console_connection_columns(data)
|
||||||
|
data = utils.get_dict_properties(data, columns)
|
||||||
|
|
||||||
|
return (display_columns, data)
|
@@ -157,7 +157,7 @@ class TestConsoleUrlShow(compute_fakes.TestComputev2):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
def test_console_url_show_with_spice(self):
|
def test_console_url_show_with_spice_html5(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--spice',
|
'--spice',
|
||||||
'foo_vm',
|
'foo_vm',
|
||||||
@@ -174,6 +174,23 @@ class TestConsoleUrlShow(compute_fakes.TestComputev2):
|
|||||||
self.assertEqual(self.columns, columns)
|
self.assertEqual(self.columns, columns)
|
||||||
self.assertEqual(self.data, data)
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
|
def test_console_url_show_with_spice_direct(self):
|
||||||
|
arglist = [
|
||||||
|
'--spice-direct',
|
||||||
|
'foo_vm',
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('url_type', 'spice-direct'),
|
||||||
|
('server', 'foo_vm'),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
self.compute_client.create_console.assert_called_once_with(
|
||||||
|
self._server.id, console_type='spice-direct'
|
||||||
|
)
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.data, data)
|
||||||
|
|
||||||
def test_console_url_show_with_rdp(self):
|
def test_console_url_show_with_rdp(self):
|
||||||
arglist = [
|
arglist = [
|
||||||
'--rdp',
|
'--rdp',
|
||||||
|
@@ -0,0 +1,72 @@
|
|||||||
|
# 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 uuid
|
||||||
|
|
||||||
|
from openstack.compute.v2 import console_auth_token as _console_auth_token
|
||||||
|
from openstack.test import fakes as sdk_fakes
|
||||||
|
|
||||||
|
from openstackclient.compute.v2 import console_connection
|
||||||
|
from openstackclient.tests.unit.compute.v2 import fakes as compute_fakes
|
||||||
|
|
||||||
|
|
||||||
|
class TestConsoleTokens(compute_fakes.TestComputev2):
|
||||||
|
def setUp(self):
|
||||||
|
super().setUp()
|
||||||
|
|
||||||
|
self._console_auth_token = sdk_fakes.generate_fake_resource(
|
||||||
|
_console_auth_token.ConsoleAuthToken,
|
||||||
|
host='127.0.0.1',
|
||||||
|
instance_uuid=uuid.uuid4().hex,
|
||||||
|
internal_access_path=None,
|
||||||
|
port=5900,
|
||||||
|
tls_port=5901,
|
||||||
|
)
|
||||||
|
self.compute_client.validate_console_auth_token.return_value = (
|
||||||
|
self._console_auth_token
|
||||||
|
)
|
||||||
|
|
||||||
|
self.columns = (
|
||||||
|
'host',
|
||||||
|
'instance_uuid',
|
||||||
|
'internal_access_path',
|
||||||
|
'port',
|
||||||
|
'tls_port',
|
||||||
|
)
|
||||||
|
self.data = (
|
||||||
|
self._console_auth_token.host,
|
||||||
|
self._console_auth_token.instance_uuid,
|
||||||
|
self._console_auth_token.internal_access_path,
|
||||||
|
self._console_auth_token.port,
|
||||||
|
self._console_auth_token.tls_port,
|
||||||
|
)
|
||||||
|
|
||||||
|
self.cmd = console_connection.ShowConsoleConnectionInformation(
|
||||||
|
self.app, None
|
||||||
|
)
|
||||||
|
|
||||||
|
def test_console_connection_show(self):
|
||||||
|
arglist = [
|
||||||
|
'token',
|
||||||
|
]
|
||||||
|
verifylist = [
|
||||||
|
('token', 'token'),
|
||||||
|
]
|
||||||
|
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||||
|
|
||||||
|
columns, data = self.cmd.take_action(parsed_args)
|
||||||
|
|
||||||
|
self.compute_client.validate_console_auth_token.assert_called_once_with(
|
||||||
|
'token'
|
||||||
|
)
|
||||||
|
self.assertEqual(self.columns, columns)
|
||||||
|
self.assertEqual(self.data, data)
|
@@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Add support for the new ``spice-direct`` console type, as well as the
|
||||||
|
exposing the ability for admins to lookup console connection information
|
||||||
|
via the new ``console connection show`` command.
|
@@ -7,7 +7,7 @@ pbr!=2.1.0,>=2.0.0 # Apache-2.0
|
|||||||
cryptography>=2.7 # BSD/Apache-2.0
|
cryptography>=2.7 # BSD/Apache-2.0
|
||||||
cliff>=3.5.0 # Apache-2.0
|
cliff>=3.5.0 # Apache-2.0
|
||||||
iso8601>=0.1.11 # MIT
|
iso8601>=0.1.11 # MIT
|
||||||
openstacksdk>=4.4.0 # Apache-2.0
|
openstacksdk>=4.5.0 # Apache-2.0
|
||||||
osc-lib>=2.3.0 # Apache-2.0
|
osc-lib>=2.3.0 # Apache-2.0
|
||||||
oslo.i18n>=3.15.3 # Apache-2.0
|
oslo.i18n>=3.15.3 # Apache-2.0
|
||||||
python-keystoneclient>=3.22.0 # Apache-2.0
|
python-keystoneclient>=3.22.0 # Apache-2.0
|
||||||
|
@@ -77,6 +77,8 @@ openstack.compute.v2 =
|
|||||||
console_log_show = openstackclient.compute.v2.console:ShowConsoleLog
|
console_log_show = openstackclient.compute.v2.console:ShowConsoleLog
|
||||||
console_url_show = openstackclient.compute.v2.console:ShowConsoleURL
|
console_url_show = openstackclient.compute.v2.console:ShowConsoleURL
|
||||||
|
|
||||||
|
console_connection_show = openstackclient.compute.v2.console_connection:ShowConsoleConnectionInformation
|
||||||
|
|
||||||
flavor_create = openstackclient.compute.v2.flavor:CreateFlavor
|
flavor_create = openstackclient.compute.v2.flavor:CreateFlavor
|
||||||
flavor_delete = openstackclient.compute.v2.flavor:DeleteFlavor
|
flavor_delete = openstackclient.compute.v2.flavor:DeleteFlavor
|
||||||
flavor_list = openstackclient.compute.v2.flavor:ListFlavor
|
flavor_list = openstackclient.compute.v2.flavor:ListFlavor
|
||||||
|
Reference in New Issue
Block a user