'Returns a list of oslo.messaging.TransportHost objects.'

def _create_transport_hosts(self, username, password, broker_hosts=None, hostname=None, port=None):

    transport_hosts = []
    if broker_hosts:
        hosts = broker_hosts.split(',')
        for host in hosts:
            host = host.strip()
            (broker_hostname, broker_port) = utils.parse_server_string(host)
            if (not broker_port):
                msg = (_('Invalid    broker_hosts    value:    %s.    It    should    be    in    hostname:port    format') % host)
                raise ValueError(msg)
            try:
                broker_port = int(broker_port)
            except ValueError:
                msg = (_('Invalid    port    value:    %s.    It    should    be    an    integer') % broker_port)
                raise ValueError(msg)
            transport_hosts.append(messaging.TransportHost(hostname=broker_hostname, port=broker_port, username=username, password=password))
    else:
        try:
            port = int(port)
        except ValueError:
            msg = (_('Invalid    port    value:    %s.    Should    be    an    integer') % port)
            raise ValueError(msg)
        transport_hosts.append(messaging.TransportHost(hostname=hostname, port=port, username=username, password=password))
    return transport_hosts
