• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common.check_img_metadata_quota_limit函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nova.api.openstack.common.check_img_metadata_quota_limit函数的典型用法代码示例。如果您正苦于以下问题:Python check_img_metadata_quota_limit函数的具体用法?Python check_img_metadata_quota_limit怎么用?Python check_img_metadata_quota_limit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了check_img_metadata_quota_limit函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: _action_create_image

    def _action_create_image(self, req, id, body):
        """Snapshot a server instance."""
        context = req.environ["nova.context"]
        entity = body.get("createImage", {})

        image_name = entity.get("name")

        if not image_name:
            msg = _("createImage entity requires name attribute")
            raise exc.HTTPBadRequest(explanation=msg)

        props = {}
        metadata = entity.get("metadata", {})
        common.check_img_metadata_quota_limit(context, metadata)
        try:
            props.update(metadata)
        except ValueError:
            msg = _("Invalid metadata")
            raise exc.HTTPBadRequest(explanation=msg)

        instance = self._get_server(context, id)

        try:
            image = self.compute_api.snapshot(context, instance, image_name, extra_properties=props)
        except exception.InstanceInvalidState as state_error:
            common.raise_http_conflict_for_instance_invalid_state(state_error, "createImage")

        # build location of newly-created image entity
        image_id = str(image["id"])
        image_ref = os.path.join(req.application_url, context.project_id, "images", image_id)

        resp = webob.Response(status_int=202)
        resp.headers["Location"] = image_ref
        return resp
开发者ID:rcbops,项目名称:nova-buildpackage,代码行数:34,代码来源:servers.py


示例2: _action_create_backup

    def _action_create_backup(self, input_dict, req, instance_id):
        """Backup a server instance.

        Images now have an `image_type` associated with them, which can be
        'snapshot' or the backup type, like 'daily' or 'weekly'.

        If the image_type is backup-like, then the rotation factor can be
        included and that will cause the oldest backups that exceed the
        rotation factor to be deleted.

        """
        context = req.environ["nova.context"]
        entity = input_dict["createBackup"]

        try:
            image_name = entity["name"]
            backup_type = entity["backup_type"]
            rotation = entity["rotation"]

        except KeyError as missing_key:
            msg = _("createBackup entity requires %s attribute") % missing_key
            raise exc.HTTPBadRequest(explanation=msg)

        except TypeError:
            msg = _("Malformed createBackup entity")
            raise exc.HTTPBadRequest(explanation=msg)

        try:
            rotation = int(rotation)
        except ValueError:
            msg = _("createBackup attribute 'rotation' must be an integer")
            raise exc.HTTPBadRequest(explanation=msg)

        # preserve link to server in image properties
        server_ref = os.path.join(req.application_url, 'servers', instance_id)
        props = {'instance_ref': server_ref}

        metadata = entity.get('metadata', {})
        common.check_img_metadata_quota_limit(context, metadata)
        try:
            props.update(metadata)
        except ValueError:
            msg = _("Invalid metadata")
            raise exc.HTTPBadRequest(explanation=msg)

        image = self.compute_api.backup(context,
                                        instance_id,
                                        image_name,
                                        backup_type,
                                        rotation,
                                        extra_properties=props)

        # build location of newly-created image entity
        image_id = str(image['id'])
        image_ref = os.path.join(req.application_url, 'images', image_id)

        resp = webob.Response(status_int=202)
        resp.headers['Location'] = image_ref
        return resp
开发者ID:dragonetail,项目名称:nova,代码行数:59,代码来源:servers.py


示例3: update_all

 def update_all(self, req, image_id, body):
     context = req.environ['nova.context']
     image = self._get_image(context, image_id)
     metadata = body.get('metadata', {})
     common.check_img_metadata_quota_limit(context, metadata)
     image['properties'] = metadata
     self.image_service.update(context, image_id, image, None)
     return dict(metadata=metadata)
开发者ID:CaptTofu,项目名称:reddwarf,代码行数:8,代码来源:image_metadata.py


示例4: create

 def create(self, req, image_id, body):
     context = req.environ['nova.context']
     image = self._get_image(context, image_id)
     if 'metadata' in body:
         for key, value in body['metadata'].iteritems():
             image['properties'][key] = value
     common.check_img_metadata_quota_limit(context, image['properties'])
     self.image_service.update(context, image_id, image, None)
     return dict(metadata=image['properties'])
开发者ID:CaptTofu,项目名称:reddwarf,代码行数:9,代码来源:image_metadata.py


示例5: _action_create_image

    def _action_create_image(self, input_dict, req, instance_id):
        """Snapshot a server instance."""
        entity = input_dict.get("createImage", {})

        try:
            image_name = entity["name"]
            force_snapshot = entity.get("force_snapshot", False)

        except KeyError:
            msg = _("createImage entity requires name attribute")
            raise webob.exc.HTTPBadRequest(explanation=msg)

        except TypeError:
            msg = _("Malformed createImage entity")
            raise webob.exc.HTTPBadRequest(explanation=msg)

        # preserve link to server in image properties
        server_ref = os.path.join(req.application_url,
                                  'servers',
                                  str(instance_id))
        props = {'instance_ref': server_ref}

        metadata = entity.get('metadata', {})
        context = req.environ['nova.context']
        common.check_img_metadata_quota_limit(context, metadata)
        try:
            props.update(metadata)
        except ValueError:
            msg = _("Invalid metadata")
            raise webob.exc.HTTPBadRequest(explanation=msg)

        try:
            extra_options = {
                'force_snapshot' : force_snapshot
            }
            image = self.compute_api.snapshot(context,
                                              instance_id,
                                              image_name,
                                              extra_properties=props,
                                              extra_options=extra_options)
        except exception.InstanceBusy:
            msg = _("Server is currently creating an image. Please wait.")
            raise webob.exc.HTTPConflict(explanation=msg)

        # build location of newly-created image entity
        image_id = str(image['id'])
        image_ref = os.path.join(req.application_url,
                                 context.project_id,
                                 'images',
                                 image_id)

        resp = webob.Response(status_int=202)
        resp.headers['Location'] = image_ref
        return resp
开发者ID:chopachom,项目名称:nova,代码行数:54,代码来源:servers.py


示例6: create

 def create(self, req, image_id, body):
     context = req.environ['nova.context']
     img = self.image_service.show(context, image_id)
     metadata = self._get_metadata(context, image_id, img)
     if 'metadata' in body:
         for key, value in body['metadata'].iteritems():
             metadata[key] = value
     common.check_img_metadata_quota_limit(context, metadata)
     img['properties'] = metadata
     self.image_service.update(context, image_id, img, None)
     return dict(metadata=metadata)
开发者ID:AsherBond,项目名称:dodai-compute,代码行数:11,代码来源:image_metadata.py


示例7: _action_create_image

    def _action_create_image(self, input_dict, req, instance_id):
        """Snapshot a server instance."""
        context = req.environ["nova.context"]
        entity = input_dict.get("createImage", {})

        try:
            image_name = entity["name"]

        except KeyError:
            msg = _("createImage entity requires name attribute")
            raise exc.HTTPBadRequest(explanation=msg)

        except TypeError:
            msg = _("Malformed createImage entity")
            raise exc.HTTPBadRequest(explanation=msg)

        # preserve link to server in image properties
        server_ref = os.path.join(req.application_url, "servers", instance_id)
        props = {"instance_ref": server_ref}

        metadata = entity.get("metadata", {})
        common.check_img_metadata_quota_limit(context, metadata)
        try:
            props.update(metadata)
        except ValueError:
            msg = _("Invalid metadata")
            raise exc.HTTPBadRequest(explanation=msg)

        instance = self._get_server(context, instance_id)

        try:
            image = self.compute_api.snapshot(context, instance, image_name, extra_properties=props)
        except exception.InstanceBusy:
            msg = _("Server is currently creating an image. Please wait.")
            raise webob.exc.HTTPConflict(explanation=msg)

        # build location of newly-created image entity
        image_id = str(image["id"])
        image_ref = os.path.join(req.application_url, context.project_id, "images", image_id)

        resp = webob.Response(status_int=202)
        resp.headers["Location"] = image_ref
        return resp
开发者ID:oubiwann,项目名称:nova,代码行数:43,代码来源:servers.py


示例8: update

    def update(self, req, image_id, id, body):
        context = req.environ['nova.context']

        try:
            meta = body['meta']
        except KeyError:
            expl = _('Incorrect request body format')
            raise exc.HTTPBadRequest(explanation=expl)

        if not id in meta:
            expl = _('Request body and URI mismatch')
            raise exc.HTTPBadRequest(explanation=expl)
        if len(meta) > 1:
            expl = _('Request body contains too many items')
            raise exc.HTTPBadRequest(explanation=expl)

        image = self._get_image(context, image_id)
        image['properties'][id] = meta[id]
        common.check_img_metadata_quota_limit(context, image['properties'])
        self.image_service.update(context, image_id, image, None)
        return dict(meta=meta)
开发者ID:CaptTofu,项目名称:reddwarf,代码行数:21,代码来源:image_metadata.py



注:本文中的nova.api.openstack.common.check_img_metadata_quota_limit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python common.get_flavor函数代码示例发布时间:2022-05-27
下一篇:
Python common.check_img_metadata_properties_quota函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap