summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessandro Pilotti <apilotti@cloudbasesolutions.com>2013-08-29 12:25:57 +0300
committerGerrit Code Review <review@openstack.org>2014-02-08 20:15:37 +0000
commit55249f777cc13e7e6cf3440023cf543ccdca176d (patch)
tree4e9e2d6815cbfadbd76a64ac6eaa45eaeb15c561
parent810857849ed32773c38df12785715f89d33e83af (diff)
downloadpython-novaclient-55249f777cc13e7e6cf3440023cf543ccdca176d.tar.gz
Adds support for the get_rdp_console API
Hyper-V employs RDP to access virtual machine consoles, unlike most other hypervisors which support VNC. In order to support this scenario, the get_rdp_console API has been added to Nova. This commit adds the corresponding client side feature, implemented in a way consistent with existing VNC and SPICE console support. Nova Gerrit commit: https://review.openstack.org/#/c/43502/ Change-Id: I86b814797d234f1eb49a7fa67ed27a9bcda034ae Implements: blueprint hyper-v-rdp-console
-rw-r--r--novaclient/tests/v1_1/fakes.py2
-rw-r--r--novaclient/tests/v1_1/test_servers.py8
-rw-r--r--novaclient/v1_1/servers.py19
-rw-r--r--novaclient/v1_1/shell.py17
-rw-r--r--novaclient/v3/shell.py17
5 files changed, 63 insertions, 0 deletions
diff --git a/novaclient/tests/v1_1/fakes.py b/novaclient/tests/v1_1/fakes.py
index d00dd078..e10b8eb6 100644
--- a/novaclient/tests/v1_1/fakes.py
+++ b/novaclient/tests/v1_1/fakes.py
@@ -598,6 +598,8 @@ class FakeHTTPClient(base_client.HTTPClient):
assert list(body[action]) == ['type']
elif action == 'os-getSPICEConsole':
assert list(body[action]) == ['type']
+ elif action == 'os-getRDPConsole':
+ assert list(body[action]) == ['type']
elif action == 'os-migrateLive':
assert set(body[action].keys()) == set(['host',
'block_migration',
diff --git a/novaclient/tests/v1_1/test_servers.py b/novaclient/tests/v1_1/test_servers.py
index ac30df18..a48204c1 100644
--- a/novaclient/tests/v1_1/test_servers.py
+++ b/novaclient/tests/v1_1/test_servers.py
@@ -510,6 +510,14 @@ class ServersTest(utils.TestCase):
cs.servers.get_spice_console(s, 'fake')
cs.assert_called('POST', '/servers/1234/action')
+ def test_get_rdp_console(self):
+ s = cs.servers.get(1234)
+ s.get_rdp_console('fake')
+ cs.assert_called('POST', '/servers/1234/action')
+
+ cs.servers.get_rdp_console(s, 'fake')
+ cs.assert_called('POST', '/servers/1234/action')
+
def test_create_image(self):
s = cs.servers.get(1234)
s.create_image('123')
diff --git a/novaclient/v1_1/servers.py b/novaclient/v1_1/servers.py
index 0553f140..0ae5d166 100644
--- a/novaclient/v1_1/servers.py
+++ b/novaclient/v1_1/servers.py
@@ -76,6 +76,14 @@ class Server(base.Resource):
"""
return self.manager.get_spice_console(self, console_type)
+ def get_rdp_console(self, console_type):
+ """
+ Get rdp console for a Server.
+
+ :param console_type: Type of console ('rdp-html5')
+ """
+ return self.manager.get_rdp_console(self, console_type)
+
def get_password(self, private_key=None):
"""
Get password for a Server.
@@ -644,6 +652,17 @@ class ServerManager(base.BootingManagerWithFind):
return self._action('os-getSPICEConsole', server,
{'type': console_type})[1]
+ def get_rdp_console(self, server, console_type):
+ """
+ Get a rdp console for an instance
+
+ :param server: The :class:`Server` (or its ID) to add an IP to.
+ :param console_type: Type of rdp console to get ('rdp-html5')
+ """
+
+ return self._action('os-getRDPConsole', server,
+ {'type': console_type})[1]
+
def get_password(self, server, private_key=None):
"""
Get password for an instance
diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py
index dbc77ad3..ae59bfcb 100644
--- a/novaclient/v1_1/shell.py
+++ b/novaclient/v1_1/shell.py
@@ -1872,6 +1872,23 @@ def do_get_spice_console(cs, args):
@utils.arg('server', metavar='<server>', help='Name or ID of server.')
+@utils.arg('console_type',
+ metavar='<console-type>',
+ help='Type of rdp console ("rdp-html5").')
+def do_get_rdp_console(cs, args):
+ """Get a rdp console to a server."""
+ server = _find_server(cs, args.server)
+ data = server.get_rdp_console(args.console_type)
+
+ class RDPConsole:
+ def __init__(self, console_dict):
+ self.type = console_dict['type']
+ self.url = console_dict['url']
+
+ utils.print_list([RDPConsole(data['console'])], ['Type', 'Url'])
+
+
+@utils.arg('server', metavar='<server>', help='Name or ID of server.')
@utils.arg('private_key',
metavar='<private-key>',
help='Private key (used locally to decrypt password) (Optional). '
diff --git a/novaclient/v3/shell.py b/novaclient/v3/shell.py
index 89062ee9..49c8768f 100644
--- a/novaclient/v3/shell.py
+++ b/novaclient/v3/shell.py
@@ -1479,6 +1479,23 @@ def do_get_spice_console(cs, args):
@utils.arg('server', metavar='<server>', help='Name or ID of server.')
+@utils.arg('console_type',
+ metavar='<console-type>',
+ help='Type of rdp console ("rdp-html5").')
+def do_get_rdp_console(cs, args):
+ """Get a rdp console to a server."""
+ server = _find_server(cs, args.server)
+ data = server.get_rdp_console(args.console_type)
+
+ class RDPConsole:
+ def __init__(self, console_dict):
+ self.type = console_dict['type']
+ self.url = console_dict['url']
+
+ utils.print_list([RDPConsole(data['console'])], ['Type', 'Url'])
+
+
+@utils.arg('server', metavar='<server>', help='Name or ID of server.')
@utils.arg('private_key',
metavar='<private-key>',
help='Private key (used locally to decrypt password) (Optional). '