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

Python flavors.destroy函数代码示例

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

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



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

示例1: test_instance_type_create_then_delete

    def test_instance_type_create_then_delete(self):
        # Ensure instance types can be created.
        name = "Small Flavor"
        flavorid = "flavor1"

        original_list = flavors.get_all_types()

        # create new type and make sure values stick
        inst_type = flavors.create(name, 256, 1, 120, 100, flavorid)
        inst_type_id = inst_type["id"]
        self.assertEqual(inst_type["flavorid"], flavorid)
        self.assertEqual(inst_type["name"], name)
        self.assertEqual(inst_type["memory_mb"], 256)
        self.assertEqual(inst_type["vcpus"], 1)
        self.assertEqual(inst_type["root_gb"], 120)
        self.assertEqual(inst_type["ephemeral_gb"], 100)
        self.assertEqual(inst_type["swap"], 0)
        self.assertEqual(inst_type["rxtx_factor"], 1.0)

        # make sure new type shows up in list
        new_list = flavors.get_all_types()
        self.assertNotEqual(len(original_list), len(new_list), "instance type was not created")

        flavors.destroy(name)
        self.assertRaises(exception.InstanceTypeNotFound, flavors.get_instance_type, inst_type_id)

        # deleted instance should not be in list anymoer
        new_list = flavors.get_all_types()
        self.assertEqual(original_list, new_list)
开发者ID:comstud,项目名称:nova,代码行数:29,代码来源:test_instance_types.py


示例2: _delete

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

        try:
            flavor = flavors.get_flavor_by_flavor_id(id, ctxt=context, read_deleted="no")
        except exception.FlavorNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())

        flavors.destroy(flavor["name"])
开发者ID:BU-NU-CLOUD-SP16,项目名称:Trusted-Platform-Module-nova,代码行数:10,代码来源:flavor_manage.py


示例3: test_read_deleted_false_converting_flavorid

    def test_read_deleted_false_converting_flavorid(self):
        """Ensure deleted flavors are not returned when not needed (for
        example when creating a server and attempting to translate from
        flavorid to instance_type_id.
        """
        flavors.create("instance_type1", 256, 1, 120, 100, "test1")
        flavors.destroy("instance_type1")
        flavors.create("instance_type1_redo", 256, 1, 120, 100, "test1")

        instance_type = flavors.get_flavor_by_flavor_id("test1", read_deleted="no")
        self.assertEqual("instance_type1_redo", instance_type.name)
开发者ID:isyippee,项目名称:nova,代码行数:11,代码来源:test_flavors.py


示例4: test_get_inactive_flavors_with_same_flavorid

    def test_get_inactive_flavors_with_same_flavorid(self):
        flav1 = flavors.create('flavor', 256, 1, 120, 100, "flavid")
        flavors.destroy('flavor')
        flav2 = flavors.create('flavor', 512, 4, 250, 100, "flavid")

        returned_flavors_ids = flavors.get_all_flavors().keys()
        self.assertNotIn(flav1['id'], returned_flavors_ids)
        self.assertIn(flav2['id'], returned_flavors_ids)

        returned_flavors_ids = flavors.get_all_flavors(inactive=True).keys()
        self.assertIn(flav1['id'], returned_flavors_ids)
        self.assertIn(flav2['id'], returned_flavors_ids)
开发者ID:Acidburn0zzz,项目名称:nova,代码行数:12,代码来源:test_flavors.py


示例5: test_get_inactive_flavors

    def test_get_inactive_flavors(self):
        flav1 = flavors.create('flavor1', 256, 1, 120)
        flav2 = flavors.create('flavor2', 512, 4, 250)
        flavors.destroy('flavor1')

        returned_flavors_ids = flavors.get_all_flavors().keys()
        self.assertNotIn(flav1['id'], returned_flavors_ids)
        self.assertIn(flav2['id'], returned_flavors_ids)

        returned_flavors_ids = flavors.get_all_flavors(inactive=True).keys()
        self.assertIn(flav1['id'], returned_flavors_ids)
        self.assertIn(flav2['id'], returned_flavors_ids)
开发者ID:Acidburn0zzz,项目名称:nova,代码行数:12,代码来源:test_flavors.py


示例6: test_get_inactive_flavors_with_same_name

    def test_get_inactive_flavors_with_same_name(self):
        flavors.create('flavor1', 256, 1, 120, 100, "test_id1")
        flavors.destroy('flavor1')
        flavors.create('flavor1', 512, 4, 250, 100, "test_id2")

        returned_flavors_ids = flavors.get_all_flavors().keys()
        self.assertNotIn('test_id1', returned_flavors_ids)
        self.assertIn('test_id2', returned_flavors_ids)

        returned_flavors_ids = flavors.get_all_flavors(inactive=True).keys()
        self.assertIn('test_id1', returned_flavors_ids)
        self.assertIn('test_id2', returned_flavors_ids)
开发者ID:aspiers,项目名称:nova,代码行数:12,代码来源:test_flavors.py


示例7: test_get_inactive_flavors_with_same_name

    def test_get_inactive_flavors_with_same_name(self):
        flav1 = flavors.create('flavor', 256, 1, 120)
        flavors.destroy('flavor')
        flav2 = flavors.create('flavor', 512, 4, 250)

        returned_flavors_ids = flavors.get_all_flavors().keys()
        self.assertNotIn(flav1.id, returned_flavors_ids)
        self.assertIn(flav2.id, returned_flavors_ids)

        returned_flavors_ids = flavors.get_all_flavors(inactive=True).keys()
        self.assertIn(flav1.id, returned_flavors_ids)
        self.assertIn(flav2.id, returned_flavors_ids)
开发者ID:Milstein,项目名称:nova,代码行数:12,代码来源:test_flavors.py


示例8: _delete

    def _delete(self, req, id):
        context = req.environ['nova.context']
        authorize(context)
        try:
            flavor = flavors.get_flavor_by_flavor_id(
                    id, ctxt=context, read_deleted="no")
        except exception.FlavorNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())

        flavors.destroy(flavor['name'])

        return webob.Response(status_int=202)
开发者ID:375670450,项目名称:nova,代码行数:12,代码来源:flavormanage.py


示例9: test_can_read_deleted_types_using_flavor_id

    def test_can_read_deleted_types_using_flavor_id(self):
        # Ensure deleted instance types can be read when querying flavor_id.
        inst_type_name = "test"
        inst_type_flavor_id = "test1"

        inst_type = flavors.create(inst_type_name, 256, 1, 120, 100, inst_type_flavor_id)
        self.assertEqual(inst_type_name, inst_type["name"])

        # NOTE(jk0): The deleted flavor will show up here because the context
        # in get_instance_type_by_flavor_id() is set to use read_deleted by
        # default.
        flavors.destroy(inst_type["name"])
        deleted_inst_type = flavors.get_instance_type_by_flavor_id(inst_type_flavor_id)
        self.assertEqual(inst_type_name, deleted_inst_type["name"])
开发者ID:sdague,项目名称:nova,代码行数:14,代码来源:test_instance_types.py


示例10: delete

 def delete(self, name):
     """Marks instance types / flavors as deleted."""
     try:
         flavors.destroy(name)
     except exception.InstanceTypeNotFound:
         print _("Valid instance type name is required")
         return 1
     except db_exc.DBError as e:
         print _("DB Error: %s") % e
         return 2
     except Exception:
         return 3
     else:
         print _("%s deleted") % name
开发者ID:comstud,项目名称:nova,代码行数:14,代码来源:manage.py


示例11: test_create_then_delete

    def test_create_then_delete(self):
        original_list = flavors.get_all_types()

        flavor = flavors.create("flavor", 64, 1, 120)

        # Ensure new type shows up in list
        new_list = flavors.get_all_types()
        self.assertNotEqual(len(original_list), len(new_list), "instance type was not created")

        flavors.destroy("flavor")
        self.assertRaises(exception.InstanceTypeNotFound, flavors.get_instance_type, flavor["id"])

        # Deleted instance should not be in list anymore
        new_list = flavors.get_all_types()
        self.assertEqual(original_list, new_list)
开发者ID:sdague,项目名称:nova,代码行数:15,代码来源:test_instance_types.py


示例12: test_create_then_delete

    def test_create_then_delete(self):
        original_list = flavors.get_all_flavors()

        flavor = flavors.create('flavor', 64, 1, 120)

        # Ensure new type shows up in list
        new_list = flavors.get_all_flavors()
        self.assertNotEqual(len(original_list), len(new_list),
                            'instance type was not created')

        flavors.destroy('flavor')
        self.assertRaises(exception.InstanceTypeNotFound,
                          flavors.get_flavor, flavor['id'])

        # Deleted instance should not be in list anymore
        new_list = flavors.get_all_flavors()
        self.assertEqual(original_list, new_list)
开发者ID:MasterZ40,项目名称:nova,代码行数:17,代码来源:test_flavors.py


示例13: _delete

    def _delete(self, req, 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)

        try:
            flavor = flavors.get_flavor_by_flavor_id(
                    id, ctxt=context, read_deleted="no")
        except exception.FlavorNotFound as e:
            raise webob.exc.HTTPNotFound(explanation=e.format_message())

        flavors.destroy(flavor['name'])

        return webob.Response(status_int=202)
开发者ID:Dynavisor,项目名称:nova,代码行数:17,代码来源:flavormanage.py


示例14: test_create_then_delete

    def test_create_then_delete(self):
        original_list = flavors.get_all_flavors()

        flavor = flavors.create("flavor", 64, 1, 120)

        # Ensure new type shows up in list
        new_list = flavors.get_all_flavors()
        self.assertNotEqual(len(original_list), len(new_list), "instance type was not created")

        flavors.destroy("flavor")
        self.assertRaises(exception.FlavorNotFound, flavors.get_flavor, flavor.id)

        # Deleted instance should not be in list anymore
        new_list = flavors.get_all_flavors()
        self.assertEqual(len(original_list), len(new_list))
        for k in original_list.keys():
            f = original_list[k]
            self.assertIsInstance(f, objects.Flavor)
            self.assertEqual(f.flavorid, new_list[k].flavorid)
开发者ID:isyippee,项目名称:nova,代码行数:19,代码来源:test_flavors.py


示例15: test_create_then_delete

    def test_create_then_delete(self):
        ctxt = context.get_admin_context()
        original_list = objects.FlavorList.get_all(ctxt)

        flavor = flavors.create('flavor', 64, 1, 120)

        # Ensure new type shows up in list
        new_list = objects.FlavorList.get_all(ctxt)
        self.assertNotEqual(len(original_list), len(new_list),
                            'instance type was not created')

        flavors.destroy('flavor')
        self.assertRaises(exception.FlavorNotFound,
                          objects.Flavor.get_by_id, ctxt, flavor.id)

        # Deleted instance should not be in list anymore
        new_list = objects.FlavorList.get_all(ctxt)
        self.assertEqual(len(original_list), len(new_list))
        for i, f in enumerate(original_list):
            self.assertIsInstance(f, objects.Flavor)
            self.assertEqual(f.flavorid, new_list[i].flavorid)
开发者ID:apporc,项目名称:nova,代码行数:21,代码来源:test_flavors.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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