Ejemplo n.º 1
0
    def detail(self, req):
        """Return a detailed index listing of volumes available to the request.

        :param req: `wsgi.Request` object.

        """
        context = req.environ['nova.context']
        filters = self._get_filters(req)
        params = req.GET.copy()
        page_params = common.get_pagination_params(req)
        for key, val in page_params.iteritems():
            params[key] = val
        try:
            volumes = self.conn.describe_volumes(limit=50, status=["pending","available","in-use","suspended"])
        except exception.Invalid as e:
            raise webob.exc.HTTPBadRequest(explanation=e.format_message())
	data = volumes['volume_set']
        res = []
        for volume in data:
            attachments = []
            for i in volume['resources']:
                attachments.append({'server_id': i.get('resource_id')})
            res.append({
                'status': volume['status'],
                'display_name': volume['volume_name'],
                'attachments': attachments,
                'display_description': volume['description'],
                'id': volume['volume_id'],
                'volume_type': volume['volume_type'],
                'snapshot_id': None,
                'size': volume['size'],
                'metadata': {},
                'created_at': volume['create_time'],
                'multiattach': 'false'})
        return {'volumes': res}
Ejemplo n.º 2
0
    def index(self, req):
        """Return an index listing of images available to the request.

        :param req: `wsgi.Request` object

        """
        params = req.GET.copy()
        page_params = common.get_pagination_params(req)
        for key, val in page_params.iteritems():
            params[key] = val
        data = []

        try:
            images = self.conn.describe_images(
                provider="selected", status=["available"], **page_params)
        except exception.Invalid as e:
            raise webob.exc.HTTPBadRequest(explanation=e.format_message())
        for image in images['image_set']:
            data.append({
                'status': image.get('status', None),
                'name': image.get('image_id', None),
                'id': image.get('image_id', None)})
        return {'images': data}

        raise webob.exc.HTTPMethodNotAllowed()
Ejemplo n.º 3
0
    def index(self, req):
        """Return an index listing of volumes available to the request.

        :param req: `wsgi.Request` object

        """
        context = req.environ['nova.context']
        filters = self._get_filters(req)
        params = req.GET.copy()
        page_params = common.get_pagination_params(req)
        for key, val in page_params.iteritems():
            params[key] = val

        try:
            volumes = self.conn.describe_volumes(limit=50)

        except exception.Invalid as e:
            raise webob.exc.HTTPBadRequest(explanation=e.format_message())
        return self._view_builder.index(req, volumes)
Ejemplo n.º 4
0
    def detail(self, req):
        """Return a detailed index listing of images available to the request.

        :param req: `wsgi.Request` object.

        """
        page_params = common.get_pagination_params(req)
        data = []
        try:
            images = self.conn.describe_images(
                provider="system", status=["pending","available","suspended"], **page_params)
            for image in images['image_set']:
                data.append({
                    'status': image.get('status', None),
                    'name': image.get('image_name', None),
                    'id': image.get('image_id', None)})

        except exception.Invalid as e:
            raise webob.exc.HTTPBadRequest(explanation=e.format_message())

        return {'images': data}