本文整理汇总了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)
示例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)
示例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)
示例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)
示例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")
示例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"])
示例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()
示例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"])
示例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"])
示例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')