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

Python common.get_flavor函数代码示例

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

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



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

示例1: show

 def show(self, req, flavor_id, id):
     """Return a single extra spec item."""
     context = req.environ['nova.context']
     context.can(fes_policies.POLICY_ROOT % 'show')
     flavor = common.get_flavor(context, flavor_id)
     try:
         return {id: flavor.extra_specs[id]}
     except KeyError:
         msg = _("Flavor %(flavor_id)s has no extra specs with "
                 "key %(key)s.") % dict(flavor_id=flavor_id,
                                        key=id)
         raise webob.exc.HTTPNotFound(explanation=msg)
开发者ID:2020human,项目名称:nova,代码行数:12,代码来源:flavors_extraspecs.py


示例2: index

    def index(self, req, flavor_id):
        context = req.environ['nova.context']
        context.can(fa_policies.BASE_POLICY_NAME)

        flavor = common.get_flavor(context, flavor_id)

        # public flavor to all projects
        if flavor.is_public:
            explanation = _("Access list not available for public flavors.")
            raise webob.exc.HTTPNotFound(explanation=explanation)

        # private flavor to listed projects only
        return _marshall_flavor_access(flavor)
开发者ID:arbrandes,项目名称:nova,代码行数:13,代码来源:flavor_access.py


示例3: index

    def index(self, req, flavor_id):
        context = req.environ["nova.context"]
        authorize(context)

        flavor = common.get_flavor(context, flavor_id)

        # public flavor to all projects
        if flavor.is_public:
            explanation = _("Access list not available for public flavors.")
            raise webob.exc.HTTPNotFound(explanation=explanation)

        # private flavor to listed projects only
        return _marshall_flavor_access(flavor)
开发者ID:coryschwartz,项目名称:nova,代码行数:13,代码来源:flavor_access.py


示例4: create

    def create(self, req, flavor_id, body):
        context = req.environ['nova.context']
        context.can(fes_policies.POLICY_ROOT % 'create')

        specs = body['extra_specs']
        self._check_extra_specs_value(specs)
        flavor = common.get_flavor(context, flavor_id)
        try:
            flavor.extra_specs = dict(flavor.extra_specs, **specs)
            flavor.save()
        except exception.FlavorExtraSpecUpdateCreateFailed as e:
            raise webob.exc.HTTPConflict(explanation=e.format_message())
        except exception.FlavorNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
        return body
开发者ID:2020human,项目名称:nova,代码行数:15,代码来源:flavors_extraspecs.py


示例5: index

    def index(self, req, flavor_id):
        context = req.environ['nova.context']
        authorize(context)
        # NOTE(alex_xu): back-compatible with db layer hard-code admin
        # permission checks.
        nova_context.require_admin_context(context)

        flavor = common.get_flavor(context, flavor_id)

        # public flavor to all projects
        if flavor.is_public:
            explanation = _("Access list not available for public flavors.")
            raise webob.exc.HTTPNotFound(explanation=explanation)

        # private flavor to listed projects only
        return _marshall_flavor_access(flavor)
开发者ID:375670450,项目名称:nova,代码行数:16,代码来源:flavor_access.py


示例6: delete

 def delete(self, req, flavor_id, id):
     """Deletes an existing extra spec."""
     context = req.environ['nova.context']
     context.can(fes_policies.POLICY_ROOT % 'delete')
     flavor = common.get_flavor(context, flavor_id)
     try:
         del flavor.extra_specs[id]
         flavor.save()
     except (exception.FlavorExtraSpecsNotFound,
             exception.FlavorNotFound) as e:
         raise webob.exc.HTTPNotFound(explanation=e.format_message())
     except KeyError:
         msg = _("Flavor %(flavor_id)s has no extra specs with "
                 "key %(key)s.") % dict(flavor_id=flavor_id,
                                        key=id)
         raise webob.exc.HTTPNotFound(explanation=msg)
开发者ID:2020human,项目名称:nova,代码行数:16,代码来源:flavors_extraspecs.py


示例7: create

    def create(self, req, flavor_id, body):
        context = req.environ['nova.context']
        authorize(context, action='create')
        self._check_body(body)
        specs = body.get('extra_specs')
        self._check_extra_specs(specs)
        flavor = common.get_flavor(context, flavor_id)

        try:
            flavor.extra_specs = dict(flavor.extra_specs, **specs)
            flavor.save()
        except exception.FlavorExtraSpecUpdateCreateFailed as e:
            raise exc.HTTPConflict(explanation=e.format_message())
        except exception.FlavorNotFound as error:
            raise exc.HTTPNotFound(explanation=error.format_message())
        return body
开发者ID:375670450,项目名称:nova,代码行数:16,代码来源:flavorextraspecs.py


示例8: update

    def update(self, req, flavor_id, id, body):
        context = req.environ['nova.context']
        context.can(fes_policies.POLICY_ROOT % 'update')

        self._check_extra_specs_value(body)
        if id not in body:
            expl = _('Request body and URI mismatch')
            raise webob.exc.HTTPBadRequest(explanation=expl)
        flavor = common.get_flavor(context, flavor_id)
        try:
            flavor.extra_specs = dict(flavor.extra_specs, **body)
            flavor.save()
        except exception.FlavorExtraSpecUpdateCreateFailed as e:
            raise webob.exc.HTTPConflict(explanation=e.format_message())
        except exception.FlavorNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
        return body
开发者ID:2020human,项目名称:nova,代码行数:17,代码来源:flavors_extraspecs.py


示例9: _remove_tenant_access

    def _remove_tenant_access(self, req, id, body):
        context = req.environ['nova.context']
        context.can(
            fa_policies.POLICY_ROOT % "remove_tenant_access")

        vals = body['removeTenantAccess']
        tenant = vals['tenant']

        # NOTE(gibi): We have to load a flavor from the db here as
        # flavor.remove_access() will try to emit a notification and that needs
        # a fully loaded flavor.
        flavor = common.get_flavor(context, id)

        try:
            flavor.remove_access(tenant)
        except (exception.FlavorAccessNotFound,
                exception.FlavorNotFound) as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
        return _marshall_flavor_access(flavor)
开发者ID:vmturbo,项目名称:nova,代码行数:19,代码来源:flavor_access.py


示例10: update

 def update(self, req, flavor_id, id, body):
     context = req.environ['nova.context']
     authorize(context, action='update')
     self._check_extra_specs(body)
     if id not in body:
         expl = _('Request body and URI mismatch')
         raise exc.HTTPBadRequest(explanation=expl)
     if len(body) > 1:
         expl = _('Request body contains too many items')
         raise exc.HTTPBadRequest(explanation=expl)
     flavor = common.get_flavor(context, flavor_id)
     try:
         flavor.extra_specs = dict(flavor.extra_specs, **body)
         flavor.save()
     except exception.FlavorExtraSpecUpdateCreateFailed as e:
         raise exc.HTTPConflict(explanation=e.format_message())
     except exception.FlavorNotFound as error:
         raise exc.HTTPNotFound(explanation=error.format_message())
     return body
开发者ID:375670450,项目名称:nova,代码行数:19,代码来源:flavorextraspecs.py


示例11: _add_tenant_access

    def _add_tenant_access(self, req, id, body):
        context = req.environ['nova.context']
        context.can(fa_policies.POLICY_ROOT % "add_tenant_access")

        vals = body['addTenantAccess']
        tenant = vals['tenant']

        flavor = common.get_flavor(context, id)

        try:
            if api_version_request.is_supported(req, min_version='2.7'):
                if flavor.is_public:
                    exp = _("Can not add access to a public flavor.")
                    raise webob.exc.HTTPConflict(explanation=exp)
            flavor.add_access(tenant)
        except exception.FlavorNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
        except exception.FlavorAccessExists as err:
            raise webob.exc.HTTPConflict(explanation=err.format_message())
        return _marshall_flavor_access(flavor)
开发者ID:amadev,项目名称:nova,代码行数:20,代码来源:flavor_access.py


示例12: _add_tenant_access

    def _add_tenant_access(self, req, id, body):
        context = req.environ["nova.context"]
        authorize(context, action="add_tenant_access")

        vals = body["addTenantAccess"]
        tenant = vals["tenant"]

        flavor = common.get_flavor(context, id)

        try:
            if api_version_request.is_supported(req, min_version="2.7"):
                if flavor.is_public:
                    exp = _("Can not add access to a public flavor.")
                    raise webob.exc.HTTPConflict(explanation=exp)
            flavor.add_access(tenant)
        except exception.FlavorNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())
        except exception.FlavorAccessExists as err:
            raise webob.exc.HTTPConflict(explanation=err.format_message())
        except exception.AdminRequired as e:
            raise webob.exc.HTTPForbidden(explanation=e.format_message())
        return _marshall_flavor_access(flavor)
开发者ID:coryschwartz,项目名称:nova,代码行数:22,代码来源:flavor_access.py


示例13: _get_extra_specs

 def _get_extra_specs(self, context, flavor_id):
     flavor = common.get_flavor(context, flavor_id)
     return dict(extra_specs=flavor.extra_specs)
开发者ID:2020human,项目名称:nova,代码行数:3,代码来源:flavors_extraspecs.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python common.get_id_from_href函数代码示例发布时间:2022-05-27
下一篇:
Python common.check_img_metadata_quota_limit函数代码示例发布时间: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