summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorDan Smith <danms@us.ibm.com>2013-03-13 13:24:23 -0400
committerDan Smith <danms@us.ibm.com>2013-03-13 13:24:23 -0400
commit79acbf0ad730a4f58f7606c2f093b22a968f5562 (patch)
tree667f65ab4609db0e814d309ce9d58bcdd908c43d /nova/api
parent697843b2af4c47df299d47d1fd765eec79b160db (diff)
Fix use of potentially-stale instance_type in tenant_usage
The simple_tenant_usage API extension may return incorrect billing information if a flavor is changed or deleted while an instance using it is still running. This makes it use the stashed instance_type instead. Fixes bug 1154707 Change-Id: Ifce33488e5ef8aa942051d882407a3e2d088aaf5
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/compute/contrib/simple_tenant_usage.py15
1 files changed, 2 insertions, 13 deletions
diff --git a/nova/api/openstack/compute/contrib/simple_tenant_usage.py b/nova/api/openstack/compute/contrib/simple_tenant_usage.py
index f759e90b0..0fa9b9e40 100644
--- a/nova/api/openstack/compute/contrib/simple_tenant_usage.py
+++ b/nova/api/openstack/compute/contrib/simple_tenant_usage.py
@@ -24,7 +24,7 @@ from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.api.openstack import xmlutil
from nova.compute import api
-from nova import exception
+from nova.compute import instance_types
from nova.openstack.common import timeutils
authorize_show = extensions.extension_authorizer('compute',
@@ -119,18 +119,7 @@ class SimpleTenantUsageController(object):
info['hours'] = self._hours_for(instance,
period_start,
period_stop)
- flavor_type = instance['instance_type_id']
-
- if not flavors.get(flavor_type):
- try:
- it_ref = compute_api.get_instance_type(context,
- flavor_type)
- flavors[flavor_type] = it_ref
- except exception.InstanceTypeNotFound:
- # can't bill if there is no instance type
- continue
-
- flavor = flavors[flavor_type]
+ flavor = instance_types.extract_instance_type(instance)
info['instance_id'] = instance['uuid']
info['name'] = instance['display_name']