summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.rst1
-rw-r--r--novaclient/v1_1/servers.py19
-rw-r--r--novaclient/v1_1/shell.py17
-rw-r--r--tests/v1_1/fakes.py2
-rw-r--r--tests/v1_1/test_servers.py8
5 files changed, 47 insertions, 0 deletions
diff --git a/README.rst b/README.rst
index 407ac52e..8640d376 100644
--- a/README.rst
+++ b/README.rst
@@ -90,6 +90,7 @@ You'll find complete documentation on the shell by running
floating-ip-list List allocated floating IPs for the current tenant.
floating-ip-pool-list
List all floating ip pools.
+ get-vnc-console Get a vnc console for a server
help Display help about this program or one of its
subcommands.
image-create Create a new image by taking a snapshot of a running
diff --git a/novaclient/v1_1/servers.py b/novaclient/v1_1/servers.py
index 1fa77da3..59bc602e 100644
--- a/novaclient/v1_1/servers.py
+++ b/novaclient/v1_1/servers.py
@@ -55,6 +55,14 @@ class Server(base.Resource):
"""
return self.manager.get_console_output(self, length)
+ def get_vnc_console(self, console_type):
+ """
+ Get vnc console for a Server.
+
+ :param console_type: Type of console ('novnc' or 'xvpvnc')
+ """
+ return self.manager.get_vnc_console(self, console_type)
+
def add_fixed_ip(self, network_id):
"""
Add an IP address on a network.
@@ -286,6 +294,17 @@ class ServerManager(local_base.BootingManagerWithFind):
address = address.ip if hasattr(address, 'ip') else address
self._action('removeFloatingIp', server, {'address': address})
+ def get_vnc_console(self, server, console_type):
+ """
+ Get a vnc console for an instance
+
+ :param server: The :class:`Server` (or its ID) to add an IP to.
+ :param console_type: Type of vnc console to get ('novnc' or 'xvpvnc')
+ """
+
+ return self._action('os-getVNCConsole', server,
+ {'type': console_type})[1]
+
def pause(self, server):
"""
Pause the server.
diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py
index 9d9cb540..9086cbcf 100644
--- a/novaclient/v1_1/shell.py
+++ b/novaclient/v1_1/shell.py
@@ -964,6 +964,23 @@ def do_volume_snapshot_delete(cs, args):
snapshot.delete()
+@utils.arg('server', metavar='<server>', help='Name or ID of server.')
+@utils.arg('console_type',
+ metavar='<console_type>',
+ help='Type of vnc console ("novnc" or "xvpvnc").')
+def do_get_vnc_console(cs, args):
+ """Get a vnc console to a server."""
+ server = _find_server(cs, args.server)
+ data = server.get_vnc_console(args.console_type)
+
+ class VNCConsole:
+ def __init__(self, console_dict):
+ self.type = console_dict['type']
+ self.url = console_dict['url']
+
+ utils.print_list([VNCConsole(data['console'])], ['Type', 'Url'])
+
+
def _print_floating_ip_list(floating_ips):
utils.print_list(floating_ips, ['Ip', 'Instance Id', 'Fixed Ip', 'Pool'])
diff --git a/tests/v1_1/fakes.py b/tests/v1_1/fakes.py
index 4f0085d0..a17748d0 100644
--- a/tests/v1_1/fakes.py
+++ b/tests/v1_1/fakes.py
@@ -323,6 +323,8 @@ class FakeHTTPClient(base_client.HTTPClient):
elif action == 'os-getConsoleOutput':
assert body[action].keys() == ['length']
return (202, {'output': 'foo'})
+ elif action == 'os-getVNCConsole':
+ assert body[action].keys() == ['type']
else:
raise AssertionError("Unexpected server action: %s" % action)
return (202, _body)
diff --git a/tests/v1_1/test_servers.py b/tests/v1_1/test_servers.py
index fa4e9dfa..f5ca8c01 100644
--- a/tests/v1_1/test_servers.py
+++ b/tests/v1_1/test_servers.py
@@ -247,3 +247,11 @@ class ServersTest(utils.TestCase):
cs.assert_called('GET', '/servers/1234/diagnostics')
self.assertEqual(diagnostics, diagnostics_from_manager)
+
+ def test_get_vnc_console(self):
+ s = cs.servers.get(1234)
+ s.get_vnc_console('fake')
+ cs.assert_called('POST', '/servers/1234/action')
+
+ cs.servers.get_vnc_console(s, 'fake')
+ cs.assert_called('POST', '/servers/1234/action')