Fixes RequestContext initialization failure.

RequestContext initialization failed in nova because of the following
error:
"TypeError: 'in <string>' requires string as left operand, not NoneType"

It must traverses in tuple not in string when find the "volume" service_catalog.

Change-Id: Ie0de50fcafbeabf4698696add610d4e6804f45eb
Closes-Bug: #1248424
This commit is contained in:
huangtianhua
2013-11-06 15:26:35 +08:00
parent 8cea914ac7
commit 94c1ad5c0e
2 changed files with 4 additions and 2 deletions

View File

@@ -82,7 +82,7 @@ class RequestContext(object):
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')]
if s.get('type') in ('volume',)]
else:
# if list is empty or none
self.service_catalog = []

View File

@@ -95,7 +95,9 @@ class ContextTestCase(test.NoDBTestCase):
{u'type': u'volume', u'name': u'cinder'},
{u'type': u'ec2', u'name': u'ec2'},
{u'type': u'object-store', u'name': u'swift'},
{u'type': u'identity', u'name': u'keystone'}]
{u'type': u'identity', u'name': u'keystone'},
{u'type': None, u'name': u'S_withouttype'},
{u'type': u'vo', u'name': u'S_partofvolume'}]
volume_catalog = [{u'type': u'volume', u'name': u'cinder'}]
ctxt = context.RequestContext('111', '222',