Add support for get_spice_console RPC API
Add the new get_spice_console API mirroring the impl of the existing get_vnc_console support. Blueprint: libvirt-spice Change-Id: Id549de57ebbed95dc01749838ed539b3b47efc8b Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
020ff909cc
commit
5b8099cd0e
@ -119,6 +119,7 @@ You'll find complete documentation on the shell by running
|
||||
floating-ip-pool-list
|
||||
List all floating ip pools.
|
||||
get-vnc-console Get a vnc console to a server.
|
||||
get-spice-console Get a spice console to a server.
|
||||
host-action Perform a power action on a host.
|
||||
host-update Update host settings.
|
||||
image-create Create a new image by taking a snapshot of a running
|
||||
|
@ -66,6 +66,14 @@ class Server(base.Resource):
|
||||
"""
|
||||
return self.manager.get_vnc_console(self, console_type)
|
||||
|
||||
def get_spice_console(self, console_type):
|
||||
"""
|
||||
Get spice console for a Server.
|
||||
|
||||
:param console_type: Type of console ('spice-html5')
|
||||
"""
|
||||
return self.manager.get_spice_console(self, console_type)
|
||||
|
||||
def get_password(self, private_key):
|
||||
"""
|
||||
Get password for a Server.
|
||||
@ -397,6 +405,17 @@ class ServerManager(local_base.BootingManagerWithFind):
|
||||
return self._action('os-getVNCConsole', server,
|
||||
{'type': console_type})[1]
|
||||
|
||||
def get_spice_console(self, server, console_type):
|
||||
"""
|
||||
Get a spice console for an instance
|
||||
|
||||
:param server: The :class:`Server` (or its ID) to add an IP to.
|
||||
:param console_type: Type of spice console to get ('spice-html5')
|
||||
"""
|
||||
|
||||
return self._action('os-getSPICEConsole', server,
|
||||
{'type': console_type})[1]
|
||||
|
||||
def get_password(self, server, private_key):
|
||||
"""
|
||||
Get password for an instance
|
||||
|
@ -1512,6 +1512,23 @@ def do_get_vnc_console(cs, args):
|
||||
utils.print_list([VNCConsole(data['console'])], ['Type', 'Url'])
|
||||
|
||||
|
||||
@utils.arg('server', metavar='<server>', help='Name or ID of server.')
|
||||
@utils.arg('console_type',
|
||||
metavar='<console-type>',
|
||||
help='Type of spice console ("spice-html5").')
|
||||
def do_get_spice_console(cs, args):
|
||||
"""Get a spice console to a server."""
|
||||
server = _find_server(cs, args.server)
|
||||
data = server.get_spice_console(args.console_type)
|
||||
|
||||
class SPICEConsole:
|
||||
def __init__(self, console_dict):
|
||||
self.type = console_dict['type']
|
||||
self.url = console_dict['url']
|
||||
|
||||
utils.print_list([SPICEConsole(data['console'])], ['Type', 'Url'])
|
||||
|
||||
|
||||
@utils.arg('server', metavar='<server>', help='Name or ID of server.')
|
||||
@utils.arg('private_key',
|
||||
metavar='<private-key>',
|
||||
|
@ -479,6 +479,8 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
return (202, {}, {'output': 'foo'})
|
||||
elif action == 'os-getVNCConsole':
|
||||
assert body[action].keys() == ['type']
|
||||
elif action == 'os-getSPICEConsole':
|
||||
assert body[action].keys() == ['type']
|
||||
elif action == 'os-migrateLive':
|
||||
assert set(body[action].keys()) == set(['host',
|
||||
'block_migration',
|
||||
|
@ -370,6 +370,14 @@ class ServersTest(utils.TestCase):
|
||||
cs.servers.get_vnc_console(s, 'fake')
|
||||
cs.assert_called('POST', '/servers/1234/action')
|
||||
|
||||
def test_get_spice_console(self):
|
||||
s = cs.servers.get(1234)
|
||||
s.get_spice_console('fake')
|
||||
cs.assert_called('POST', '/servers/1234/action')
|
||||
|
||||
cs.servers.get_spice_console(s, 'fake')
|
||||
cs.assert_called('POST', '/servers/1234/action')
|
||||
|
||||
def test_create_image(self):
|
||||
s = cs.servers.get(1234)
|
||||
s.create_image('123')
|
||||
|
Loading…
x
Reference in New Issue
Block a user