예제 #1
0
def write_genapi_base_tpl(python_interpreter, genapi_start, logging_level, riak_host, app_port,
                          genapi_api_id, genapi_version, genapi_env, genapi_entity_list, genapi_api_key,
                          genapi_home_directory, genapi_user, genapi_log_file, config_file_name):
    """
        Write a configuration file for a given API that will be readable by supervisord.
    """
    # Load the template
    template = load_template(GENAPI_TEMPLATES_CONFIG['GENAPI_BASE']['GENAPI_BASE_TEMPLATE'])

    # Render the template with substituted values
    tpl = template.render(
        genapi_api_id=genapi_api_id,
        python_interpreter=python_interpreter,
        genapi_start=genapi_start,
        logging_level=logging_level,
        riak_host=riak_host,
        app_port=app_port,
        genapi_version=genapi_version,
        genapi_env=genapi_env,
        genapi_entity_list=entity_list_as_csv(genapi_entity_list),
        genapi_api_key=genapi_api_key,
        genapi_home_directory=genapi_home_directory,
        genapi_user=genapi_user,
        genapi_log_file=genapi_log_file
    )

    # And write the template.
    logger.debug("Writing template: {}".format(tpl))
    filesystem_service.write_file(filename=config_file_name, content=tpl)
    logger.info('Supervisor configuration file written for API with id: {}'.format(genapi_api_id))
예제 #2
0
def write_genapi_base_tpl(python_interpreter, genapi_start, logging_level,
                          riak_host, app_port, genapi_api_id, genapi_version,
                          genapi_env, genapi_entity_list, genapi_api_key,
                          genapi_home_directory, genapi_user, genapi_log_file,
                          config_file_name):
    """
        Write a configuration file for a given API that will be readable by supervisord.
    """
    # Load the template
    template = load_template(
        GENAPI_TEMPLATES_CONFIG['GENAPI_BASE']['GENAPI_BASE_TEMPLATE'])

    # Render the template with substituted values
    tpl = template.render(
        genapi_api_id=genapi_api_id,
        python_interpreter=python_interpreter,
        genapi_start=genapi_start,
        logging_level=logging_level,
        riak_host=riak_host,
        app_port=app_port,
        genapi_version=genapi_version,
        genapi_env=genapi_env,
        genapi_entity_list=entity_list_as_csv(genapi_entity_list),
        genapi_api_key=genapi_api_key,
        genapi_home_directory=genapi_home_directory,
        genapi_user=genapi_user,
        genapi_log_file=genapi_log_file)

    # And write the template.
    logger.debug("Writing template: {}".format(tpl))
    filesystem_service.write_file(filename=config_file_name, content=tpl)
    logger.info(
        'Supervisor configuration file written for API with id: {}'.format(
            genapi_api_id))
예제 #3
0
def write_genapi_backends_tpl(config_file_name, api_id, api_host, api_port):
    """
        Write the haproxy backends part for an already deployed API in order
        to create the routing (part 1) on the loadbalancer.
    """
    # Load the template
    template = load_template(GENAPI_TEMPLATES_CONFIG['GENAPI_BACKENDS']['GENAPI_BACKENDS_TEMPLATE'])

    # Render the template with substituted values
    tpl = template.render(api_id=api_id, api_host=api_host, api_port=api_port)

    # And write the template.
    logger.debug("Writing template: {}".format(tpl))
    filesystem_service.write_file(filename=config_file_name, content=tpl)
    logger.info('Loadbalancer (haproxy) BACKENDS configuration written for API with id: {}'.format(api_id))
예제 #4
0
def write_genapi_backends_tpl(config_file_name, api_id, api_host, api_port):
    """
        Write the haproxy backends part for an already deployed API in order
        to create the routing (part 1) on the loadbalancer.
    """
    # Load the template
    template = load_template(
        GENAPI_TEMPLATES_CONFIG['GENAPI_BACKENDS']['GENAPI_BACKENDS_TEMPLATE'])

    # Render the template with substituted values
    tpl = template.render(api_id=api_id, api_host=api_host, api_port=api_port)

    # And write the template.
    logger.debug("Writing template: {}".format(tpl))
    filesystem_service.write_file(filename=config_file_name, content=tpl)
    logger.info(
        'Loadbalancer (haproxy) BACKENDS configuration written for API with id: {}'
        .format(api_id))
예제 #5
0
def test_writer_file():
    write_file(filename='{}.conf'.format(API_ID), content=tpl)
    assert os.path.exists('{}.conf'.format(API_ID))
예제 #6
0
def test_writer_file():
    write_file(filename='{}.conf'.format(API_ID), content=tpl)
    assert os.path.exists('{}.conf'.format(API_ID))