def parse_port_text(port_text):
    """

    >>> slurm_ports = parse_port_text("8888/tcp -> 0.0.0.0:32769")
    >>> slurm_ports[8888]['host']
    '0.0.0.0'
    """
    ports = None
    if port_text is not None:
        ports = {}
        for line in port_text.strip().split('\n'):
            if ' -> ' not in line:
                raise Exception('Cannot parse host and port from line [%s]' %
                    line)
            tool, host = line.split(' -> ', 1)
            hostname, port = host.split(':')
            port = int(port)
            tool_p, tool_prot = tool.split('/')
            tool_p = int(tool_p)
            ports[tool_p] = dict(tool_port=tool_p, host=hostname, port=port,
                protocol=tool_prot)
    return ports
