예제 #1
0
파일: server.py 프로젝트: airshipit/armada
def create(enable_middleware=CONF.middleware):
    """Entry point for initializing Armada server.

    :param enable_middleware: Whether to enable middleware.
    :type enable_middleware: bool
    """

    if enable_middleware:
        api = falcon.API(
            request_type=ArmadaRequest,
            middleware=[
                AuthMiddleware(),
                ContextMiddleware(),
                LoggingMiddleware(),
            ])
    else:
        api = falcon.API(request_type=ArmadaRequest)

    logging.set_defaults(default_log_levels=CONF.default_log_levels)
    logging.setup(CONF, 'armada')

    # Configure API routing
    url_routes_v1 = [
        (HEALTH_PATH, Health()),
        ('apply', Apply()),
        ('releases', Releases()),
        # TODO: Remove this in follow on release after Shipyard has
        # been updated to no longer depend on it.
        ('status', Status()),
        ('tests', TestReleasesManifestController()),
        ('test/{namespace}/{release}', TestReleasesReleaseNameController()),
        ('validatedesign', Validate()),
        (METRICS_PATH, Metrics()),
    ]

    for route, service in url_routes_v1:
        api.add_route("/api/v1.0/{}".format(route), service)
    api.add_route('/versions', Versions())

    # Initialize policy config options.
    policy.Enforcer(CONF)

    # Error handlers (FILO handling)
    api.add_error_handler(Exception, exceptions.default_exception_handler)
    api.add_error_handler(
        exceptions.ArmadaAPIException, exceptions.ArmadaAPIException.handle)

    # Built-in error serializer
    api.set_error_serializer(exceptions.default_error_serializer)

    return api
예제 #2
0
def create(enable_middleware=CONF.middleware):
    """Entry point for initializing Armada server.

    :param enable_middleware: Whether to enable middleware.
    :type enable_middleware: bool
    """

    if enable_middleware:
        api = falcon.API(request_type=ArmadaRequest,
                         middleware=[
                             AuthMiddleware(),
                             ContextMiddleware(),
                             LoggingMiddleware(),
                         ])
    else:
        api = falcon.API(request_type=ArmadaRequest)

    logging.set_defaults(default_log_levels=CONF.default_log_levels)
    logging.setup(CONF, 'armada')

    # Configure API routing
    url_routes_v1 = (
        ('health', Health()),
        ('apply', Apply()),
        ('releases', Release()),
        ('rollback/{release}', Rollback()),
        ('status', Status()),
        ('tests', TestReleasesManifestController()),
        ('test/{release}', TestReleasesReleaseNameController()),
        ('validatedesign', Validate()),
    )

    for route, service in url_routes_v1:
        api.add_route("/api/v1.0/{}".format(route), service)
    api.add_route('/versions', Versions())

    # Initialize policy config options.
    policy.Enforcer(CONF)

    # Error handlers (FILO handling)
    api.add_error_handler(exceptions.ArmadaBaseException,
                          exceptions.default_exception_handler)
    api.add_error_handler(exceptions.ArmadaAPIException,
                          exceptions.ArmadaAPIException.handle)

    # Built-in error serializer
    api.set_error_serializer(exceptions.default_error_serializer)

    return api
예제 #3
0
def create(enable_middleware=CONF.middleware):
    """Entry point for intializing Armada server.

    :param enable_middleware: Whether to enable middleware.
    :type enable_middleware: bool
    """

    if enable_middleware:
        api = falcon.API(request_type=ArmadaRequest,
                         middleware=[
                             AuthMiddleware(),
                             LoggingMiddleware(),
                             ContextMiddleware()
                         ])
    else:
        api = falcon.API(request_type=ArmadaRequest)

    logging.set_defaults(default_log_levels=CONF.default_log_levels)
    logging.setup(CONF, 'armada')

    # Configure API routing
    url_routes_v1 = (
        ('health', Health()),
        ('apply', Apply()),
        ('releases', Release()),
        ('status', Status()),
        ('tests', Tests()),
        ('test/{release}', Test()),
        ('validatedesign', Validate()),
    )

    for route, service in url_routes_v1:
        api.add_route("/api/v1.0/{}".format(route), service)
    api.add_route('/versions', Versions())

    # Initialize policy config options.
    policy.Enforcer(CONF)

    return api