From fada5d801c699da16e8e600d474a1da94fb7f4d2 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 27 Jun 2012 17:20:49 +0000 Subject: Make nova list/show behave nicely on instance_type deletion One shouldn't remove an instance_type from the DB outright... but we should make the code behave nicely in the rare case. Fixes bug 1018500 Change-Id: If742070d7982889a56709ae058cd106e3a63114b --- nova/api/openstack/compute/views/servers.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'nova/api') diff --git a/nova/api/openstack/compute/views/servers.py b/nova/api/openstack/compute/views/servers.py index f14773e98..b0c2fb2b2 100644 --- a/nova/api/openstack/compute/views/servers.py +++ b/nova/api/openstack/compute/views/servers.py @@ -179,7 +179,12 @@ class ViewBuilder(common.ViewBuilder): } def _get_flavor(self, request, instance): - flavor_id = instance["instance_type"]["flavorid"] + instance_type = instance["instance_type"] + if not instance_type: + LOG.warn(_("Instance has had its instance_type removed " + "from the DB"), instance=instance) + return {} + flavor_id = instance_type["flavorid"] flavor_bookmark = self._flavor_builder._get_bookmark_link(request, flavor_id, "flavors") -- cgit