summaryrefslogtreecommitdiffstats
path: root/nova/context.py
diff options
context:
space:
mode:
authorDavanum Srinivas <dims@linux.vnet.ibm.com>2013-03-18 15:28:57 -0400
committerDavanum Srinivas <dims@linux.vnet.ibm.com>2013-03-18 18:06:52 -0400
commit4664d2294aed498ef013afc1689740f03de80a6c (patch)
tree190346ebe622de6a6a933d3c8303d8cbb95b2051 /nova/context.py
parent85aebeb8b864f990cdfb78b6deafc8a3fe3c1e23 (diff)
downloadnova-4664d2294aed498ef013afc1689740f03de80a6c.tar.gz
nova-4664d2294aed498ef013afc1689740f03de80a6c.tar.xz
nova-4664d2294aed498ef013afc1689740f03de80a6c.zip
Fix RequestContext crashes w/ no service catalog
Code introduced in a prev review assumed service_catalog will be at least an empty list and will never be None. But missed one code path where the service_catalog could potentially be set to None. So this change switches back the default value of service_catalog in the arguments to None and makes sure we tolerate anyone else passing in a None or Empty list as service_catalog Fix for LP# 1156730 Change-Id: I480b761d57c4699ea7ef72114160cdbeb281e454
Diffstat (limited to 'nova/context.py')
-rw-r--r--nova/context.py12
1 files changed, 9 insertions, 3 deletions
diff --git a/nova/context.py b/nova/context.py
index 714948e90..cd4428e58 100644
--- a/nova/context.py
+++ b/nova/context.py
@@ -47,7 +47,7 @@ class RequestContext(object):
roles=None, remote_address=None, timestamp=None,
request_id=None, auth_token=None, overwrite=True,
quota_class=None, user_name=None, project_name=None,
- service_catalog=[], instance_lock_checked=False, **kwargs):
+ service_catalog=None, instance_lock_checked=False, **kwargs):
"""
:param read_deleted: 'no' indicates deleted records are hidden, 'yes'
indicates deleted records are visible, 'only' indicates that
@@ -77,9 +77,15 @@ class RequestContext(object):
request_id = generate_request_id()
self.request_id = request_id
self.auth_token = auth_token
- # Only include required parts of service_catalog
- self.service_catalog = [s for s in service_catalog
+
+ if service_catalog:
+ # Only include required parts of service_catalog
+ self.service_catalog = [s for s in service_catalog
if s.get('type') in ('volume')]
+ else:
+ # if list is empty or none
+ self.service_catalog = []
+
self.instance_lock_checked = instance_lock_checked
# NOTE(markmc): this attribute is currently only used by the