Beispiel #1
0
    def test_index_with_domain_context(self):
        domain = self.domains.get(id="1")
        filters = {}
        self.setSessionValues(domain_context=domain.id,
                              domain_context_name=domain.name)

        domain_tenants = [
            tenant for tenant in self.tenants.list()
            if tenant.domain_id == domain.id
        ]

        api.keystone.tenant_list(IsA(http.HttpRequest),
                                 domain=domain.id,
                                 paginate=True,
                                 marker=None,
                                 filters=filters) \
                    .AndReturn([domain_tenants, False])
        api.keystone.domain_lookup(IgnoreArg()).AndReturn(
            {domain.id: domain.name})
        quotas.enabled_quotas(IsA(http.HttpRequest)).AndReturn(('instances', ))
        self.mox.ReplayAll()

        res = self.client.get(INDEX_URL)
        self.assertTemplateUsed(res, 'identity/projects/index.html')
        self.assertItemsEqual(res.context['table'].data, domain_tenants)
        self.assertContains(res, "<em>test_domain:</em>")
Beispiel #2
0
    def test_detail_view(self):
        project = self.tenants.first()

        api.keystone.tenant_get(IsA(http.HttpRequest), self.tenant.id) \
            .AndReturn(project)
        quotas.enabled_quotas(IsA(http.HttpRequest)).AndReturn(('instances', ))
        self.mox.ReplayAll()

        res = self.client.get(PROJECT_DETAIL_URL, args=[project.id])

        self.assertTemplateUsed(res, 'identity/projects/detail.html')
        self.assertEqual(res.context['project'].name, project.name)
        self.assertEqual(res.context['project'].id, project.id)
Beispiel #3
0
    def test_index(self):
        domain = self.domains.get(id="1")
        filters = {}
        api.keystone.tenant_list(IsA(http.HttpRequest),
                                 domain=None,
                                 paginate=True,
                                 filters=filters,
                                 marker=None) \
            .AndReturn([self.tenants.list(), False])
        api.keystone.domain_lookup(IgnoreArg()).AndReturn(
            {domain.id: domain.name})
        quotas.enabled_quotas(IsA(http.HttpRequest)).MultipleTimes()\
            .AndReturn(('instances',))
        self.mox.ReplayAll()

        res = self.client.get(INDEX_URL)
        self.assertTemplateUsed(res, 'identity/projects/index.html')
        self.assertItemsEqual(res.context['table'].data, self.tenants.list())
Beispiel #4
0
 def allowed(self, request, datum):
     if api.keystone.VERSIONS.active < 3:
         return True
     else:
         return (api.keystone.is_cloud_admin(request) and
                 quotas.enabled_quotas(request))
Beispiel #5
0
 def allowed(self, request, datum):
     return (api.keystone.is_cloud_admin(request)
             and quotas.enabled_quotas(request))
Beispiel #6
0
 def allowed(self, request, datum):
     if api.keystone.VERSIONS.active < 3:
         return True
     else:
         return (api.keystone.is_cloud_admin(request) and
                 quotas.enabled_quotas(request))
Beispiel #7
0
 def allowed(self, request, _=None):
     return quotas.enabled_quotas(request)
Beispiel #8
0
 def allowed(self, request, _=None):
     return quotas.enabled_quotas(request)
Beispiel #9
0
    def test_index(self):
        # Neutron does not have an API for getting default system
        # quotas. When not using Neutron, the floating ips quotas
        # should be in the list.
        self.mox.StubOutWithMock(api.nova, 'default_quota_get')
        self.mox.StubOutWithMock(api.cinder, 'default_quota_get')
        self.mox.StubOutWithMock(api.cinder, 'is_volume_service_enabled')
        self.mox.StubOutWithMock(api.base, 'is_service_enabled')
        self.mox.StubOutWithMock(api.neutron, 'default_quota_get')
        self.mox.StubOutWithMock(quotas, 'enabled_quotas')

        api.cinder.is_volume_service_enabled(IsA(http.HttpRequest)) \
            .MultipleTimes().AndReturn(True)
        api.base.is_service_enabled(IsA(http.HttpRequest), 'compute') \
            .MultipleTimes().AndReturn(True)
        api.base.is_service_enabled(IsA(http.HttpRequest), 'network') \
            .MultipleTimes().AndReturn(True)
        compute_quotas = [q.name for q in self.quotas.nova]
        quotas.enabled_quotas(IsA(http.HttpRequest)) \
            .MultipleTimes().AndReturn(compute_quotas)
        api.nova.default_quota_get(IsA(http.HttpRequest),
                                   self.tenant.id).AndReturn(self.quotas.nova)
        api.cinder.default_quota_get(IsA(http.HttpRequest), self.tenant.id) \
            .AndReturn(self.cinder_quotas.first())
        api.neutron.default_quota_get(IsA(http.HttpRequest)).AndReturn(
            self.neutron_quotas.first())

        self.mox.ReplayAll()

        res = self.client.get(INDEX_URL)

        self.assertTemplateUsed(res, 'admin/defaults/index.html')

        expected_data = [
            '<Quota: (injected_file_content_bytes, 1)>',
            '<Quota: (metadata_items, 1)>',
            '<Quota: (injected_files, 1)>',
            '<Quota: (ram, 10000)>',
            '<Quota: (instances, 10)>',
            '<Quota: (cores, 10)>',
            '<Quota: (key_pairs, 100)>',
            '<Quota: (injected_file_path_bytes, 255)>',
        ]
        self._check_quotas_data(res, 'compute_quotas', expected_data)

        expected_data = [
            '<Quota: (gigabytes, 1000)>',
            '<Quota: (snapshots, 1)>',
            '<Quota: (volumes, 1)>',
        ]
        self._check_quotas_data(res, 'volume_quotas', expected_data)

        expected_data = [
            '<Quota: (network, 10)>',
            '<Quota: (subnet, 10)>',
            '<Quota: (port, 50)>',
            '<Quota: (router, 10)>',
            '<Quota: (floatingip, 50)>',
            '<Quota: (security_group, 20)>',
            '<Quota: (security_group_rule, 100)>',
        ]
        self._check_quotas_data(res, 'network_quotas', expected_data)