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

Python flavors.delete_flavor_info函数代码示例

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

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



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

示例1: test_delete_flavor_info

 def test_delete_flavor_info(self):
     instance_type = flavors.get_default_flavor()
     metadata = {}
     flavors.save_flavor_info(metadata, instance_type)
     flavors.save_flavor_info(metadata, instance_type, '_')
     flavors.delete_flavor_info(metadata, '', '_')
     self.assertEqual(metadata, {})
开发者ID:MasterZ40,项目名称:nova,代码行数:7,代码来源:test_flavors.py


示例2: _migrate_flavor

    def _migrate_flavor(instance):
        """Migrate a fractional flavor to a full one stored in extra.

        This method migrates flavor information stored in an instance's
        system_metadata to instance_extra. Since the information in the
        former is not complete, we must attempt to fetch the original
        flavor by id to merge its extra_specs with what we store.

        This is a transitional tool and can be removed in a later release
        once we can ensure that everyone has migrated their instances
        (likely the L release).
        """

        # NOTE(danms): Always use admin context and read_deleted=yes here
        # because we need to make sure we can look up our original flavor
        # and try to reconstruct extra_specs, even if it has been deleted
        ctxt = context.get_admin_context(read_deleted="yes")

        instance.flavor = flavors.extract_flavor(instance)
        flavors.delete_flavor_info(instance.system_metadata, "")

        for ftype in ("old", "new"):
            attrname = "%s_flavor" % ftype
            prefix = "%s_" % ftype

            try:
                flavor = flavors.extract_flavor(instance, prefix)
                setattr(instance, attrname, flavor)
                flavors.delete_flavor_info(instance.system_metadata, prefix)
            except KeyError:
                setattr(instance, attrname, None)

        # NOTE(danms): Merge in the extra_specs from the original flavor
        # since they weren't stored with the instance.
        for flv in (instance.flavor, instance.new_flavor, instance.old_flavor):
            if flv is not None:
                try:
                    db_flavor = objects.Flavor.get_by_flavor_id(ctxt, flv.flavorid)
                except exception.FlavorNotFound:
                    continue
                extra_specs = dict(db_flavor.extra_specs)
                extra_specs.update(flv.get("extra_specs", {}))
                flv.extra_specs = extra_specs
开发者ID:jcalonsoh,项目名称:openstack-nova,代码行数:43,代码来源:instance.py


示例3: test_flavor_numa_extras_are_saved

 def test_flavor_numa_extras_are_saved(self):
     instance_type = flavors.get_default_flavor()
     instance_type['extra_specs'] = {
         'hw:numa_mem.0': '123',
         'hw:numa_cpus.0': '456',
         'hw:numa_mem.1': '789',
         'hw:numa_cpus.1': 'ABC',
         'foo': 'bar',
     }
     sysmeta = flavors.save_flavor_info({}, instance_type)
     _instance_type = flavors.extract_flavor({'system_metadata': sysmeta})
     expected_extra_specs = {
         'hw:numa_mem.0': '123',
         'hw:numa_cpus.0': '456',
         'hw:numa_mem.1': '789',
         'hw:numa_cpus.1': 'ABC',
     }
     self.assertEqual(expected_extra_specs, _instance_type['extra_specs'])
     flavors.delete_flavor_info(sysmeta, '')
     self.assertEqual({}, sysmeta)
开发者ID:Juniper,项目名称:nova,代码行数:20,代码来源:test_flavors.py


示例4: test_flavor_numa_extras_are_saved

 def test_flavor_numa_extras_are_saved(self):
     instance_type = flavors.get_default_flavor()
     instance_type["extra_specs"] = {
         "hw:numa_mem.0": "123",
         "hw:numa_cpus.0": "456",
         "hw:numa_mem.1": "789",
         "hw:numa_cpus.1": "ABC",
         "foo": "bar",
     }
     sysmeta = flavors.save_flavor_info({}, instance_type)
     _instance_type = flavors.extract_flavor({"system_metadata": sysmeta})
     expected_extra_specs = {
         "hw:numa_mem.0": "123",
         "hw:numa_cpus.0": "456",
         "hw:numa_mem.1": "789",
         "hw:numa_cpus.1": "ABC",
     }
     self.assertEqual(expected_extra_specs, _instance_type["extra_specs"])
     flavors.delete_flavor_info(sysmeta, "")
     self.assertEqual({}, sysmeta)
开发者ID:isyippee,项目名称:nova,代码行数:20,代码来源:test_flavors.py


示例5: _maybe_upgrade_flavor

    def _maybe_upgrade_flavor(self):
        # NOTE(danms): We may have regressed to flavors stored in sysmeta,
        # so we have to merge back in here. That could happen if we pass
        # a converted instance to an older node, which still stores the
        # flavor in sysmeta, which then calls save(). We need to not
        # store that flavor info back into sysmeta after we've already
        # converted it.
        if not self.obj_attr_is_set("system_metadata") or "instance_type_id" not in self.system_metadata:
            return

        LOG.debug("Transforming legacy flavors on save", instance=self)
        for ftype in ("", "old_", "new_"):
            attr = "%sflavor" % ftype
            try:
                flavor = flavors.extract_flavor(self, prefix=ftype)
                flavors.delete_flavor_info(self.system_metadata, ftype)
                # NOTE(danms): This may trigger a lazy-load of the flavor
                # information, but only once and it avoids re-fetching and
                # re-migrating the original flavor.
                getattr(self, attr).update(flavor)
            except AttributeError:
                setattr(self, attr, flavor)
            except KeyError:
                setattr(self, attr, None)
开发者ID:jcalonsoh,项目名称:openstack-nova,代码行数:24,代码来源:instance.py


示例6: delete_flavor

 def delete_flavor(self, namespace):
     self.system_metadata = flavors.delete_flavor_info(
         self.system_metadata, "%s_" % namespace)
     self.save()
开发者ID:bigloupe,项目名称:nova,代码行数:4,代码来源:instance.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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