Exemplo n.º 1
0
 def setUp(self):
     super(ApiEc2TestCase, self).setUp()
     self.host = '127.0.0.1'
     # NOTE(vish): skipping the Authorizer
     roles = ['sysadmin', 'netadmin']
     ctxt = context.RequestContext('fake', 'fake', roles=roles)
     self.app = auth.InjectContext(
         ctxt,
         ec2.Requestify(ec2.Authorizer(ec2.Executor()),
                        'nova.api.ec2.cloud.CloudController'))
Exemplo n.º 2
0
    def wrap(app, use_context=False):
        if v2_compatible:
            app = openstack_api.LegacyV2CompatibleWrapper(app)

        if use_context:
            if fake_auth_context is not None:
                ctxt = fake_auth_context
            else:
                ctxt = context.RequestContext(
                    'fake', FAKE_PROJECT_ID, auth_token=True)
            app = api_auth.InjectContext(ctxt, app)

        app = openstack_api.FaultWrapper(app)

        return app
Exemplo n.º 3
0
def wsgi_app_v21(fake_auth_context=None, v2_compatible=False):

    inner_app_v21 = compute.APIRouterV21()

    if v2_compatible:
        inner_app_v21 = openstack_api.LegacyV2CompatibleWrapper(inner_app_v21)

    if fake_auth_context is not None:
        ctxt = fake_auth_context
    else:
        ctxt = context.RequestContext('fake', 'fake', auth_token=True)
    api_v21 = openstack_api.FaultWrapper(
        api_auth.InjectContext(ctxt, inner_app_v21))
    mapper = urlmap.URLMap()
    mapper['/v2'] = api_v21
    mapper['/v2.1'] = api_v21
    mapper['/'] = openstack_api.FaultWrapper(versions.Versions())
    return mapper
Exemplo n.º 4
0
def wsgi_app_v21(inner_app_v21=None, fake_auth_context=None,
        use_no_auth=False, ext_mgr=None, init_only=None):
    if not inner_app_v21:
        inner_app_v21 = compute.APIRouterV21(init_only)

    if use_no_auth:
        api_v21 = openstack_api.FaultWrapper(auth.NoAuthMiddlewareV3(
              limits.RateLimitingMiddleware(inner_app_v21)))
    else:
        if fake_auth_context is not None:
            ctxt = fake_auth_context
        else:
            ctxt = context.RequestContext('fake', 'fake', auth_token=True)
        api_v21 = openstack_api.FaultWrapper(api_auth.InjectContext(ctxt,
              limits.RateLimitingMiddleware(inner_app_v21)))

    mapper = urlmap.URLMap()
    mapper['/v2'] = api_v21
    mapper['/v2.1'] = api_v21
    return mapper
Exemplo n.º 5
0
def wsgi_app(inner_app_v2=None, fake_auth_context=None,
        use_no_auth=False, ext_mgr=None):
    if not inner_app_v2:
        inner_app_v2 = compute.APIRouter(ext_mgr)

    if use_no_auth:
        api_v2 = openstack_api.FaultWrapper(auth.NoAuthMiddleware(
              limits.RateLimitingMiddleware(inner_app_v2)))
    else:
        if fake_auth_context is not None:
            ctxt = fake_auth_context
        else:
            ctxt = context.RequestContext('fake', 'fake', auth_token=True)
        api_v2 = openstack_api.FaultWrapper(api_auth.InjectContext(ctxt,
              limits.RateLimitingMiddleware(inner_app_v2)))

    mapper = urlmap.URLMap()
    mapper['/v2'] = api_v2
    mapper['/v1.1'] = api_v2
    mapper['/'] = openstack_api.FaultWrapper(versions.Versions())
    return mapper
Exemplo n.º 6
0
def wsgi_app_v3(inner_app_v3=None, fake_auth_context=None,
        use_no_auth=False, ext_mgr=None, init_only=None):
    if not inner_app_v3:
        inner_app_v3 = compute.APIRouterV3(init_only)

    if use_no_auth:
        api_v3 = openstack_api.FaultWrapper(auth.NoAuthMiddlewareV3(
              limits.RateLimitingMiddleware(inner_app_v3)))
    else:
        if fake_auth_context is not None:
            ctxt = fake_auth_context
        else:
            ctxt = context.RequestContext('fake', 'fake', auth_token=True)
        api_v3 = openstack_api.FaultWrapper(api_auth.InjectContext(ctxt,
              limits.RateLimitingMiddleware(inner_app_v3)))

    mapper = urlmap.URLMap()
    mapper['/v3'] = api_v3
    # TODO(cyeoh): bp nova-api-core-as-extensions
    # Still need to implement versions for v3 API
    #    mapper['/'] = openstack_api.FaultWrapper(versions.Versions())
    return mapper