Merge "add new command get-serial-console"

This commit is contained in:
Jenkins 2014-09-17 15:09:22 +00:00 committed by Gerrit Code Review
commit b8ad231654
4 changed files with 51 additions and 0 deletions

View File

@ -457,6 +457,8 @@ class V1(Base):
assert list(body[action]) == ['type']
elif action == 'os-getRDPConsole':
assert list(body[action]) == ['type']
elif action == 'os-getSerialConsole':
assert list(body[action]) == ['type']
elif action == 'os-migrateLive':
assert set(body[action].keys()) == set(['host',
'block_migration',
@ -568,6 +570,7 @@ class V3(Base):
'get_console_output': ['length'],
'get_vnc_console': ['type'],
'get_spice_console': ['type'],
'get_serial_console': ['type'],
'reset_state': ['state'],
'create_image': ['name', 'metadata'],
'migrate_live': ['host', 'block_migration', 'disk_over_commit'],

View File

@ -548,6 +548,14 @@ class ServersTest(utils.FixturedTestCase):
self.cs.servers.get_spice_console(s, 'fake')
self.assert_called('POST', '/servers/1234/action')
def test_get_serial_console(self):
s = self.cs.servers.get(1234)
s.get_serial_console('fake')
self.assert_called('POST', '/servers/1234/action')
self.cs.servers.get_serial_console(s, 'fake')
self.assert_called('POST', '/servers/1234/action')
def test_get_rdp_console(self):
s = self.cs.servers.get(1234)
s.get_rdp_console('fake')

View File

@ -86,6 +86,14 @@ class Server(base.Resource):
"""
return self.manager.get_rdp_console(self, console_type)
def get_serial_console(self, console_type):
"""
Get serial console for a Server.
:param console_type: Type of console ('serial')
"""
return self.manager.get_serial_console(self, console_type)
def get_password(self, private_key=None):
"""
Get password for a Server.
@ -675,6 +683,17 @@ class ServerManager(base.BootingManagerWithFind):
return self._action('os-getRDPConsole', server,
{'type': console_type})[1]
def get_serial_console(self, server, console_type):
"""
Get a serial console for an instance
:param server: The :class:`Server` (or its ID) to add an IP to.
:param console_type: Type of serial console to get ('serial')
"""
return self._action('os-getSerialConsole', server,
{'type': console_type})[1]
def get_password(self, server, private_key=None):
"""
Get password for an instance

View File

@ -2040,6 +2040,27 @@ def do_get_rdp_console(cs, args):
utils.print_list([RDPConsole(data['console'])], ['Type', 'Url'])
@utils.arg('server', metavar='<server>', help=_('Name or ID of server.'))
@utils.arg('--console_type', default='serial',
help=_('Type of serial console, default="serial".'))
def do_get_serial_console(cs, args):
"""Get a serial console to a server."""
if args.console_type not in ('serial',):
raise exceptions.CommandError(
_("Invalid parameter value for 'console_type', "
"currently supported 'serial'."))
server = _find_server(cs, args.server)
data = server.get_serial_console(args.console_type)
class SerialConsole:
def __init__(self, console_dict):
self.type = console_dict['type']
self.url = console_dict['url']
utils.print_list([SerialConsole(data['console'])], ['Type', 'Url'])
@utils.arg('server', metavar='<server>', help='Name or ID of server.')
@utils.arg('private_key',
metavar='<private-key>',