Return the ZeroMQ URI to connect the Minion to the Master.
    It supports different source IP / port, given the ZeroMQ syntax:
    // Connecting using a IP address and bind to an IP address
    rc = zmq_connect(socket, "tcp://192.168.1.17:5555;192.168.1.1:5555"); assert (rc == 0);
    Source: http://api.zeromq.org/4-1:zmq-tcp

def _get_master_uri(master_ip,
                    master_port,
                    source_ip=None,
                    source_port=None):
    '''
    Return the ZeroMQ URI to connect the Minion to the Master.
    It supports different source IP / port, given the ZeroMQ syntax:
    // Connecting using a IP address and bind to an IP address
    rc = zmq_connect(socket, "tcp://192.168.1.17:5555;192.168.1.1:5555"); assert (rc == 0);
    Source: http://api.zeromq.org/4-1:zmq-tcp
    '''
    from salt.utils.zeromq import ip_bracket

    master_uri = 'tcp://{master_ip}:{master_port}'.format(
                  master_ip=ip_bracket(master_ip), master_port=master_port)

    if source_ip or source_port:
        if LIBZMQ_VERSION_INFO >= (4, 1, 6) and ZMQ_VERSION_INFO >= (16, 0, 1):
            # The source:port syntax for ZeroMQ has been added in libzmq 4.1.6
            # which is included in the pyzmq wheels starting with 16.0.1.
            if source_ip and source_port:
                master_uri = 'tcp://{source_ip}:{source_port};{master_ip}:{master_port}'.format(
                             source_ip=ip_bracket(source_ip), source_port=source_port,
                             master_ip=ip_bracket(master_ip), master_port=master_port)
            elif source_ip and not source_port:
                master_uri = 'tcp://{source_ip}:0;{master_ip}:{master_port}'.format(
                             source_ip=ip_bracket(source_ip),
                             master_ip=ip_bracket(master_ip), master_port=master_port)
            elif source_port and not source_ip:
                ip_any = '0.0.0.0' if ipaddress.ip_address(master_ip).version == 4 else ip_bracket('::')
                master_uri = 'tcp://{ip_any}:{source_port};{master_ip}:{master_port}'.format(
                             ip_any=ip_any, source_port=source_port,
                             master_ip=ip_bracket(master_ip), master_port=master_port)
        else:
            log.warning('Unable to connect to the Master using a specific source IP / port')
            log.warning('Consider upgrading to pyzmq >= 16.0.1 and libzmq >= 4.1.6')
            log.warning('Specific source IP / port for connecting to master returner port: configuraion ignored')

    return master_uri