Add server.get_vnc_console functionality to python-novaclient
Change-Id: I8784161ba0ff5adff10045097ed691246bee6e63
This commit is contained in:
parent
559949c9b0
commit
2c6c34dd11
@ -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
|
||||
|
@ -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.
|
||||
|
@ -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'])
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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')
|
||||
|
Loading…
x
Reference in New Issue
Block a user