Beispiel #1
0
def get_external_proxy_host_port():
    """Returns connection details for access from outside the cluster, via proxy if enabled"""
    db_proxy_provider = db_proxy_manager.get_provider(required=False)
    if db_proxy_provider:
        host, port = db_proxy_provider.get_external_proxy_host_port()
        if host and port:
            return host, port
    return get_provider().get_postgres_external_host_port()
Beispiel #2
0
def get_internal_proxy_host_port():
    """Returns connection details for internal cluster access, via proxy if enabled"""
    db_proxy_provider = db_proxy_manager.get_provider(required=False)
    if db_proxy_provider:
        db_host, db_port = db_proxy_provider.get_internal_proxy_host_port()
    else:
        db_provider_manager = get_provider()
        db_host, db_port = db_provider_manager.get_postgres_internal_host_port(
        )
    return db_host, db_port
Beispiel #3
0
def get_external_proxy_host_port(db_prefix=None):
    """Returns connection details for access from outside the cluster, via proxy if enabled"""
    from .gcloudsql.manager import _credentials_get

    is_private_ip = _credentials_get(db_prefix,
                                     key='is-private-ip',
                                     required=False) == 'y'
    if not is_private_ip:
        return get_provider().get_postgres_external_host_port(
            db_prefix=db_prefix)
    db_proxy_provider = db_proxy_manager.get_provider(required=False)
    assert db_proxy_provider, "SQL instance has private IP, so direct access to the DB is not supported, please enable the db proxy"
    host, port = db_proxy_provider.get_external_proxy_host_port(
        db_prefix=db_prefix)
    return (host, port) if host and port else get_provider(
    ).get_postgres_external_host_port(db_prefix=db_prefix)