Read deleted flavors when using to_xml()

Fixes bug 1073736

Extend get_instance_type to accept an optional flag to return inactive
flavors and use this within to_xml().

Change-Id: Id01724a85d9aff3b32b3502be06a84578fa8f4df
Cherry-Picked: d8970d6b78
This commit is contained in:
Rafi Khardalian 2012-10-31 22:24:43 +00:00
parent 15815057db
commit 8d1095c13f
2 changed files with 6 additions and 2 deletions

View File

@ -128,7 +128,7 @@ def get_default_instance_type():
return get_instance_type_by_name(name)
def get_instance_type(instance_type_id, ctxt=None):
def get_instance_type(instance_type_id, ctxt=None, inactive=False):
"""Retrieves single instance type by id."""
if instance_type_id is None:
return get_default_instance_type()
@ -136,6 +136,9 @@ def get_instance_type(instance_type_id, ctxt=None):
if ctxt is None:
ctxt = context.get_admin_context()
if inactive:
ctxt = ctxt.elevated(read_deleted="yes")
return db.instance_type_get(ctxt, instance_type_id)

View File

@ -1678,7 +1678,8 @@ class LibvirtDriver(driver.ComputeDriver):
"""
# FIXME(vish): stick this in db
inst_type_id = instance['instance_type_id']
inst_type = instance_types.get_instance_type(inst_type_id)
inst_type = instance_types.get_instance_type(inst_type_id,
inactive=True)
guest = config.LibvirtConfigGuest()
guest.virt_type = FLAGS.libvirt_type