'Acquire serial console information.
:param context: request context
:param instance: nova instance
:return: ConsoleSerial object
:raise ConsoleTypeUnavailable: if serial console is unavailable
for the instance'

def get_serial_console(self, context, instance):

    LOG.debug('Getting    serial    console', instance=instance)
    try:
        result = self._get_node_console_with_reset(instance)
    except exception.ConsoleNotAvailable:
        raise exception.ConsoleTypeUnavailable(console_type='serial')
    node = result['node']
    console_info = result['console_info']
    if (console_info['type'] != 'socat'):
        LOG.warning('Console    type    "%(type)s"    (of    ironic    node    %(node)s)    does    not    support    Nova    serial    console', {'type': console_info['type'], 'node': node.uuid}, instance=instance)
        raise exception.ConsoleTypeUnavailable(console_type='serial')
    url = urlparse.urlparse(console_info['url'])
    try:
        scheme = url.scheme
        hostname = url.hostname
        port = url.port
        if (not (scheme and hostname and port)):
            raise AssertionError()
    except (ValueError, AssertionError):
        LOG.error('Invalid    Socat    console    URL    "%(url)s"    (ironic    node    %(node)s)', {'url': console_info['url'], 'node': node.uuid}, instance=instance)
        raise exception.ConsoleTypeUnavailable(console_type='serial')
    if (scheme == 'tcp'):
        return console_type.ConsoleSerial(host=hostname, port=port)
    else:
        LOG.warning('Socat    serial    console    only    supports    "tcp".    This    URL    is    "%(url)s"    (ironic    node    %(node)s).', {'url': console_info['url'], 'node': node.uuid}, instance=instance)
        raise exception.ConsoleTypeUnavailable(console_type='serial')
