def _get_EnabledWebservices_collection(self, marker, limit,
                                           sort_key, sort_dir, project_id,
                                           fields=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.EnabledWebservice.get_by_id(
                pecan.request.context,
                marker)

        if sort_key in self.invalid_sort_key_list:
            raise exception.InvalidParameterValue(
                ("The sort_key value %(key)s is an invalid field for "
                 "sorting") % {'key': sort_key})

        filters = {}
        filters['project_id'] = project_id

        EnabledWebservices = objects.EnabledWebservice.list(
            pecan.request.context, limit,
            marker_obj,
            sort_key=sort_key,
            sort_dir=sort_dir,
            filters=filters)

        parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}

        return EnabledWebserviceCollection.convert_with_links(
            EnabledWebservices, limit,
            fields=fields,
            **parameters)
Exemple #2
0
    def _get_fleets_collection(self,
                               marker,
                               limit,
                               sort_key,
                               sort_dir,
                               fields=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Fleet.get_by_uuid(pecan.request.context,
                                                   marker)

        if sort_key in self.invalid_sort_key_list:
            raise exception.InvalidParameterValue(
                ("The sort_key value %(key)s is an invalid field for "
                 "sorting") % {'key': sort_key})

        filters = {}
        fleets = objects.Fleet.list(pecan.request.context,
                                    limit,
                                    marker_obj,
                                    sort_key=sort_key,
                                    sort_dir=sort_dir,
                                    filters=filters)

        parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}

        return FleetCollection.convert_with_links(fleets,
                                                  limit,
                                                  fields=fields,
                                                  **parameters)
Exemple #3
0
    def _get_fleets_collection(self, marker, limit,
                               sort_key, sort_dir,
                               fields=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Fleet.get_by_uuid(pecan.request.context,
                                                   marker)

        if sort_key in self.invalid_sort_key_list:
            raise exception.InvalidParameterValue(
                ("The sort_key value %(key)s is an invalid field for "
                 "sorting") % {'key': sort_key})

        filters = {}
        fleets = objects.Fleet.list(pecan.request.context, limit,
                                    marker_obj,
                                    sort_key=sort_key, sort_dir=sort_dir,
                                    filters=filters)

        parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}

        return FleetCollection.convert_with_links(fleets, limit,
                                                  fields=fields,
                                                  **parameters)
Exemple #4
0
    def _get_nodes_collection(self,
                              marker,
                              limit,
                              sort_key,
                              sort_dir,
                              expand=False,
                              resource_url=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Node.get_by_uuid(pecan.request.context,
                                                  marker)

        if sort_key in self.invalid_sort_key_list:
            raise exception.InvalidParameterValue(
                _("The sort_key value %(key)s is an invalid field for "
                  "sorting") % {'key': sort_key})

        filters = {}
        nodes = objects.Node.list(pecan.request.context,
                                  limit,
                                  marker_obj,
                                  sort_key=sort_key,
                                  sort_dir=sort_dir,
                                  filters=filters)

        parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}
        return NodeCollection.convert_with_locates(nodes,
                                                   limit,
                                                   url=resource_url,
                                                   expand=expand,
                                                   **parameters)
Exemple #5
0
    def _get_boards_collection(self,
                               status,
                               marker,
                               limit,
                               sort_key,
                               sort_dir,
                               project=None,
                               resource_url=None,
                               fields=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Board.get_by_uuid(pecan.request.context,
                                                   marker)

        if sort_key in self.invalid_sort_key_list:
            raise exception.InvalidParameterValue(
                ("The sort_key value %(key)s is an invalid field for "
                 "sorting") % {'key': sort_key})

        filters = {}

        # bounding the request to a project
        if project:
            if pecan.request.context.is_admin:
                filters['project_id'] = project
            else:
                msg = ("Project parameter can be used only "
                       "by the administrator.")
                raise wsme.exc.ClientSideError(msg, status_code=400)
        else:
            filters['project_id'] = pecan.request.context.project_id

        if status:
            filters['status'] = status

        boards = objects.Board.list(pecan.request.context,
                                    limit,
                                    marker_obj,
                                    sort_key=sort_key,
                                    sort_dir=sort_dir,
                                    filters=filters)

        parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}

        return BoardCollection.convert_with_links(boards,
                                                  limit,
                                                  url=resource_url,
                                                  fields=fields,
                                                  **parameters)
Exemple #6
0
    def _get_ports_collection(self,
                              marker,
                              limit,
                              sort_key,
                              sort_dir,
                              fields=None,
                              with_public=False,
                              all_ports=False):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Port.get_by_uuid(pecan.request.context,
                                                  marker)

        if sort_key in self.invalid_sort_key_list:
            raise exception.InvalidParameterValue(
                ("The sort_key value %(key)s is an invalid field for "
                 "sorting") % {'key': sort_key})

        filters = {}
        #        if all_ports and not pecan.request.context.is_admin:
        #            msg = ("all_ports parameter can only be used  "
        #                   "by the administrator.")
        #            raise wsme.exc.ClientSideError(msg,
        #                                           status_code=400)
        #        else:
        #            if not all_ports:
        #                filters['owner'] = pecan.request.context.user_id
        #                if with_public:
        #                    filters['with_public'] = with_public

        ports = objects.Port.list(pecan.request.context,
                                  limit,
                                  marker_obj,
                                  sort_key=sort_key,
                                  sort_dir=sort_dir,
                                  filters=filters)

        parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}

        return PortCollection.convert_with_links(ports,
                                                 limit,
                                                 fields=fields,
                                                 **parameters)
Exemple #7
0
    def _get_boards_collection(self, status, marker, limit,
                               sort_key, sort_dir,
                               project=None,
                               resource_url=None, fields=None):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Board.get_by_uuid(pecan.request.context,
                                                   marker)

        if sort_key in self.invalid_sort_key_list:
            raise exception.InvalidParameterValue(
                ("The sort_key value %(key)s is an invalid field for "
                 "sorting") % {'key': sort_key})

        filters = {}

        # bounding the request to a project
        if project:
            if pecan.request.context.is_admin:
                filters['project_id'] = project
            else:
                msg = ("Project parameter can be used only "
                       "by the administrator.")
                raise wsme.exc.ClientSideError(msg,
                                               status_code=400)
        else:
            filters['project_id'] = pecan.request.context.project_id

        if status:
            filters['status'] = status

        boards = objects.Board.list(pecan.request.context, limit, marker_obj,
                                    sort_key=sort_key, sort_dir=sort_dir,
                                    filters=filters)

        parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}

        return BoardCollection.convert_with_links(boards, limit,
                                                  url=resource_url,
                                                  fields=fields,
                                                  **parameters)
Exemple #8
0
    def _get_services_collection(self, marker, limit,
                                 sort_key, sort_dir,
                                 fields=None, with_public=False,
                                 all_services=False):

        limit = api_utils.validate_limit(limit)
        sort_dir = api_utils.validate_sort_dir(sort_dir)

        marker_obj = None
        if marker:
            marker_obj = objects.Service.get_by_uuid(pecan.request.context,
                                                     marker)

        if sort_key in self.invalid_sort_key_list:
            raise exception.InvalidParameterValue(
                ("The sort_key value %(key)s is an invalid field for "
                 "sorting") % {'key': sort_key})

        filters = {}
        if all_services and not pecan.request.context.is_admin:
            msg = ("all_services parameter can only be used  "
                   "by the administrator.")
            raise wsme.exc.ClientSideError(msg,
                                           status_code=400)
        else:
            if not all_services:
                filters['project'] = pecan.request.context.user_id
                if with_public:
                    filters['with_public'] = with_public

        services = objects.Service.list(pecan.request.context, limit,
                                        marker_obj,
                                        sort_key=sort_key, sort_dir=sort_dir,
                                        filters=filters)

        parameters = {'sort_key': sort_key, 'sort_dir': sort_dir}

        return ServiceCollection.convert_with_links(services, limit,
                                                    fields=fields,
                                                    **parameters)