当前位置: 首页>>代码示例>>Python>>正文


Python instance_types.destroy函数代码示例

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


在下文中一共展示了destroy函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = instance_types.get_all_types()

        # create new type and make sure values stick
        inst_type = instance_types.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 = instance_types.get_all_types()
        self.assertNotEqual(len(original_list), len(new_list), "instance type was not created")

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

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

示例2: 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 = instance_types.get_all_types()

        # create new type and make sure values stick
        inst_type = instance_types.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)

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

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

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

示例3: test_repeated_inst_types_should_raise_api_error

 def test_repeated_inst_types_should_raise_api_error(self):
     """Ensures that instance duplicates raises ApiError"""
     new_name = self.name + "dup"
     instance_types.create(new_name, 256, 1, 120, self.flavorid + 1)
     instance_types.destroy(new_name)
     self.assertRaises(
             exception.ApiError,
             instance_types.create, new_name, 256, 1, 120, self.flavorid)
开发者ID:AsherBond,项目名称:dodai-compute,代码行数:8,代码来源:test_instance_types.py

示例4: delete

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

示例5: test_instance_type_create_then_delete

 def test_instance_type_create_then_delete(self):
     """Ensure instance types can be created"""
     starting_inst_list = instance_types.get_all_types()
     instance_types.create(self.name, 256, 1, 120, self.flavorid)
     new = instance_types.get_all_types()
     self.assertNotEqual(len(starting_inst_list), len(new), "instance type was not created")
     instance_types.destroy(self.name)
     self.assertEqual(1, instance_types.get_instance_type(self.id)["deleted"])
     self.assertEqual(starting_inst_list, instance_types.get_all_types())
     instance_types.purge(self.name)
     self.assertEqual(len(starting_inst_list), len(instance_types.get_all_types()), "instance type not purged")
开发者ID:rajarammallya,项目名称:openstack-nova,代码行数:11,代码来源:test_instance_types.py

示例6: test_read_deleted_false_converting_flavorid

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

        instance_type = instance_types.get_instance_type_by_flavor_id("test1", read_deleted="no")
        self.assertEqual("instance_type1_redo", instance_type["name"])
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:12,代码来源:test_instance_types.py

示例7: delete

    def delete(self, req, id):
        qs = req.environ.get('QUERY_STRING', '')
        env = urlparse.parse_qs(qs)

        purge = env.get('purge', False)

        flavor = instance_types.get_instance_type_by_flavor_id(id)
        if purge:
            instance_types.purge(flavor['name'])
        else:
            instance_types.destroy(flavor['name'])

        return exc.HTTPAccepted()
开发者ID:mgius,项目名称:openstackx,代码行数:13,代码来源:admin.py

示例8: 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 = instance_types.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.
        instance_types.destroy(inst_type["name"])
        deleted_inst_type = instance_types.get_instance_type_by_flavor_id(inst_type_flavor_id)
        self.assertEqual(inst_type_name, deleted_inst_type["name"])
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:14,代码来源:test_instance_types.py

示例9: test_will_list_deleted_type_for_active_instance

    def test_will_list_deleted_type_for_active_instance(self):
        # Ensure deleted instance types with active instances can be read.
        ctxt = context.get_admin_context()
        inst_type = instance_types.create("test", 256, 1, 120, 100, "test1")

        instance_params = {"instance_type_id": inst_type["id"]}
        instance = db.instance_create(ctxt, instance_params)

        # NOTE(jk0): Delete the instance type and reload the instance from the
        # DB. The instance_type object will still be available to the active
        # instance, otherwise being None.
        instance_types.destroy(inst_type["name"])
        instance = db.instance_get_by_uuid(ctxt, instance["uuid"])

        self.assertRaises(exception.InstanceTypeNotFound, instance_types.get_instance_type, inst_type["name"])
        self.assertTrue(instance["instance_type"])
开发者ID:jamesbjackson,项目名称:openstack-smartos-nova-grizzly,代码行数:16,代码来源:test_instance_types.py

示例10: 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 = instance_types.get_all_types()

        # create new type and make sure values stick
        inst_type = instance_types.create(name, 256, 1, 120, 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['local_gb'], 120)
        self.assertEqual(inst_type['swap'], 0)
        self.assertEqual(inst_type['rxtx_quota'], 0)
        self.assertEqual(inst_type['rxtx_cap'], 0)

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

        # destroy instance and make sure deleted flag is set to True
        instance_types.destroy(name)
        inst_type = instance_types.get_instance_type(inst_type_id)
        self.assertEqual(1, inst_type["deleted"])

        # deleted instance should not be in list anymoer
        new_list = instance_types.get_all_types()
        self.assertEqual(original_list, new_list)

        # ensure instances are gone after purge
        instance_types.purge(name)
        new_list = instance_types.get_all_types()
        self.assertEqual(original_list, new_list,
                         'instance type not purged')
开发者ID:BillTheBest,项目名称:nova,代码行数:38,代码来源:test_instance_types.py


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