本文整理汇总了Python中nova.db.flavor_destroy函数的典型用法代码示例。如果您正苦于以下问题:Python flavor_destroy函数的具体用法?Python flavor_destroy怎么用?Python flavor_destroy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了flavor_destroy函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: migrate_flavors
def migrate_flavors(ctxt, count, hard_delete=False):
main_db_ids = _get_main_db_flavor_ids(ctxt, count)
if not main_db_ids:
return 0, 0
count_all = len(main_db_ids)
count_hit = 0
for flavor_id in main_db_ids:
try:
flavor = Flavor.get_by_id(ctxt, flavor_id)
flavor_values = {field: getattr(flavor, field)
for field in flavor.fields}
flavor._flavor_create(ctxt, flavor_values)
count_hit += 1
if hard_delete:
_destroy_flavor_hard(ctxt, flavor.name)
else:
db.flavor_destroy(ctxt, flavor.flavorid)
except exception.FlavorNotFound:
LOG.warning('Flavor id %(id)i disappeared during migration',
{'id': flavor_id})
except (exception.FlavorExists, exception.FlavorIdExists) as e:
LOG.error(six.text_type(e))
return count_all, count_hit
示例2: destroy
def destroy(name):
"""Marks flavor as deleted."""
try:
assert name is not None
db.flavor_destroy(context.get_admin_context(), name)
except (AssertionError, exception.NotFound):
LOG.exception(_('Instance type %s not found for deletion') % name)
raise exception.InstanceTypeNotFoundByName(instance_type_name=name)
示例3: destroy
def destroy(name):
"""Marks flavor as deleted."""
try:
if not name:
raise ValueError()
db.flavor_destroy(context.get_admin_context(), name)
except (ValueError, exception.NotFound):
LOG.exception(_('Instance type %s not found for deletion') % name)
raise exception.FlavorNotFoundByName(flavor_name=name)
示例4: destroy
def destroy(self):
# NOTE(danms): Historically the only way to delete a flavor
# is via name, which is not very precise. We need to be able to
# support the light construction of a flavor object and subsequent
# delete request with only our name filled out. However, if we have
# our id property, we should instead delete with that since it's
# far more specific.
try:
if 'id' in self:
self._flavor_destroy(self._context, flavor_id=self.id)
else:
self._flavor_destroy(self._context, name=self.name)
except exception.FlavorNotFound:
db.flavor_destroy(self._context, self.name)
示例5: tearDown
def tearDown(self):
db.flavor_destroy(
self.admin_context, self.disabled_type['name'])
super(DisabledFlavorsWithRealDBTestV21, self).tearDown()
示例6: tearDown
def tearDown(self):
db.flavor_destroy(context.get_admin_context(),
"test.small")
super(InstanceTypeCommandsTestCase, self).tearDown()
示例7: destroy
def destroy(self, context):
db.flavor_destroy(context, self.name)
示例8: destroy
def destroy(self):
db.flavor_destroy(self._context, self.name)
示例9: tearDown
def tearDown(self):
# Remove the instance type from the database
db.flavor_destroy(self.context, "cg1.4xlarge")
super(InstanceTypeExtraSpecsTestCase, self).tearDown()