Beispiel #1
0
    def get_tenant_groups(self, admin_token, tenant_id, marker, limit, url):
        self.__validate_token(admin_token)
        if tenant_id == None:
            raise fault.BadRequestFault("Expecting a Tenant Id")

        dtenant = db_api.tenant_get(tenant_id)
        if dtenant == None:
            raise fault.ItemNotFoundFault("The tenant not found")

        ts = []
        dtenantgroups = db_api.tenant_group_get_page(tenant_id, marker, limit)

        for dtenantgroup in dtenantgroups:
            ts.append(tenants.Group(dtenantgroup.id,
                                     dtenantgroup.desc,
                                     dtenantgroup.tenant_id))
        prev, next = db_api.tenant_group_get_page_markers(tenant_id, marker,
                                                          limit)
        links = []
        if prev:
            links.append(atom.Link('prev', "%s?'marker=%s&limit=%s'" \
                                    % (url, prev, limit)))
        if next:
            links.append(atom.Link('next', "%s?'marker=%s&limit=%s'"\
                                    % (url, next, limit)))

        return tenants.Groups(ts, links)
Beispiel #2
0
 def get_global_groups(self, admin_token, marker, limit, url):
     self.__validate_token(admin_token)
     gtenant = self.__check_create_global_tenant()
     ts = []
     dtenantgroups = db_api.tenant_group_get_page(gtenant.id, \
                                                   marker, limit)
     for dtenantgroup in dtenantgroups:
         ts.append(tenants.GlobalGroup(dtenantgroup.id,
                                  dtenantgroup.desc))
     prev, next = db_api.tenant_group_get_page_markers(gtenant.id,
                                                    marker, limit)
     links = []
     if prev:
         links.append(atom.Link('prev', "%s?'marker=%s&limit=%s'" %
                               (url, prev, limit)))
     if next:
         links.append(atom.Link('next', "%s?'marker=%s&limit=%s'" %
                               (url, next, limit)))
     return tenants.GlobalGroups(ts, links)