diff --git a/cinder/context.py b/cinder/context.py index 05b5396f7ae..2e077d79fdb 100644 --- a/cinder/context.py +++ b/cinder/context.py @@ -91,7 +91,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 ('compute')] + if s.get('type') in ('compute',)] else: # if list is empty or none self.service_catalog = [] diff --git a/cinder/tests/test_context.py b/cinder/tests/test_context.py index 46722d91f23..48323c7a9b2 100644 --- a/cinder/tests/test_context.py +++ b/cinder/tests/test_context.py @@ -70,3 +70,20 @@ class ContextTestCase(test.TestCase): self.assertTrue(c) self.assertIn("'extra_arg1': 'meow'", info['log_msg']) self.assertIn("'extra_arg2': 'wuff'", info['log_msg']) + + def test_service_catalog_nova_only(self): + service_catalog = [ + {u'type': u'compute', u'name': u'nova'}, + {u'type': u's3', u'name': u's3'}, + {u'type': u'image', u'name': u'glance'}, + {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': None, u'name': u'S_withtypeNone'}, + {u'type': u'co', u'name': u'S_partofcompute'}] + + compute_catalog = [{u'type': u'compute', u'name': u'nova'}] + ctxt = context.RequestContext('111', '222', + service_catalog=service_catalog) + self.assertEquals(ctxt.service_catalog, compute_catalog)