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