示例#1
0
def get_es_conn():
    """Return an Elasticsearch ConnectionContext."""
    cm = ConfigurationManager(
        ConnectionContext.get_required_config(), values_source_list=[environment]
    )
    config = cm.get_config()
    return ConnectionContext(config)
示例#2
0
def get_conn():
    # Create a configuration manager that will only check the environment for
    # configuration and not command line parameters

    cm = ConfigurationManager(ConnectionContext.get_required_config(),
                              values_source_list=[environment])
    config = cm.get_config()
    return ConnectionContext(config)
示例#3
0
def es_conn():
    """Create an Elasticsearch ConnectionContext and clean up indices afterwards."""
    cm = ConfigurationManager(ConnectionContext.get_required_config(),
                              values_source_list=[environment])
    config = cm.get_config()
    conn = ConnectionContext(config)
    yield conn
    for index in conn.get_indices():
        conn.delete_index(index)
示例#4
0
文件: es.py 项目: mozilla/socorro
def get_conn():
    # Create a configuration manager that will only check the environment for
    # configuration and not command line parameters

    cm = ConfigurationManager(
        ConnectionContext.get_required_config(),
        values_source_list=[environment]
    )
    config = cm.get_config()
    return ConnectionContext(config)
示例#5
0
def es_conn():
    """Create an Elasticsearch ConnectionContext and clean up indices afterwards."""
    cm = ConfigurationManager(
        ConnectionContext.get_required_config(),
        values_source_list=[environment]
    )
    config = cm.get_config()
    conn = ConnectionContext(config)
    yield conn
    for index in conn.get_indices():
        conn.delete_index(index)
示例#6
0
def es_conn():
    """Create an Elasticsearch ConnectionContext and clean up indices afterwards.

    This uses defaults and configuration from the environment.

    """
    manager = ConfigurationManager(ESConnectionContext.get_required_config(),
                                   values_source_list=[environment])
    conn = ESConnectionContext(manager.get_config())

    # Create two indexes--this week and last week
    template = conn.config.elasticsearch_index
    conn.create_index(utc_now().strftime(template))
    conn.create_index(
        (utc_now() - datetime.timedelta(weeks=1)).strftime(template))
    conn.health_check()

    yield conn
    for index in conn.get_indices():
        conn.delete_index(index)