summaryrefslogtreecommitdiffstats
path: root/nova/utils.py
diff options
context:
space:
mode:
authorNachi Ueno <ueno.nachi@lab.ntt.co.jp>2011-08-22 14:45:18 -0700
committerNachi Ueno <ueno.nachi@lab.ntt.co.jp>2011-08-22 14:45:18 -0700
commit63a1591fb502fbabe050363beb7ef89aa745a567 (patch)
treedcb373d291f841555d2fd818f5853d99d0ac869d /nova/utils.py
parent5a288485215a13f3892ae17a46b9644ed84fc089 (diff)
parentdd9d9195b0d77e2801e001be45aafe9bc14b4b2c (diff)
downloadnova-63a1591fb502fbabe050363beb7ef89aa745a567.tar.gz
nova-63a1591fb502fbabe050363beb7ef89aa745a567.tar.xz
nova-63a1591fb502fbabe050363beb7ef89aa745a567.zip
Fixed conflict with branch
Diffstat (limited to 'nova/utils.py')
-rw-r--r--nova/utils.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/nova/utils.py b/nova/utils.py
index be2ba68f9..44a0d4398 100644
--- a/nova/utils.py
+++ b/nova/utils.py
@@ -296,7 +296,7 @@ EASIER_PASSWORD_SYMBOLS = ('23456789' # Removed: 0, 1
def usage_from_instance(instance_ref, **kw):
usage_info = dict(
- tenant_id=instance_ref['project_id'],
+ project_id=instance_ref['project_id'],
user_id=instance_ref['user_id'],
instance_id=instance_ref['id'],
instance_type=instance_ref['instance_type']['name'],
@@ -548,11 +548,17 @@ def to_primitive(value, convert_instances=False, level=0):
Therefore, convert_instances=True is lossy ... be aware.
"""
- if inspect.isclass(value):
- return unicode(value)
+ nasty = [inspect.ismodule, inspect.isclass, inspect.ismethod,
+ inspect.isfunction, inspect.isgeneratorfunction,
+ inspect.isgenerator, inspect.istraceback, inspect.isframe,
+ inspect.iscode, inspect.isbuiltin, inspect.isroutine,
+ inspect.isabstract]
+ for test in nasty:
+ if test(value):
+ return unicode(value)
if level > 3:
- return []
+ return '?'
# The try block may not be necessary after the class check above,
# but just in case ...