Esempio n. 1
0
    def index(self, req):
        """Return a basic filtered list of public, non-deleted images

        :param req: the Request object coming from the wsgi layer
        :retval a mapping of the following form::

            dict(images=[image_list])

        Where image_list is a sequence of mappings::

            {
            'id': <ID>,
            'name': <NAME>,
            'size': <SIZE>,
            'disk_format': <DISK_FORMAT>,
            'container_format': <CONTAINER_FORMAT>,
            'checksum': <CHECKSUM>
            }

        """
        params = {
            'filters': self._get_filters(req),
            'limit': self._get_limit(req),
        }

        if 'marker' in req.str_params:
            params['marker'] = self._get_marker(req)

        images = db_api.image_get_all_public(None, **params)

        results = []
        for image in images:
            result = {}
            for field in DISPLAY_FIELDS_IN_INDEX:
                result[field] = image[field]
            results.append(result)
        return dict(images=results)
Esempio n. 2
0
    def detail(self, req):
        """Return a filtered list of public, non-deleted images in detail

        :param req: the Request object coming from the wsgi layer
        :retval a mapping of the following form::

            dict(images=[image_list])

        Where image_list is a sequence of mappings containing
        all image model fields.

        """
        params = {
            'filters': self._get_filters(req),
            'limit': self._get_limit(req),
        }

        if 'marker' in req.str_params:
            params['marker'] = self._get_marker(req)

        images = db_api.image_get_all_public(None, **params)

        image_dicts = [make_image_dict(i) for i in images]
        return dict(images=image_dicts)