Merge "Adds support for the get_rdp_console API"

This commit is contained in:
Jenkins 2014-02-15 05:03:58 +00:00 committed by Gerrit Code Review
commit 0042874812
5 changed files with 63 additions and 0 deletions

@ -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',

@ -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')

@ -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

@ -1871,6 +1871,23 @@ def do_get_spice_console(cs, args):
utils.print_list([SPICEConsole(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 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>',

@ -1478,6 +1478,23 @@ def do_get_spice_console(cs, args):
utils.print_list([SPICEConsole(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 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>',