예제 #1
0
def setup():

    global app, backend

    # initialize flask application
    app = Flask(__name__)
    Api(app)

    # load application configuration file is exists
    config_file_path = os.environ.get('HOST_POOL_SERVICE_CONFIG_PATH')
    if config_file_path:
        utils.write_to_log('service.setup', "config_file_path {0}".format(config_file_path))
        with open(config_file_path) as f:
            yaml_conf = yaml.load(f.read())
            config.configure(yaml_conf)
        utils.write_to_log('service.setup', "config_file_path {0} after configure".format(config_file_path))
    else:
        utils.write_to_log('service.setup', "Failed loading application: " \
              "HOST_POOL_SERVICE_CONFIG_PATH environment variable is not defined. " \
              "Use this variable to point to the application configuration file ")
        raise exceptions.ConfigurationError(
            'Failed loading application: '
            'HOST_POOL_SERVICE_CONFIG_PATH environment '
            'variable is not defined. Use this variable to '
            'point to the application configuration file ')

    # initialize application backend
    backend = rest_backend.RestBackend(pool=config.get().pool)
예제 #2
0
def setup():

    global app, backend

    # initialize flask application
    app = Flask(__name__)
    Api(app)

    # load application configuration file is exists
    config_file_path = os.environ.get('HOST_POOL_SERVICE_CONFIG_PATH')
    if config_file_path:
        with open(config_file_path) as f:
            yaml_conf = yaml.load(f.read())
            config.configure(yaml_conf)
    else:
        raise exceptions.ConfigurationError(
            'Failed loading application: '
            'HOST_POOL_SERVICE_CONFIG_PATH environment '
            'variable is not defined. Use this variable to '
            'point to the application configuration file ')

    # initialize application backend
    backend = rest_backend.RestBackend(pool=config.get().pool)
예제 #3
0
def reset_backend():
    global app, backend
    # initialize application backend
    backend = rest_backend.RestBackend(pool=config.get().pool)