From cf20225347766240a2ebb155e6e46b85f84a3ddc Mon Sep 17 00:00:00 2001 From: Rui Chen Date: Thu, 21 Jul 2016 15:30:01 +0800 Subject: [PATCH] Support to get server rdp/serial/mks type console url The patch add the support to get server rdp/serial/mks type console url, that make osc capability equal with current nova server side feature. Change-Id: I3dee2531c68563725187c8251d5ea8d4c02cca0c Closes-Bug: #1605088 --- doc/source/command-objects/console-url.rst | 12 +++++ openstackclient/compute/v2/console.py | 27 +++++++++++ .../tests/compute/v2/test_console.py | 47 +++++++++++++++++++ .../notes/bug-1605088-fea9347336764469.yaml | 4 ++ 4 files changed, 90 insertions(+) create mode 100644 releasenotes/notes/bug-1605088-fea9347336764469.yaml diff --git a/doc/source/command-objects/console-url.rst b/doc/source/command-objects/console-url.rst index 7993a7bfe..166d0a9ed 100644 --- a/doc/source/command-objects/console-url.rst +++ b/doc/source/command-objects/console-url.rst @@ -30,6 +30,18 @@ Show server's remote console URL Show SPICE console URL +.. option:: --rdp + + Show RDP console URL + +.. option:: --serial + + Show serial console URL + +.. option:: --mks + + Show WebMKS console URL + .. describe:: Server to show URL (name or ID) diff --git a/openstackclient/compute/v2/console.py b/openstackclient/compute/v2/console.py index 74bed4417..02be99d52 100644 --- a/openstackclient/compute/v2/console.py +++ b/openstackclient/compute/v2/console.py @@ -96,6 +96,27 @@ class ShowConsoleURL(command.ShowOne): const='spice-html5', help=_("Show SPICE console URL") ) + type_group.add_argument( + '--rdp', + dest='url_type', + action='store_const', + const='rdp-html5', + help=_("Show RDP console URL"), + ) + type_group.add_argument( + '--serial', + dest='url_type', + action='store_const', + const='serial', + help=_("Show serial console URL"), + ) + type_group.add_argument( + '--mks', + dest='url_type', + action='store_const', + const='webmks', + help=_("Show WebMKS console URL"), + ) return parser def take_action(self, parsed_args): @@ -110,6 +131,12 @@ class ShowConsoleURL(command.ShowOne): data = server.get_vnc_console(parsed_args.url_type) if parsed_args.url_type in ['spice-html5']: data = server.get_spice_console(parsed_args.url_type) + if parsed_args.url_type in ['rdp-html5']: + data = server.get_rdp_console(parsed_args.url_type) + if parsed_args.url_type in ['serial']: + data = server.get_serial_console(parsed_args.url_type) + if parsed_args.url_type in ['webmks']: + data = server.get_mks_console() if not data: return ({}, {}) diff --git a/openstackclient/tests/compute/v2/test_console.py b/openstackclient/tests/compute/v2/test_console.py index 6be081263..fe4f26ae9 100644 --- a/openstackclient/tests/compute/v2/test_console.py +++ b/openstackclient/tests/compute/v2/test_console.py @@ -147,3 +147,50 @@ class TestConsoleUrlShow(TestConsole): old_fake_server.get_vnc_console.assert_called_once_with('novnc') self.assertEqual(old_columns, columns) self.assertEqual(old_data, data) + + def test_console_url_show_with_rdp(self): + arglist = [ + '--rdp', + 'foo_vm', + ] + verifylist = [ + ('url_type', 'rdp-html5'), + ('server', 'foo_vm'), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + columns, data = self.cmd.take_action(parsed_args) + self.fake_server.get_rdp_console.assert_called_once_with( + 'rdp-html5') + self.assertEqual(self.columns, columns) + self.assertEqual(self.data, data) + + def test_console_url_show_with_serial(self): + arglist = [ + '--serial', + 'foo_vm', + ] + verifylist = [ + ('url_type', 'serial'), + ('server', 'foo_vm'), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + columns, data = self.cmd.take_action(parsed_args) + self.fake_server.get_serial_console.assert_called_once_with( + 'serial') + self.assertEqual(self.columns, columns) + self.assertEqual(self.data, data) + + def test_console_url_show_with_mks(self): + arglist = [ + '--mks', + 'foo_vm', + ] + verifylist = [ + ('url_type', 'webmks'), + ('server', 'foo_vm'), + ] + parsed_args = self.check_parser(self.cmd, arglist, verifylist) + columns, data = self.cmd.take_action(parsed_args) + self.fake_server.get_mks_console.assert_called_once_with() + self.assertEqual(self.columns, columns) + self.assertEqual(self.data, data) diff --git a/releasenotes/notes/bug-1605088-fea9347336764469.yaml b/releasenotes/notes/bug-1605088-fea9347336764469.yaml new file mode 100644 index 000000000..15e0bc455 --- /dev/null +++ b/releasenotes/notes/bug-1605088-fea9347336764469.yaml @@ -0,0 +1,4 @@ +--- +features: + - Support to get server ``rdp``, ``serial``, ``mks`` type console url. + [Bug `1605088 `_]