コード例 #1
0
def tenants(request):
    if not request.user or not request.user.is_authenticated():
        return {}

    try:
        return {'tenants': api.token_list_tenants(request, request.user.token)}
    except api_exceptions.BadRequest, e:
        messages.error(request, "Unable to retrieve tenant list from\
                                  keystone: %s" % e.message)
        return {'tenants': []}
コード例 #2
0
ファイル: context_processors.py プロジェクト: dais/colony
def tenants(request):
    if not request.user or not request.user.is_authenticated():
        return {}

    try:
        return {'tenants': api.token_list_tenants(request, request.user.token)}
    except api_exceptions.BadRequest, e:
        messages.error(request, "Unable to retrieve tenant list from\
                                  keystone: %s" % e.message)
        return {'tenants': []}
コード例 #3
0
    def test_token_list_tenants(self):
        self.mox.StubOutWithMock(api, "auth_api")
        auth_api_mock = self.mox.CreateMockAnything()
        api.auth_api().AndReturn(auth_api_mock)

        tenants_mock = self.mox.CreateMockAnything()
        auth_api_mock.tenants = tenants_mock

        tenant_list = [
            Tenant("notTheDroid", "notTheDroid_desc", False),
            Tenant(TEST_TENANT_ID, TEST_TENANT_DESCRIPTION, True),
        ]
        tenants_mock.for_token("aToken").AndReturn(tenant_list)

        self.mox.ReplayAll()

        ret_val = api.token_list_tenants(self.request, "aToken")
        for tenant in ret_val:
            self.assertIn(tenant, tenant_list)

        self.mox.VerifyAll()
コード例 #4
0
def tenants(request):
    if not request.user or not request.user.is_authenticated():
        return {}
    return {'tenants': api.token_list_tenants(request, request.user.token)}